plugin_path = plugin_dir_path( dirname( __FILE__, 2 ) ); $this->plugin_url = plugin_dir_url( dirname( __FILE__, 2 ) ); $this->plugin = plugin_basename( dirname( __FILE__, 3 ) ) . '/pixvisualize.php'; $this->managers = array( 'pixvisualize_block_manager' => __( 'Activate PixVisualize Block', 'pixvisualize' ), 'pixvisualize_elementor_manager' => __( 'Activate PixVisualize Elementor Widget', 'pixvisualize' ), 'pixvisualize_shortcode_manager' => __( 'Activate PixVisualize Shortcodes', 'pixvisualize' ), 'pixvisualize_woocommerce_manager' => __( 'Activate PixVisualize WooCommerce Gallery', 'pixvisualize' ), ); } public function activated( string $key ) { $option = get_option( 'pixvisualize' ); // When the option has never been created (e.g. network/multisite // activation where the activation hook does not fire), enable the // managers by default instead of silently leaving them disabled. if ( ! is_array( $option ) ) { return true; } return isset( $option[ $key ] ) ? $option[ $key ] : true; } /** * Render the comparison slider (block, shortcode, Elementor, WooCommerce). * * @param array $atts Slider settings. * @return string */ protected function buildSliderMarkup( array $atts ) { $atts = wp_parse_args( $atts, array( 'before' => '', 'after' => '', 'position' => 50, 'before_label' => 'Before', 'after_label' => 'After', 'show_labels' => 1, 'orientation' => 'horizontal', 'height' => 450, 'ratio' => '16/9', 'full_width' => 0, 'handle' => 'circle', 'svg' => '', 'handle_size' => 24, 'handle_bg' => '', 'handle_arrow_color' => '#666666', 'handle_padding' => 0, 'label_position_before' => 'top-left', 'label_position_after' => 'top-right', 'label_bg' => '#00000080', 'label_color' => '#ffffff', 'label_font_size' => 12, 'label_font_weight' => 600, 'label_padding_x' => 10, 'label_padding_y' => 5, 'label_border_radius' => 4, 'separator_thickness' => 2, 'separator_color' => '#ffffff', 'separator_shadow' => 1, 'hover' => 0, 'autoscan' => 0, 'autoscan_duration' => 2500, 'magnifier' => 0, 'magnifier_zoom' => 2, 'tablet_position' => 50, 'mobile_position' => 50, 'tablet_ratio' => '', 'mobile_ratio' => '', 'alignment' => 'center', 'caption_title' => '', 'caption_text' => '', 'show_caption' => 1, 'caption_bg' => '#ffffff', 'caption_title_color' => '#1e293b', 'caption_text_color' => '#64748b', 'caption_alignment' => 'center', 'caption_title_size' => 22, 'caption_text_size' => 15, 'caption_padding' => 16, 'caption_padding_x' => 5, 'caption_padding_y' => 9, 'container_shadow' => 0, 'container_shadow_color' => '#000000', 'container_shadow_horizontal' => 0, 'container_shadow_vertical' => 8, 'container_shadow_blur' => 20, 'container_shadow_spread' => 0, 'container_shadow_opacity' => 35, 'container_border_width' => 0, // Free presets: 2px gray border, 16px radius. Pro settings win when set. 'container_border' => 0, 'container_rounded' => 0, 'container_border_color' => '#000000', 'container_border_style' => 'solid', 'container_border_radius_tl' => 0, 'container_border_radius_tr' => 0, 'container_border_radius_br' => 0, 'container_border_radius_bl' => 0, 'extra_class' => '', ) ); $blockId = 'pixvisualize-block-' . uniqid(); $output = '
'; $output .= '
'; $output .= '
'; return $output; } /** * Enqueue front-end slider assets for any placement. * * @return void */ protected function enqueueViewAssets() { $build_dir = function_exists( 'pixvisualize_get_build_dir' ) ? pixvisualize_get_build_dir() : 'build'; if ( ! wp_script_is( 'create-block-pixvisualize-view', 'registered' ) ) { $asset_file = $this->plugin_path . $build_dir . '/pixvisualize/view.asset.php'; if ( ! file_exists( $asset_file ) ) { return; } $asset = include $asset_file; wp_register_script( 'create-block-pixvisualize-view', $this->plugin_url . $build_dir . '/pixvisualize/view.js', $asset['dependencies'], $asset['version'], true ); wp_register_style( 'create-block-pixvisualize-style', $this->plugin_url . $build_dir . '/pixvisualize/style-index.css', array(), $asset['version'] ); } wp_enqueue_script( 'create-block-pixvisualize-view' ); wp_enqueue_style( 'create-block-pixvisualize-style' ); // Front-end slider strings (wp.i18n in view.js + shared components): // loaded like the editor/admin/woo handles so fallbacks, aria-label // and alt texts are localized on the public site too. wp_set_script_translations( 'create-block-pixvisualize-view', 'pixvisualize', $this->plugin_path . 'languages/' ); } }