Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/yith-woocommerce-zoom-magnifier/init.php
+++ b/yith-woocommerce-zoom-magnifier/init.php
@@ -1,156 +1,156 @@
-<?php
-/**
- * Plugin Name: YITH WooCommerce Product Gallery & Image Zoom
- * Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-zoom-magnifier/
- * Description: <code><strong>YITH WooCommerce Product Gallery & Image Zoom</strong></code> allows you to add a zoom effect to product images and a thumbnail slider for the product image gallery. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
- * Version: 2.52.0
- * Author: YITH
- * Author URI: https://yithemes.com/
- * Text Domain: yith-woocommerce-zoom-magnifier
- * Domain Path: /languages/
- * WC requires at least: 10.8
- * WC tested up to: 11.0
- * Requires Plugins: woocommerce
- *
- * @author YITH <plugins@yithemes.com>
- **/
-
-/* Copyright 2015-2026 Your Inspiration Themes S.L.U. (email : plugins@yithemes.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-if ( ! defined ( 'ABSPATH' ) ) {
- exit;
-} // Exit if accessed directly
-
-if ( ! function_exists( 'is_plugin_active' ) ) {
- if ( ! function_exists( 'get_plugin_data' ) ) {
- require_once(ABSPATH . 'wp-admin/includes/plugin.php');
- }
-}
-
-if ( ! function_exists ( 'yith_ywzm_install_woocommerce_admin_notice' ) ) {
- /**
- * WooCommerce is not enabled, the plugin will not be effective
- *
- * @since 1.0.0
- */
- function yith_ywzm_install_woocommerce_admin_notice () {
- ?>
- <div class="error">
- <p><?php _e ( 'YITH WooCommerce Product Gallery & Image Zoom is enabled but not effective. It requires WooCommerce in order to work.', 'yith-woocommerce-zoom-magnifier' ); ?></p>
- </div>
- <?php
- }
-}
-
-if ( ! function_exists ( 'yith_ywzm_install_free_admin_notice' ) ) {
- /**
- * Unable to activate the free version while the premium version is active
- *
- * @since 1.0.0
- */
- function yith_ywzm_install_free_admin_notice () {
- ?>
- <div class="error">
- <p><?php _e ( 'You can't activate the free version of YITH WooCommerce Product Gallery & Image Zoom while you are using the premium one.', 'yith-woocommerce-zoom-magnifier' ); ?></p>
- </div>
- <?php
- }
-}
-
-if ( ! function_exists ( 'yith_plugin_registration_hook' ) ) {
- require_once 'plugin-fw/yit-plugin-registration-hook.php';
-}
-
-register_activation_hook ( __FILE__, 'yith_plugin_registration_hook' );
-
-defined( 'YITH_YWZM_FREE' ) || define( 'YITH_YWZM_FREE', '1' );
-defined ( 'YITH_YWZM_FREE_INIT' ) || define ( 'YITH_YWZM_FREE_INIT', plugin_basename ( __FILE__ ) );
-defined ( 'YITH_YWZM_SLUG' ) || define ( 'YITH_YWZM_SLUG', 'yith-woocommerce-zoom-magnifier' );
-defined ( 'YITH_YWZM_VERSION' ) || define ( 'YITH_YWZM_VERSION', '2.52.0' );
-defined ( 'YITH_YWZM_SCRIPT_VERSION' ) || define ( 'YITH_YWZM_SCRIPT_VERSION', '2.1.1' );
-
-defined ( 'YITH_YWZM_FILE' ) || define ( 'YITH_YWZM_FILE', __FILE__ );
-defined ( 'YITH_YWZM_DIR' ) || define ( 'YITH_YWZM_DIR', plugin_dir_path ( __FILE__ ) );
-defined ( 'YITH_YWZM_URL' ) || define ( 'YITH_YWZM_URL', plugins_url ( '/', __FILE__ ) );
-defined ( 'YITH_YWZM_ASSETS_URL' ) || define ( 'YITH_YWZM_ASSETS_URL', YITH_YWZM_URL . 'assets' );
-defined ( 'YITH_YWZM_TEMPLATE_DIR' ) || define ( 'YITH_YWZM_TEMPLATE_DIR', YITH_YWZM_DIR . 'templates' );
-defined ( 'YITH_YWZM_ASSETS_IMAGES_URL' ) || define ( 'YITH_YWZM_ASSETS_IMAGES_URL', YITH_YWZM_ASSETS_URL . '/images/' );
-defined ( 'YITH_YWZM_LIB_DIR' ) || define ( 'YITH_YWZM_LIB_DIR', YITH_YWZM_DIR . 'lib/' );
-
-// Plugin Framework Loader.
-if ( file_exists( plugin_dir_path( __FILE__ ) . 'plugin-fw/init.php' ) ) {
- require_once plugin_dir_path( __FILE__ ) . 'plugin-fw/init.php';
-}
-
-if ( ! function_exists ( 'yith_ywzm_init' ) ) {
- /**
- * Init the plugin
- *
- * @since 1.0.0
- */
- function yith_ywzm_init () {
-
- /**
- * Load text domain and start plugin
- */
- if ( function_exists( 'yith_plugin_fw_load_plugin_textdomain' ) ) {
- yith_plugin_fw_load_plugin_textdomain( 'yith-woocommerce-zoom-magnifier', basename( dirname( __FILE__ ) ) . '/languages' );
- }
-
- add_option ( 'yith_wcmg_slider_direction', apply_filters ( 'yith_wcmg_slider_direction', 'left' ) );
-
- define ( 'YITH_WCMG', true );
- define ( 'YITH_WCMG_URL', plugin_dir_url ( __FILE__ ) );
-
- // Load required classes and functions
- require_once ( YITH_YWZM_LIB_DIR . 'class.yith-wcmg-admin.php' );
- require_once ( YITH_YWZM_LIB_DIR . 'class.yith-wcmg-frontend.php' );
- require_once ( YITH_YWZM_LIB_DIR . 'class.yith-woocommerce-zoom-magnifier.php' );
- require_once ( YITH_YWZM_LIB_DIR . 'class.yith-ywzm-plugin-fw-loader.php' );
- require_once ( YITH_YWZM_LIB_DIR . 'functions.yith-ywzm.php' );
-
- YITH_YWZM_Plugin_FW_Loader::get_instance ();
-
- // Let's start the game!
- global $yith_wcmg;
-
- $yith_wcmg = new YITH_WooCommerce_Zoom_Magnifier();
- }
-}
-add_action ( 'yith_ywzm_init', 'yith_ywzm_init' );
-
-if ( ! function_exists ( 'yith_ywzm_install' ) ) {
- /**
- * install the plugin
- *
- * @since 1.0.0
- */
- function yith_ywzm_install () {
-
- if ( ! function_exists ( 'WC' ) ) {
- add_action ( 'admin_notices', 'yith_ywzm_install_woocommerce_admin_notice' );
- } elseif ( defined ( 'YITH_YWZM_PREMIUM' ) ) {
- add_action ( 'admin_notices', 'yith_ywzm_install_free_admin_notice' );
- deactivate_plugins ( plugin_basename ( __FILE__ ) );
- } else {
- do_action ( 'yith_ywzm_init' );
- }
-
- }
-}
-
-add_action ( 'plugins_loaded', 'yith_ywzm_install', 11 );
+<?php
+/**
+ * Plugin Name: YITH WooCommerce Product Gallery & Image Zoom
+ * Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-zoom-magnifier/
+ * Description: <code><strong>YITH WooCommerce Product Gallery & Image Zoom</strong></code> allows you to add a zoom effect to product images and a thumbnail slider for the product image gallery. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
+ * Version: 2.52.1
+ * Author: YITH
+ * Author URI: https://yithemes.com/
+ * Text Domain: yith-woocommerce-zoom-magnifier
+ * Domain Path: /languages/
+ * WC requires at least: 10.8
+ * WC tested up to: 11.0
+ * Requires Plugins: woocommerce
+ *
+ * @author YITH <plugins@yithemes.com>
+ **/
+
+/* Copyright 2015-2026 Your Inspiration Themes S.L.U. (email : plugins@yithemes.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+if ( ! defined ( 'ABSPATH' ) ) {
+ exit;
+} // Exit if accessed directly
+
+if ( ! function_exists( 'is_plugin_active' ) ) {
+ if ( ! function_exists( 'get_plugin_data' ) ) {
+ require_once(ABSPATH . 'wp-admin/includes/plugin.php');
+ }
+}
+
+if ( ! function_exists ( 'yith_ywzm_install_woocommerce_admin_notice' ) ) {
+ /**
+ * WooCommerce is not enabled, the plugin will not be effective
+ *
+ * @since 1.0.0
+ */
+ function yith_ywzm_install_woocommerce_admin_notice () {
+ ?>
+ <div class="error">
+ <p><?php _e ( 'YITH WooCommerce Product Gallery & Image Zoom is enabled but not effective. It requires WooCommerce in order to work.', 'yith-woocommerce-zoom-magnifier' ); ?></p>
+ </div>
+ <?php
+ }
+}
+
+if ( ! function_exists ( 'yith_ywzm_install_free_admin_notice' ) ) {
+ /**
+ * Unable to activate the free version while the premium version is active
+ *
+ * @since 1.0.0
+ */
+ function yith_ywzm_install_free_admin_notice () {
+ ?>
+ <div class="error">
+ <p><?php _e ( 'You can't activate the free version of YITH WooCommerce Product Gallery & Image Zoom while you are using the premium one.', 'yith-woocommerce-zoom-magnifier' ); ?></p>
+ </div>
+ <?php
+ }
+}
+
+if ( ! function_exists ( 'yith_plugin_registration_hook' ) ) {
+ require_once 'plugin-fw/yit-plugin-registration-hook.php';
+}
+
+register_activation_hook ( __FILE__, 'yith_plugin_registration_hook' );
+
+defined( 'YITH_YWZM_FREE' ) || define( 'YITH_YWZM_FREE', '1' );
+defined ( 'YITH_YWZM_FREE_INIT' ) || define ( 'YITH_YWZM_FREE_INIT', plugin_basename ( __FILE__ ) );
+defined ( 'YITH_YWZM_SLUG' ) || define ( 'YITH_YWZM_SLUG', 'yith-woocommerce-zoom-magnifier' );
+defined ( 'YITH_YWZM_VERSION' ) || define ( 'YITH_YWZM_VERSION', '2.52.1' );
+defined ( 'YITH_YWZM_SCRIPT_VERSION' ) || define ( 'YITH_YWZM_SCRIPT_VERSION', '2.1.1' );
+
+defined ( 'YITH_YWZM_FILE' ) || define ( 'YITH_YWZM_FILE', __FILE__ );
+defined ( 'YITH_YWZM_DIR' ) || define ( 'YITH_YWZM_DIR', plugin_dir_path ( __FILE__ ) );
+defined ( 'YITH_YWZM_URL' ) || define ( 'YITH_YWZM_URL', plugins_url ( '/', __FILE__ ) );
+defined ( 'YITH_YWZM_ASSETS_URL' ) || define ( 'YITH_YWZM_ASSETS_URL', YITH_YWZM_URL . 'assets' );
+defined ( 'YITH_YWZM_TEMPLATE_DIR' ) || define ( 'YITH_YWZM_TEMPLATE_DIR', YITH_YWZM_DIR . 'templates' );
+defined ( 'YITH_YWZM_ASSETS_IMAGES_URL' ) || define ( 'YITH_YWZM_ASSETS_IMAGES_URL', YITH_YWZM_ASSETS_URL . '/images/' );
+defined ( 'YITH_YWZM_LIB_DIR' ) || define ( 'YITH_YWZM_LIB_DIR', YITH_YWZM_DIR . 'lib/' );
+
+// Plugin Framework Loader.
+if ( file_exists( plugin_dir_path( __FILE__ ) . 'plugin-fw/init.php' ) ) {
+ require_once plugin_dir_path( __FILE__ ) . 'plugin-fw/init.php';
+}
+
+if ( ! function_exists ( 'yith_ywzm_init' ) ) {
+ /**
+ * Init the plugin
+ *
+ * @since 1.0.0
+ */
+ function yith_ywzm_init () {
+
+ /**
+ * Load text domain and start plugin
+ */
+ if ( function_exists( 'yith_plugin_fw_load_plugin_textdomain' ) ) {
+ yith_plugin_fw_load_plugin_textdomain( 'yith-woocommerce-zoom-magnifier', basename( dirname( __FILE__ ) ) . '/languages' );
+ }
+
+ add_option ( 'yith_wcmg_slider_direction', apply_filters ( 'yith_wcmg_slider_direction', 'left' ) );
+
+ define ( 'YITH_WCMG', true );
+ define ( 'YITH_WCMG_URL', plugin_dir_url ( __FILE__ ) );
+
+ // Load required classes and functions
+ require_once ( YITH_YWZM_LIB_DIR . 'class.yith-wcmg-admin.php' );
+ require_once ( YITH_YWZM_LIB_DIR . 'class.yith-wcmg-frontend.php' );
+ require_once ( YITH_YWZM_LIB_DIR . 'class.yith-woocommerce-zoom-magnifier.php' );
+ require_once ( YITH_YWZM_LIB_DIR . 'class.yith-ywzm-plugin-fw-loader.php' );
+ require_once ( YITH_YWZM_LIB_DIR . 'functions.yith-ywzm.php' );
+
+ YITH_YWZM_Plugin_FW_Loader::get_instance ();
+
+ // Let's start the game!
+ global $yith_wcmg;
+
+ $yith_wcmg = new YITH_WooCommerce_Zoom_Magnifier();
+ }
+}
+add_action ( 'yith_ywzm_init', 'yith_ywzm_init' );
+
+if ( ! function_exists ( 'yith_ywzm_install' ) ) {
+ /**
+ * install the plugin
+ *
+ * @since 1.0.0
+ */
+ function yith_ywzm_install () {
+
+ if ( ! function_exists ( 'WC' ) ) {
+ add_action ( 'admin_notices', 'yith_ywzm_install_woocommerce_admin_notice' );
+ } elseif ( defined ( 'YITH_YWZM_PREMIUM' ) ) {
+ add_action ( 'admin_notices', 'yith_ywzm_install_free_admin_notice' );
+ deactivate_plugins ( plugin_basename ( __FILE__ ) );
+ } else {
+ do_action ( 'yith_ywzm_init' );
+ }
+
+ }
+}
+
+add_action ( 'plugins_loaded', 'yith_ywzm_install', 11 );
--- a/yith-woocommerce-zoom-magnifier/lib/class.yith-wcmg-admin.php
+++ b/yith-woocommerce-zoom-magnifier/lib/class.yith-wcmg-admin.php
@@ -1,97 +1,97 @@
-<?php // phpcs:ignore WordPress.Files.FileName
-/**
- * Admin class
- *
- * @author YITH <plugins@yithemes.com>
- * @package YITHZoomMagnifierClasses
- * @version 1.1.2
- */
-
-if ( ! defined( 'YITH_WCMG' ) ) {
- exit;
-} // Exit if accessed directly
-
-if ( ! class_exists( 'YITH_WCMG_Admin' ) ) {
- /**
- * Admin class.
- * The class manage all the admin behaviors.
- *
- * @since 1.0.0
- */
- class YITH_WCMG_Admin {
- /**
- * Plugin options
- *
- * @var array
- * @access public
- * @since 1.0.0
- */
- public $options = array();
-
- /**
- * Docs URL.
- *
- * @var string
- * @access public
- * @since 1.0.0
- */
- public $doc_url = 'https://docs.yithemes.com/yith-woocommerce-zoom-magnifier/';
-
- /**
- * Constructor
- *
- * @access public
- * @since 1.0.0
- */
- public function __construct() {
-
- // Actions.
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
-
- // YITH WCMG Loaded.
- do_action( 'yith_wcmg_loaded' );
- }
-
- /**
- * Enqueue admin styles and scripts
- *
- * @access public
- * @return void
- * @since 1.0.0
- */
- public function enqueue_styles_scripts() {
-
- wp_enqueue_script( 'jquery-ui' );
- wp_enqueue_script( 'jquery-ui-core' );
- wp_enqueue_script( 'jquery-ui-mouse' );
- wp_enqueue_script( 'jquery-ui-slider' );
-
- wp_enqueue_style( 'yith_wcmg_admin', YITH_WCMG_URL . 'assets/css/admin.css', array(), YITH_YWZM_SCRIPT_VERSION );
-
- if ( isset( $_REQUEST[ 'page' ] ) && $_REQUEST[ 'page' ] === 'yith_woocommerce_zoom-magnifier_panel' ){
-
- wp_register_script(
- 'ywzm_backend',
- YITH_YWZM_ASSETS_URL . '/js/ywzm_backend.js',
- array(
- 'jquery',
- ),
- YITH_YWZM_SCRIPT_VERSION,
- true
- );
-
- wp_localize_script(
- 'ywzm_backend',
- 'ywzm_data',
- array()
- );
-
- wp_enqueue_script( 'ywzm_backend' );
-
- }
-
-
-
- }
- }
-}
+<?php // phpcs:ignore WordPress.Files.FileName
+/**
+ * Admin class
+ *
+ * @author YITH <plugins@yithemes.com>
+ * @package YITHZoomMagnifierClasses
+ * @version 1.1.2
+ */
+
+if ( ! defined( 'YITH_WCMG' ) ) {
+ exit;
+} // Exit if accessed directly
+
+if ( ! class_exists( 'YITH_WCMG_Admin' ) ) {
+ /**
+ * Admin class.
+ * The class manage all the admin behaviors.
+ *
+ * @since 1.0.0
+ */
+ class YITH_WCMG_Admin {
+ /**
+ * Plugin options
+ *
+ * @var array
+ * @access public
+ * @since 1.0.0
+ */
+ public $options = array();
+
+ /**
+ * Docs URL.
+ *
+ * @var string
+ * @access public
+ * @since 1.0.0
+ */
+ public $doc_url = 'https://docs.yithemes.com/yith-woocommerce-zoom-magnifier/';
+
+ /**
+ * Constructor
+ *
+ * @access public
+ * @since 1.0.0
+ */
+ public function __construct() {
+
+ // Actions.
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
+
+ // YITH WCMG Loaded.
+ do_action( 'yith_wcmg_loaded' );
+ }
+
+ /**
+ * Enqueue admin styles and scripts
+ *
+ * @access public
+ * @return void
+ * @since 1.0.0
+ */
+ public function enqueue_styles_scripts() {
+
+ wp_enqueue_script( 'jquery-ui' );
+ wp_enqueue_script( 'jquery-ui-core' );
+ wp_enqueue_script( 'jquery-ui-mouse' );
+ wp_enqueue_script( 'jquery-ui-slider' );
+
+ wp_enqueue_style( 'yith_wcmg_admin', YITH_WCMG_URL . 'assets/css/admin.css', array(), YITH_YWZM_SCRIPT_VERSION );
+
+ if ( isset( $_REQUEST[ 'page' ] ) && $_REQUEST[ 'page' ] === 'yith_woocommerce_zoom-magnifier_panel' ){
+
+ wp_register_script(
+ 'ywzm_backend',
+ YITH_YWZM_ASSETS_URL . '/js/ywzm_backend.js',
+ array(
+ 'jquery',
+ ),
+ YITH_YWZM_SCRIPT_VERSION,
+ true
+ );
+
+ wp_localize_script(
+ 'ywzm_backend',
+ 'ywzm_data',
+ array()
+ );
+
+ wp_enqueue_script( 'ywzm_backend' );
+
+ }
+
+
+
+ }
+ }
+}
--- a/yith-woocommerce-zoom-magnifier/lib/class.yith-wcmg-frontend.php
+++ b/yith-woocommerce-zoom-magnifier/lib/class.yith-wcmg-frontend.php
@@ -1,399 +1,399 @@
-<?php // phpcs:ignore WordPress.Files.FileName
-/**
- * Frontend class
- *
- * @author YITH <plugins@yithemes.com>
- * @package YITHZoomMagnifierClasses
- * @version 1.1.2
- */
-
-if ( ! defined( 'YITH_WCMG' ) ) {
- exit;
-} // Exit if accessed directly
-
-if ( ! class_exists( 'YITH_WCMG_Frontend' ) ) {
- /**
- * Admin class.
- * The class manage all the Frontend behaviors.
- *
- * @since 1.0.0
- */
- class YITH_WCMG_Frontend {
-
-
- /**
- * Constructor
- *
- * @access public
- * @since 1.0.0
- */
- public function __construct() {
-
- // add the action only when the loop is initializate.
- add_action( 'template_redirect', array( $this, 'render' ) );
- }
-
- /**
- * Render zoom.
- */
- public function render() {
- if ( ! apply_filters( 'yith_wczm_featured_video_enabled', false ) ) {
-
-
- //Zoom template
- remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
- add_action( 'woocommerce_before_single_product_summary', array( $this, 'show_product_images' ), 20 );
-
- //Slider template
- remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
-
- if ( get_option( 'ywzm_hide_thumbnails', 'no' ) !== 'yes' )
- add_action( 'woocommerce_product_thumbnails', array( $this, 'show_product_thumbnails' ), 20 );
-
-
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
-
- // add attributes to product variations.
- add_filter( 'woocommerce_available_variation', array( $this, 'available_variation' ), 10, 3 );
- }
- }
-
-
- /**
- * Change product-single.php template
- *
- * @access public
- * @return void
- * @since 1.0.0
- */
- public function show_product_images() {
- wc_get_template( 'single-product/product-image-magnifier.php', array(), '', YITH_YWZM_DIR . 'templates/' );
- }
-
-
- /**
- * Change product-thumbnails.php template
- *
- * @access public
- * @return void
- * @since 1.0.0
- */
- public function show_product_thumbnails() {
-
- wc_get_template( 'single-product/product-thumbnails-magnifier.php', array(), '', YITH_YWZM_DIR . 'templates/' );
- }
-
-
- /**
- * Enqueue styles and scripts
- *
- * @access public
- * @return void
- * @since 1.0.0
- */
- public function enqueue_styles_scripts() {
- global $post;
-
- if ( is_product() || ( ! empty( $post->post_content ) && strpos($post->post_content, 'product_page') !== false ) ) {
-
- wp_register_script(
- 'ywzm-magnifier',
- apply_filters( 'ywzm_magnifier_script_register_path', YITH_WCMG_URL . 'assets/js/' . yit_load_js_file( 'yith_magnifier.js' ) ),
- array( 'jquery' ),
- YITH_YWZM_SCRIPT_VERSION,
- true
- );
-
- /**
- * Avoid the stopImmediatePropagation on gallery click if the Featured Audio and Video plugin is enabled
- */
- $stop_immediate_propagation = function_exists( 'YITH_Featured_Audio_Video_Premium_Init') ? false : true;
-
- wp_localize_script(
- 'ywzm-magnifier',
- 'yith_wc_zoom_magnifier_storage_object',
- apply_filters(
- 'yith_wc_zoom_magnifier_front_magnifier_localize',
- array(
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
- 'mouse_trap_width' => apply_filters( 'yith_wczm_mouse_trap_with', '100%' ),
- 'mouse_trap_height' => apply_filters( 'yith_wczm_mouse_trap_height', '100%' ),
- 'stop_immediate_propagation' => $stop_immediate_propagation,
- )
- )
- );
-
- wp_register_script(
- 'ywzm_frontend',
- YITH_WCMG_URL . 'assets/js/' . yit_load_js_file( 'ywzm_frontend.js' ),
- array(
- 'jquery',
- 'ywzm-magnifier',
- ),
- YITH_YWZM_SCRIPT_VERSION,
- true
- );
-
- wp_register_style( 'ywzm-magnifier', YITH_WCMG_URL . 'assets/css/yith_magnifier.css', array(), YITH_YWZM_SCRIPT_VERSION );
-
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
-
- $slider_colors_default = Array(
- 'background' => 'white',
- 'border' => 'black',
- 'arrow' => 'black',
- );
-
- $slider_colors_array = get_option( 'yith_wcmg_slider_style_colors', $slider_colors_default );
- $slider_colors_hover_array = get_option( 'yith_wcmg_slider_style_colors_hover', $slider_colors_default );
-
- wp_localize_script(
- 'ywzm_frontend',
- 'ywzm_data',
- array(
- 'slider_colors_array' => $slider_colors_array,
- 'slider_colors_hover_array' => $slider_colors_hover_array,
- )
- );
-
- // Enqueue PrettyPhoto style and script.
- $wc_assets_path = str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/';
-
- // Enqueue scripts.
- wp_enqueue_script( 'wc-prettyPhoto', $wc_assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), WC()->version, true );
- wp_enqueue_script( 'ywzm-magnifier' );
- wp_enqueue_script( 'ywzm_frontend' );
-
- /**
- * Add custom init PrettyPhoto
- */
-
- wp_localize_script(
- 'ywzm_frontend',
- 'ywzm_prettyphoto_data',
- array(
- )
- );
-
- wp_enqueue_script( //phpcs:ignore
- 'yith-ywzm-prettyPhoto-init',
- apply_filters( 'ywzm_src_prettyphoto_script', YITH_WCMG_URL . 'assets/js/init.prettyPhoto.js' ),
- array(
- 'jquery',
- 'wc-prettyPhoto',
- ),
- false,
- true
- );
-
- // Enqueue Style.
- $css = file_exists( get_stylesheet_directory() . '/woocommerce/yith_magnifier.css' ) ? get_stylesheet_directory_uri() . '/woocommerce/yith_magnifier.css' : YITH_WCMG_URL . 'assets/css/frontend.css';
- wp_enqueue_style( 'ywzm-prettyPhoto', $wc_assets_path . 'css/prettyPhoto.css', array(), YITH_YWZM_SCRIPT_VERSION );
- wp_enqueue_style( 'ywzm-magnifier' );
- wp_enqueue_style( 'ywzm_frontend', $css, array(), YITH_YWZM_SCRIPT_VERSION );
-
- wp_add_inline_style( 'ywzm_frontend', $this->get_custom_css() );
- wp_add_inline_style( 'ywzm-prettyPhoto', $this->get_custom_css_prettyphoto() );
-
- }
- }
-
- public function get_custom_css(){
-
- $custom_css = '';
-
- $slider_colors_default = Array(
- 'background' => 'white',
- 'border' => 'black',
- 'arrow' => 'black',
- );
-
- $sizes_default = Array(
- 'dimensions' => array(
- 'slider' => '25',
- 'arrow' => '22',
- 'border' => '2',
- ));
-
- $colors_default = Array(
- 'background' => 'white',
- 'icon' => 'black',
- );
-
- $slider_colors_array = get_option( 'yith_wcmg_slider_style_colors', $slider_colors_default );
- $slider_colors_hover_array = get_option( 'yith_wcmg_slider_style_colors_hover', $slider_colors_default );
- $sizes = get_option( 'yith_wcmg_slider_sizes', $sizes_default );
-
- if ( is_array($slider_colors_array) ) {
-
- $custom_css .= "
- #slider-prev, #slider-next {
- background-color: {$slider_colors_array['background']};
- border: {$sizes['dimensions']['border']}px solid {$slider_colors_array['border']};
- width:{$sizes['dimensions']['slider']}px !important;
- height:{$sizes['dimensions']['slider']}px !important;
- }
-
- .yith_slider_arrow span{
- width:{$sizes['dimensions']['slider']}px !important;
- height:{$sizes['dimensions']['slider']}px !important;
- }
- ";
-
- $custom_css .= "
- #slider-prev:hover, #slider-next:hover {
- background-color: {$slider_colors_hover_array['background']};
- border: {$sizes['dimensions']['border']}px solid {$slider_colors_hover_array['border']};
- }
- ";
-
- $custom_css .= "
- .thumbnails.slider path:hover {
- fill:{$slider_colors_hover_array['arrow']};
- }
- ";
-
- $custom_css .= "
- .thumbnails.slider path {
- fill:{$slider_colors_array['arrow']};
- width:{$sizes['dimensions']['slider']}px !important;
- height:{$sizes['dimensions']['slider']}px !important;
- }
-
- .thumbnails.slider svg {
- width: {$sizes['dimensions']['arrow']}px;
- height: {$sizes['dimensions']['arrow']}px;
- }
-
- ";
-
- }
-
- //Lighbox expand icon
- $lighbox_colors_array = get_option( 'ywzm_lightbox_icon_colors', $colors_default );
- $lighbox_icon_size = get_option( 'ywzm_lightbox_icon_size', '25' );
- $lighbox_radius = get_option( 'yith_wcmg_lightbox_radius', '0' );
- $lighbox_icon_position = get_option( 'ywzm_lightbox_icon_position', 'top-right' );
-
-
-
- $arr = explode("-", $lighbox_icon_position, 2);
- $position = $arr[0];
-
- if ( $position == 'top' ){
- $top = '10px';
- $bottom = 'initial';
- }
- else{
- $top = 'initial';
- $bottom = '10px';
- }
-
- if ( $lighbox_icon_position === 'top-right' || $lighbox_icon_position === 'bottom-right' ){
- $left = 'initial';
- $right = '10px';
- }
- else{
- $left = '10px';
- $right = 'initial';
- }
-
- $custom_css .= "
- a.yith_expand {
- position: absolute;
- z-index: 1000;
- background-color: {$lighbox_colors_array['background']};
- width: {$lighbox_icon_size}px;
- height: {$lighbox_icon_size}px;
- top: {$top};
- bottom: {$bottom};
- left: {$left};
- right: {$right};
- border-radius: {$lighbox_radius}%;
- }
-
- .expand-button-hidden svg{
- width: {$lighbox_icon_size}px;
- height: {$lighbox_icon_size}px;
- }
-
- .expand-button-hidden path{
- fill: {$lighbox_colors_array['icon']};
- }
- ";
-
-
-
- return apply_filters( 'yith_ywzm_custom_css', $custom_css );
- }
-
- public function get_custom_css_prettyphoto (){
-
- $colors_default = Array(
- 'background' => 'white',
- 'icon' => 'black',
- );
-
- $lighbox_colors_array = get_option( 'ywzm_lightbox_icon_colors', $colors_default );
- $lighbox_icon_size = get_option( 'ywzm_lightbox_icon_size', '25' );
-
- $custom_css = '';
-
- $custom_css .= "
- div.pp_woocommerce a.pp_contract, div.pp_woocommerce a.pp_expand{
- content: unset !important;
- background-color: {$lighbox_colors_array['background']};
- width: {$lighbox_icon_size}px;
- height: {$lighbox_icon_size}px;
- margin-top: 5px;
- margin-left: 5px;
- }
-
- div.pp_woocommerce a.pp_contract, div.pp_woocommerce a.pp_expand:hover{
- background-color: {$lighbox_colors_array['background']};
- }
- div.pp_woocommerce a.pp_contract, div.pp_woocommerce a.pp_contract:hover{
- background-color: {$lighbox_colors_array['background']};
- }
-
- a.pp_expand:before, a.pp_contract:before{
- content: unset !important;
- }
-
- a.pp_expand .expand-button-hidden svg, a.pp_contract .expand-button-hidden svg{
- width: {$lighbox_icon_size}px;
- height: {$lighbox_icon_size}px;
- padding: 5px;
- }
-
- .expand-button-hidden path{
- fill: {$lighbox_colors_array['icon']};
- }
-
- ";
-
-
- return apply_filters( 'yith_ywzm_custom_css_prettyphoto', $custom_css );
- }
-
-
- /**
- * Add attributes to product variations
- *
- * @param array $data Data.
- * @param WC_Product_Variable $wc_prod Variable product.
- * @param WC_Product_Variation $variation Variation.
- *
- * @return mixed
- */
- public function available_variation( $data, $wc_prod, $variation ) {
-
- $attachment_id = get_post_thumbnail_id( $variation->get_id() );
- $attachment = wp_get_attachment_image_src( $attachment_id, 'shop_magnifier' );
-
- $data['image_magnifier'] = $attachment ? current( $attachment ) : '';
-
- return $data;
- }
- }
-}
+<?php // phpcs:ignore WordPress.Files.FileName
+/**
+ * Frontend class
+ *
+ * @author YITH <plugins@yithemes.com>
+ * @package YITHZoomMagnifierClasses
+ * @version 1.1.2
+ */
+
+if ( ! defined( 'YITH_WCMG' ) ) {
+ exit;
+} // Exit if accessed directly
+
+if ( ! class_exists( 'YITH_WCMG_Frontend' ) ) {
+ /**
+ * Admin class.
+ * The class manage all the Frontend behaviors.
+ *
+ * @since 1.0.0
+ */
+ class YITH_WCMG_Frontend {
+
+
+ /**
+ * Constructor
+ *
+ * @access public
+ * @since 1.0.0
+ */
+ public function __construct() {
+
+ // add the action only when the loop is initializate.
+ add_action( 'template_redirect', array( $this, 'render' ) );
+ }
+
+ /**
+ * Render zoom.
+ */
+ public function render() {
+ if ( ! apply_filters( 'yith_wczm_featured_video_enabled', false ) ) {
+
+
+ //Zoom template
+ remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
+ add_action( 'woocommerce_before_single_product_summary', array( $this, 'show_product_images' ), 20 );
+
+ //Slider template
+ remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
+
+ if ( get_option( 'ywzm_hide_thumbnails', 'no' ) !== 'yes' )
+ add_action( 'woocommerce_product_thumbnails', array( $this, 'show_product_thumbnails' ), 20 );
+
+
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
+
+ // add attributes to product variations.
+ add_filter( 'woocommerce_available_variation', array( $this, 'available_variation' ), 10, 3 );
+ }
+ }
+
+
+ /**
+ * Change product-single.php template
+ *
+ * @access public
+ * @return void
+ * @since 1.0.0
+ */
+ public function show_product_images() {
+ wc_get_template( 'single-product/product-image-magnifier.php', array(), '', YITH_YWZM_DIR . 'templates/' );
+ }
+
+
+ /**
+ * Change product-thumbnails.php template
+ *
+ * @access public
+ * @return void
+ * @since 1.0.0
+ */
+ public function show_product_thumbnails() {
+
+ wc_get_template( 'single-product/product-thumbnails-magnifier.php', array(), '', YITH_YWZM_DIR . 'templates/' );
+ }
+
+
+ /**
+ * Enqueue styles and scripts
+ *
+ * @access public
+ * @return void
+ * @since 1.0.0
+ */
+ public function enqueue_styles_scripts() {
+ global $post;
+
+ if ( is_product() || ( ! empty( $post->post_content ) && strpos($post->post_content, 'product_page') !== false ) ) {
+
+ wp_register_script(
+ 'ywzm-magnifier',
+ apply_filters( 'ywzm_magnifier_script_register_path', YITH_WCMG_URL . 'assets/js/' . yit_load_js_file( 'yith_magnifier.js' ) ),
+ array( 'jquery' ),
+ YITH_YWZM_SCRIPT_VERSION,
+ true
+ );
+
+ /**
+ * Avoid the stopImmediatePropagation on gallery click if the Featured Audio and Video plugin is enabled
+ */
+ $stop_immediate_propagation = function_exists( 'YITH_Featured_Audio_Video_Premium_Init') ? false : true;
+
+ wp_localize_script(
+ 'ywzm-magnifier',
+ 'yith_wc_zoom_magnifier_storage_object',
+ apply_filters(
+ 'yith_wc_zoom_magnifier_front_magnifier_localize',
+ array(
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
+ 'mouse_trap_width' => apply_filters( 'yith_wczm_mouse_trap_with', '100%' ),
+ 'mouse_trap_height' => apply_filters( 'yith_wczm_mouse_trap_height', '100%' ),
+ 'stop_immediate_propagation' => $stop_immediate_propagation,
+ )
+ )
+ );
+
+ wp_register_script(
+ 'ywzm_frontend',
+ YITH_WCMG_URL . 'assets/js/' . yit_load_js_file( 'ywzm_frontend.js' ),
+ array(
+ 'jquery',
+ 'ywzm-magnifier',
+ ),
+ YITH_YWZM_SCRIPT_VERSION,
+ true
+ );
+
+ wp_register_style( 'ywzm-magnifier', YITH_WCMG_URL . 'assets/css/yith_magnifier.css', array(), YITH_YWZM_SCRIPT_VERSION );
+
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
+
+ $slider_colors_default = Array(
+ 'background' => 'white',
+ 'border' => 'black',
+ 'arrow' => 'black',
+ );
+
+ $slider_colors_array = get_option( 'yith_wcmg_slider_style_colors', $slider_colors_default );
+ $slider_colors_hover_array = get_option( 'yith_wcmg_slider_style_colors_hover', $slider_colors_default );
+
+ wp_localize_script(
+ 'ywzm_frontend',
+ 'ywzm_data',
+ array(
+ 'slider_colors_array' => $slider_colors_array,
+ 'slider_colors_hover_array' => $slider_colors_hover_array,
+ )
+ );
+
+ // Enqueue PrettyPhoto style and script.
+ $wc_assets_path = str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/';
+
+ // Enqueue scripts.
+ wp_enqueue_script( 'wc-prettyPhoto', $wc_assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), WC()->version, true );
+ wp_enqueue_script( 'ywzm-magnifier' );
+ wp_enqueue_script( 'ywzm_frontend' );
+
+ /**
+ * Add custom init PrettyPhoto
+ */
+
+ wp_localize_script(
+ 'ywzm_frontend',
+ 'ywzm_prettyphoto_data',
+ array(
+ )
+ );
+
+ wp_enqueue_script( //phpcs:ignore
+ 'yith-ywzm-prettyPhoto-init',
+ apply_filters( 'ywzm_src_prettyphoto_script', YITH_WCMG_URL . 'assets/js/init.prettyPhoto.js' ),
+ array(
+ 'jquery',
+ 'wc-prettyPhoto',
+ ),
+ false,
+ true
+ );
+
+ // Enqueue Style.
+ $css = file_exists( get_stylesheet_directory() . '/woocommerce/yith_magnifier.css' ) ? get_stylesheet_directory_uri() . '/woocommerce/yith_magnifier.css' : YITH_WCMG_URL . 'assets/css/frontend.css';
+ wp_enqueue_style( 'ywzm-prettyPhoto', $wc_assets_path . 'css/prettyPhoto.css', array(), YITH_YWZM_SCRIPT_VERSION );
+ wp_enqueue_style( 'ywzm-magnifier' );
+ wp_enqueue_style( 'ywzm_frontend', $css, array(), YITH_YWZM_SCRIPT_VERSION );
+
+ wp_add_inline_style( 'ywzm_frontend', $this->get_custom_css() );
+ wp_add_inline_style( 'ywzm-prettyPhoto', $this->get_custom_css_prettyphoto() );
+
+ }
+ }
+
+ public function get_custom_css(){
+
+ $custom_css = '';
+
+ $slider_colors_default = Array(
+ 'background' => 'white',
+ 'border' => 'black',
+ 'arrow' => 'black',
+ );
+
+ $sizes_default = Array(
+ 'dimensions' => array(
+ 'slider' => '25',
+ 'arrow' => '22',
+ 'border' => '2',
+ ));
+
+ $colors_default = Array(
+ 'background' => 'white',
+ 'icon' => 'black',
+ );
+
+ $slider_colors_array = get_option( 'yith_wcmg_slider_style_colors', $slider_colors_default );
+ $slider_colors_hover_array = get_option( 'yith_wcmg_slider_style_colors_hover', $slider_colors_default );
+ $sizes = get_option( 'yith_wcmg_slider_sizes', $sizes_default );
+
+ if ( is_array($slider_colors_array) ) {
+
+ $custom_css .= "
+ #slider-prev, #slider-next {
+ background-color: {$slider_colors_array['background']};
+ border: {$sizes['dimensions']['border']}px solid {$slider_colors_array['border']};
+ width:{$sizes['dimensions']['slider']}px !important;
+ height:{$sizes['dimensions']['slider']}px !important;
+ }
+
+ .yith_slider_arrow span{
+ width:{$sizes['dimensions']['slider']}px !important;
+ height:{$sizes['dimensions']['slider']}px !important;
+ }
+ ";
+
+ $custom_css .= "
+ #slider-prev:hover, #slider-next:hover {
+ background-color: {$slider_colors_hover_array['background']};
+ border: {$sizes['dimensions']['border']}px solid {$slider_colors_hover_array['border']};
+ }
+ ";
+
+ $custom_css .= "
+ .thumbnails.slider path:hover {
+ fill:{$slider_colors_hover_array['arrow']};
+ }
+ ";
+
+ $custom_css .= "
+ .thumbnails.slider path {
+ fill:{$slider_colors_array['arrow']};
+ width:{$sizes['dimensions']['slider']}px !important;
+ height:{$sizes['dimensions']['slider']}px !important;
+ }
+
+ .thumbnails.slider svg {
+ width: {$sizes['dimensions']['arrow']}px;
+ height: {$sizes['dimensions']['arrow']}px;
+ }
+
+ ";
+
+ }
+
+ //Lighbox expand icon
+ $lighbox_colors_array = get_option( 'ywzm_lightbox_icon_colors', $colors_default );
+ $lighbox_icon_size = get_option( 'ywzm_lightbox_icon_size', '25' );
+ $lighbox_radius = get_option( 'yith_wcmg_lightbox_radius', '0' );
+ $lighbox_icon_position = get_option( 'ywzm_lightbox_icon_position', 'top-right' );
+
+
+
+ $arr = explode("-", $lighbox_icon_position, 2);
+ $position = $arr[0];
+
+ if ( $position == 'top' ){
+ $top = '10px';
+ $bottom = 'initial';
+ }
+ else{
+ $top = 'initial';
+ $bottom = '10px';
+ }
+
+ if ( $lighbox_icon_position === 'top-right' || $lighbox_icon_position === 'bottom-right' ){
+ $left = 'initial';
+ $right = '10px';
+ }
+ else{
+ $left = '10px';
+ $right = 'initial';
+ }
+
+ $custom_css .= "
+ a.yith_expand {
+ position: absolute;
+ z-index: 1000;
+ background-color: {$lighbox_colors_array['background']};
+ width: {$lighbox_icon_size}px;
+ height: {$lighbox_icon_size}px;
+ top: {$top};
+ bottom: {$bottom};
+ left: {$left};
+ right: {$right};
+ border-radius: {$lighbox_radius}%;
+ }
+
+ .expand-button-hidden svg{
+ width: {$lighbox_icon_size}px;
+ height: {$lighbox_icon_size}px;
+ }
+
+ .expand-button-hidden path{
+ fill: {$lighbox_colors_array['icon']};
+ }
+ ";
+
+
+
+ return apply_filters( 'yith_ywzm_custom_css', $custom_css );
+ }
+
+ public function get_custom_css_prettyphoto (){
+
+ $colors_default = Array(
+ 'background' => 'white',
+ 'icon' => 'black',
+ );
+
+ $lighbox_colors_array = get_option( 'ywzm_lightbox_icon_colors', $colors_default );
+ $lighbox_icon_size = get_option( 'ywzm_lightbox_icon_size', '25' );
+
+ $custom_css = '';
+
+ $custom_css .= "
+ div.pp_woocommerce a.pp_contract, div.pp_woocommerce a.pp_expand{
+ content: unset !important;
+ background-color: {$lighbox_colors_array['background']};
+ width: {$lighbox_icon_size}px;
+ height: {$lighbox_icon_size}px;
+ margin-top: 5px;
+ margin-left: 5px;
+ }
+
+ div.pp_woocommerce a.pp_contract, div.pp_woocommerce a.pp_expand:hover{
+ background-color: {$lighbox_colors_array['background']};
+ }
+ div.pp_woocommerce a.pp_contract, div.pp_woocommerce a.pp_contract:hover{
+ background-color: {$lighbox_colors_array['background']};
+ }
+
+ a.pp_expand:before, a.pp_contract:before{
+ content: unset !important;
+ }
+
+ a.pp_expand .expand-button-hidden svg, a.pp_contract .expand-button-hidden svg{
+ width: {$lighbox_icon_size}px;
+ height: {$lighbox_icon_size}px;
+ padding: 5px;
+ }
+
+ .expand-button-hidden path{
+ fill: {$lighbox_colors_array['icon']};
+ }
+
+ ";
+
+
+ return apply_filters( 'yith_ywzm_custom_css_prettyphoto', $custom_css );
+ }
+
+
+ /**
+ * Add attributes to product variations
+ *
+ * @param array $data Data.
+ * @param WC_Product_Variable $wc_prod Variable product.
+ * @param WC_Product_Variation $variation Variation.
+ *
+ * @return mixed
+ */
+ public function available_variation( $data, $wc_prod, $variation ) {
+
+ $attachment_id = get_post_thumbnail_id( $variation->get_id() );
+ $attachment = wp_get_attachment_image_src( $attachment_id, 'shop_magnifier' );
+
+ $data['image_magnifier'] = $attachment ? current( $attachment ) : '';
+
+ return $data;
+ }
+ }
+}
--- a/yith-woocommerce-zoom-magnifier/lib/class.yith-woocommerce-zoom-magnifier.php
+++ b/yith-woocommerce-zoom-magnifier/lib/class.yith-woocommerce-zoom-magnifier.php
@@ -1,176 +1,177 @@
-<?php // phpcs:ignore WordPress.Files.FileName
-/**
- * Main class
- *
- * @author YITH <plugins@yithemes.com>
- * @package YITHZoomMagnifierClasses
- * @version 1.1.2
- */
-
-if ( ! defined( 'YITH_WCMG' ) ) {
- exit;
-} // Exit if accessed directly
-
-if ( ! class_exists( 'YITH_WooCommerce_Zoom_Magnifier' ) ) {
- /**
- * YITH WooCommerce Product Gallery & Image Zoom
- *
- * @since 1.0.0
- */
- class YITH_WooCommerce_Zoom_Magnifier {
-
- /**
- * Plugin object
- *
- * @var string
- * @since 1.0.0
- */
- public $obj = null;
-
- /**
- * Plugin panel page
- *
- * @var string
- */
- protected $panel_page = 'yith_woocommerce_zoom-magnifier_panel';
-
- /**
- * Constructor
- *
- * @return mixed|YITH_WCMG_Admin|YITH_WCMG_Frontend
- * @since 1.0.0
- */
- public function __construct() {
-
- add_action(
- 'wp_ajax_nopriv_yith_wc_zoom_magnifier_get_main_image',
- array(
- $this,
- 'yith_wc_zoom_magnifier_get_main_image_call_back',
- ),
- 10
- );
-
- add_action(
- 'wp_ajax_yith_wc_zoom_magnifier_get_main_image',
- array(
- $this,
- 'yith_wc_zoom_magnifier_get_main_image_call_back',
- ),
- 10
- );
-
- // actions.
- add_action( 'init', array( $this, 'init' ) );
-
- if ( is_admin() && ( ! isset( $_REQUEST['action'] ) || ( isset( $_REQUEST['action'] ) && 'yith_load_product_quick_view' !== $_REQUEST['action'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $this->obj = new YITH_WCMG_Admin();
- } else {
-
-
- /** Stop the plugin on mobile devices */
- if ( ( 'yes' == get_option( 'ywzm_hide_zoom_mobile' ) ) && wp_is_mobile() ) {
- return;
- }
-
- $this->obj = new YITH_WCMG_Frontend();
- }
-
- return $this->obj;
-
- }
-
- /**
- * Init method:
- * - default options
- *
- * @access public
- * @since 1.0.0
- */
- public function init() {
-
- /* === Show Plugin Information === */
- add_filter( 'plugin_action_links_' . plugin_basename( YITH_YWZM_DIR . '/' . basename( YITH_YWZM_FILE ) ), array( $this, 'action_links' ) );
- add_filter( 'yith_show_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 5 );
- }
-
- /**
- * Action links.
- *
- * @param array $links Action links.
- * @since 1.4.1
- *
- * @return array
- */
- public function action_links( $links ) {
- $links = yith_add_action_links( $links, $this->panel_page, false, YITH_YWZM_SLUG );
- return $links;
- }
- /**
- * Plugin Row Meta.
- *
- * @param mixed $new_row_meta_args Row meta args.
- * @param mixed $plugin_meta Plugin meta.
- * @param mixed $plugin_file Plugin file.
- * @param mixed $plugin_data Plugin data.
- * @param mixed $status Status.
- * @param mixed $init_file Init file.
- *
- * @since 1.4.1
- *
- * @return array
- */
- public function plugin_row_meta( $new_row_meta_args, $plugin_meta, $plugin_file, $plugin_data, $status, $init_file = 'YITH_YWZM_FREE_INIT' ) {
- if ( defined( $init_file ) && constant( $init_file ) === $plugin_file ) {
- $new_row_meta_args['slug'] = YITH_YWZM_SLUG;
- }
-
- return $new_row_meta_args;
- }
-
- /**
- * Ajax method to retrieve the product main imavge
- *
- * @access public
- * @since 1.3.4
- */
- public function yith_wc_zoom_magnifier_get_main_image_call_back() {
-
- // set the main wp query for the product.
- global $post, $product;
-
- $product_id = isset( $_POST['product_id'] ) ? $_POST['product_id'] : 0; // phpcs:ignore
- $post = get_post( $product_id ); // phpcs:ignore
- $product = wc_get_product( $product_id );
-
- if ( empty( $product ) ) {
- wp_send_json_error();
- }
-
- $url = wp_get_attachment_image_src( get_post_thumbnail_id( $product_id ), 'full' );
-
- if ( function_exists( 'YITH_WCCL_Frontend' ) && function_exists( 'yith_wccl_get_variation_gallery' ) ) {
-
- $gallery = yith_wccl_get_variation_gallery( $product );
- // filter gallery based on current variation.
- if ( ! empty( $gallery ) ) {
-
- add_filter( 'woocommerce_product_variation_get_gallery_image_ids', array( YITH_WCCL_Frontend(), 'filter_gallery_ids' ), 10, 2 );
- }
- }
-
- ob_start();
- wc_get_template( 'single-product/product-thumbnails-magnifier.php', array(), '', YITH_YWZM_DIR . 'templates/' );
- $gallery_html = ob_get_clean();
-
- wp_send_json(
- array(
- 'url' => isset( $url[0] ) ? $url[0] : '',
- 'gallery' => $gallery_html,
- )
- );
-
- }
-
- }
-}
+<?php // phpcs:ignore WordPress.Files.FileName
+/**
+ * Main class
+ *
+ * @author YITH <plugins@yithemes.com>
+ * @package YITHZoomMagnifierClasses
+ * @version 1.1.2
+ */
+
+if ( ! defined( 'YITH_WCMG' ) ) {
+ exit;
+} // Exit if accessed directly
+
+if ( ! class_exists( 'YITH_WooCommerce_Zoom_Magnifier' ) ) {
+ /**
+ * YITH WooCommerce Product Gallery & Image Zoom
+ *
+ * @since 1.0.0
+ */
+ class YITH_WooCommerce_Zoom_Magnifier {
+
+ /**
+ * Plugin object
+ *
+ * @var string
+ * @since 1.0.0
+ */
+ public $obj = null;
+
+ /**
+ * Plugin panel page
+ *
+ * @var string
+ */
+ protected $panel_page = 'yith_woocommerce_zoom-magnifier_panel';
+
+ /**
+ * Constructor
+ *
+ * @return mixed|YITH_WCMG_Admin|YITH_WCMG_Frontend
+ * @since 1.0.0
+ */
+ public function __construct() {
+
+ add_action(
+ 'wp_ajax_nopriv_yith_wc_zoom_magnifier_get_main_image',
+ array(
+ $this,
+ 'yith_wc_zoom_magnifier_get_main_image_call_back',
+ ),
+ 10
+ );
+
+ add_action(
+ 'wp_ajax_yith_wc_zoom_magnifier_get_main_image',
+ array(
+ $this,
+ 'yith_wc_zoom_magnifier_get_main_image_call_back',
+ ),
+ 10
+ );
+
+ // actions.
+ add_action( 'init', array( $this, 'init' ) );
+
+ if ( is_admin() && ( ! isset( $_REQUEST['action'] ) || ( isset( $_REQUEST['action'] ) && 'yith_load_product_quick_view' !== $_REQUEST['action'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $this->obj = new YITH_WCMG_Admin();
+ } else {
+
+
+ /** Stop the plugin on mobile devices */
+ if ( ( 'yes' == get_option( 'ywzm_hide_zoom_mobile' ) ) && wp_is_mobile() ) {
+ return;
+ }
+
+ $this->obj = new YITH_WCMG_Frontend();
+ }
+
+ return $this->obj;
+
+ }
+
+ /**
+ * Init method:
+ * - default options
+ *
+ * @access public
+ * @since 1.0.0
+ */
+ public function init() {
+
+ /* === Show Plugin Information === */
+ add_filter( 'plugin_action_links_' . plugin_basename( YITH_YWZM_DIR . '/' . basename( YITH_YWZM_FILE ) ), array( $this, 'action_links' ) );
+ add_filter( 'yith_show_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 5 );
+ }
+
+ /**
+ * Action links.
+ *
+ * @param array $links Action links.
+ * @since 1.4.1
+ *
+ * @return array
+ */
+ public function action_links( $links ) {
+ $links = yith_add_action_links( $links, $this->panel_page, false, YITH_YWZM_SLUG );
+ return $links;
+ }
+ /**
+ * Plugin Row Meta.
+ *
+ * @param mixed $new_row_meta_args Row meta args.
+ * @param mixed $plugin_meta Plugin meta.
+ * @param mixed $plugin_file Plugin file.
+ * @param mixed $plugin_data Plugin data.
+ * @param mixed $status Status.
+ * @param mixed $init_file Init file.
+ *
+ * @since 1.4.1
+ *
+ * @return array
+ */
+ public function plugin_row_meta( $new_row_meta_args, $plugin_meta, $plugin_file, $plugin_data, $status, $init_file = 'YITH_YWZM_FREE_INIT' ) {
+ if ( defined( $init_file ) && constant( $init_file ) === $plugin_file ) {
+ $new_row_meta_args['slug'] = YITH_YWZM_SLUG;
+ }
+
+ return $new_row_meta_args;
+ }
+
+ /**
+ * Ajax method to retrieve the product main imavge
+ *
+ * @access public
+ * @since 1.3.4
+ */
+ public function yith_wc_zoom_magnifier_get_main_image_call_back() {
+
+ // set the main wp query for the product.
+ global $post, $product;
+
+ $product_id = isset( $_POST['product_id'] ) ? $_POST['product_id'] : 0; // phpcs:ignore
+ $post = get_post( $product_id ); // phpcs:ignore
+ $product = wc_get_product( $product_id );
+ $is_public = ( 'publish' === $post->post_status && false === post_password_required( $post ) );
+
+ if ( empty( $product ) || ! $is_public ) {
+ wp_send_json_error();
+ }
+
+ $url = wp_get_attachment_image_src( get_post_thumbnail_id( $product_id ), 'full' );
+
+ if ( function_exists( 'YITH_WCCL_Frontend' ) && function_exists( 'yith_wccl_get_variation_gallery' ) ) {
+
+ $gallery = yith_wccl_get_variation_gallery( $product );
+ // filter gallery based on current variation.
+ if ( ! empty( $gallery ) ) {
+
+ add_filter( 'woocommerce_product_variation_get_gallery_image_ids', array( YITH_WCCL_Frontend(), 'filter_gallery_ids' ), 10, 2 );
+ }
+ }
+
+ ob_start();
+ wc_get_template( 'single-product/product-thumbnails-magnifier.php', array(), '', YITH_YWZM_DIR . 'templates/' );
+ $gallery_html = ob_get_clean();
+
+ wp_send_json(
+ array(
+ 'url' => isset( $url[0] ) ? $url[0] : '',
+ 'gallery' => $gallery_html,
+ )
+ );
+
+ }
+
+ }
+}
--- a/yith-woocommerce-zoom-magnifier/lib/class.yith-ywzm-plugin-fw-loader.php
+++ b/yith-woocommerce-zoom-magnifier/lib/class.yith-ywzm-plugin-fw-loader.php
@@ -1,253 +1,253 @@
-<?php // phpcs:ignore WordPress.Files.FileName
-/**
- * Plugin FW Loader class
- *
- * @author YITH <plugins@yithemes.com>
- * @package YITHZoomMagnifierClasses
- */
-
-if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly.
-}
-
-if ( ! class_exists( 'YITH_YWZM_Plugin_FW_Loader' ) ) {
-
- /**
- * Implements features related to an invoice document
- */
- class YITH_YWZM_Plugin_FW_Loader {
-
- /**
- * Panel Object
- *
- * @var $panel
- */
- protected $panel;
-
- /**
- * Premium tab template file name
- *
- * @var $_premium
- */
- protected $_premium = 'premium.php';
-
- /**
- * Premium version landing link
- *
- * @var string
- */
- protected $_premium_landing = 'https://yithemes.com/themes/plugins/yith-woocommerce-zoom-magnifier/';
-
- /**
- * Plugin official documentation
- *
- * @var string
- */
- protected $official_documentation = 'https://docs.yithemes.com/yith-woocommerce-zoom-magnifier/';
-
- /**
- * Plugin panel page
- *
- * @var string
- */
- protected $panel_page = 'yith_woocommerce_zoom-magnifier_panel';
-
- /**
- * Single instance of the class
- *
- * @var YITH_YWZM_Plugin_FW_Loader
- * @since 1.0.0
- */
- protected static $instance;
-
- /**
- * Returns single instance of the class
- *
- * @since 1.0.0
- */
- public static function get_instance() {
- if ( is_null( self::$instance ) ) {
- self::$instance = new self();
- }
-
- return self::$instance;
- }
-
- /**
- * Constructor
- */
- public function __construct() {
- /**
- * Register actions and filters to be used for creating an entry on YIT Plugin menu
- */
- add_action( 'admin_init', array( $this, 'register_pointer' ) );
-
- // Add stylesheets and scripts files.
- add_action( 'admin_menu', array( $this, 'register_panel' ), 5 );
-
- if ( ! defined( 'YITH_YWZM_PREMIUM' ) ) {
-
- // Show plugin premium tab.
- add_action( 'yith_zoom_magnifier_premium', array( $this, 'premium_tab' ) );
- } else {
- /**
- * Register plugin to licence/update system.
- */
- $this->licence_activation();
- }
-
- add_action( 'before_woocommerce_init', array( $this, 'declare_wc_features_support' ) );
- }
-
- /**
- * Add a panel under YITH Plugins tab
- *
- * @return void
- * @since 1.0
- * @use /Yit_Plugin_Panel class
- * @see plugin-fw/lib/yit-plugin-panel.php
- */
- public function register_panel() {
-
- if ( ! empty( $this->panel ) ) {
- return;
- }
-
- $admin_tabs['image'] = esc_html__( 'Main image options', 'yith-woocommerce-zoom-magnifier' );
- $admin_tabs['gallery'] = esc_html__( 'Product gallery options', 'yith-woocommerce-zoom-magnifier' );
- $admin_tabs['premium'] = esc_html__( 'Premium Version', 'yith-woocommerce-zoom-magnifier' );
-
- $args = array(
- 'create_menu_page' => true,
- 'parent_slug' => '',
- 'page_title' => 'YITH WooCommerce Product Gallery & Image Zoom',
- 'menu_title' => 'Product Gallery & Image Zoom',
- 'capability' => 'manage_options',
- 'parent' => '',
- 'parent_page' => 'yit_plugin_panel',
- 'page' => $this->panel_page,
- 'admin-tabs' => $admin_tabs,
- 'class' => yith_set_wrapper_class(),
- 'options-path' => YITH_YWZM_DIR . '/plugin-options',
- 'plugin_slug' => YITH_YWZM_SLUG,
- 'is_free' => defined( 'YITH_YWZM_FREE' ),
- );
-
- /* === Fixed: not updated theme === */
- if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
-
- require_once 'plugin-fw/lib/yit-plugin-panel-wc.php';
- }
-
- $this->panel = new YIT_Plugin_Panel_WooCommerce( $args );
-
- }
-
- /**
- * Premium Tab Template
- *
- * Load the premium tab template on admin page
- *
- * @since 1.0
- * @return void
- */
- public function premium_tab() {
- $premium_tab_template = YITH_YWZM_TEMPLATE_DIR . '/admin/' . $this->_premium;
- if ( file_exists( $premium_tab_template ) ) {
- include_once( $premium_tab_template );
- }
- }
-
- /**
- * Register pointer.
- */
- public function register_pointer() {
- if ( ! class_exists( 'YIT_Pointers' ) ) {
- include_once 'plugin-fw/lib/yit-pointers.php';
- }
-
- $premium_message = defined( 'YITH_YWZM_PREMIUM' )
- ? ''
- : esc_html__( 'YITH WooCommerce Product Gallery & Image Zoom is available in an outstanding PREMIUM version with many new options, discover it now.', 'yith-woocommerce-zoom-magnifier' ) .
- ' <a href="' . $this->_premium_landing . '">' . esc_html__( 'Premium version', 'yith-woocommerce-zoom-magnifier' ) . '</a>';
-
- $args[] = array(
- 'screen_id' => 'plugins',
- 'pointer_id' => 'yith_woocommerce_zoom-magnifier',
- 'target' => '#toplevel_page_yit_plugin_panel',
- 'content' => sprintf(
- '<h3> %s </h3> <p> %s </p>',
- esc_html__( 'YITH WooCommerce Product Gallery & Image Zoom ', 'yith-woocommerce-zoom-magnifier' ),
- esc_html__( 'In YIT Plugins tab you can find YITH WooCommerce Product Gallery & Image Zoom options.<br> From this menu you can access all settings of the YITH plugins activated.', 'yith-woocommerce-zoom-magnifier' ) . '<br>' . $premium_message
- ),
- 'position' => array(
- 'edge' => 'left',
- 'align' => 'center',
- ),
- 'init' => defined( 'YITH_YWZM_PREMIUM' ) ? YITH_YWZM_INIT : YITH_YWZM_FREE_INIT,
- );
-
- YIT_Pointers()->register( $args );
- }
-
- /**
- * Get the premium landing uri
- *
- * @since 1.0.0
- * @return string The premium landing link
- */
- public function get_premium_landing_uri() {
- return apply_filters( 'yith_plugin_fw_premium_landing_uri', $this->_premium_landing, YITH_YWZM_SLUG );
- }
-
- // region **** licence related methods ****.
-
- /**
- * Add actions to manage licence activation and updates
- */
- public function licence_activation() {
- if ( ! defined( 'YITH_YWZM_PREMIUM' ) ) {
- return;
- }
-
- add_action( 'wp_loaded', array( $this, 'register_plugin_for_activation' ), 99 );
- add_action( 'admin_init', array( $this, 'register_plugin_for_updates' ) );
- }
-
- /**
- * Register plugins for activation tab
- *
- * @return void
- * @since 2.0.0
- */
- public function register_plugin_for_activation() {
- if ( ! class_exists( 'YIT_Plugin_Licence' ) ) {
- require_once 'plugin-fw/lib/yit-plugin-licence.php';
- }
- YIT_Plugin_Licence()->register( YITH_YWZM_INIT, YITH_YWZM_SECRET_KEY, YITH_YWZM_SLUG );
- }
-
- /**
- * Register plugins for update tab
- *
- * @return void
- * @since 2.0.0
- */
- public function register_plugin_for_updates() {
- if ( ! class_exists( 'YIT_Upgrade' ) ) {
- require_once 'plugin-fw/lib/yit-upgrade.php';
- }
- YIT_Upgrade()->register( YITH_YWZM_SLUG, YITH_YWZM_INIT );
- }
-
- /**
- * Declare support for WooCommerce features.
- */
- public function declare_wc_features_support() {
- if ( class_exists( 'AutomatticWooCommerceUtilitiesFeaturesUtil' ) ) {
- AutomatticWooCommerceUtilitiesFeaturesUtil::declare_compatibility( 'custom_order_tables', YITH_YWZM_FREE_INIT, true );
- }
- }
- // endregion.
- }
-}
+<?php // phpcs:ignore WordPress.Files.FileName
+/**
+ * Plugin FW Loader class
+ *
+ * @author YITH <plugins@yithemes.com>
+ * @package YITHZoomMagnifierClasses
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+if ( ! class_exists( 'YITH_YWZM_Plugin_FW_Loader' ) ) {
+
+ /**
+ * Implements features related to an invoice document
+ */
+ class YITH_YWZM_Plugin_FW_Loader {
+
+ /**
+ * Panel Object
+ *
+ * @var $panel
+ */
+ protected $panel;
+
+ /**
+ * Premium tab template file name
+ *
+ * @var $_premium
+ */
+ protected $_premium = 'premium.php';
+
+ /**
+ * Premium version landing link
+ *
+ * @var string
+ */
+ protected $_premium_landing = 'https://yithemes.com/themes/plugins/yith-woocommerce-zoom-magnifier/';
+
+ /**
+ * Pl