| @@ -1,44 +1,22 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Class Optml_shortcode_ultimate. | |
| 4 | + * Class Optml_yith_quick_view. | |
| 5 | 5 | * |
| 6 | - * @reason We need to turn on the image replacement on quick view ajax response, even if the user is logged in. | |
| 6 | + * @reason We need to turn on the image replacement on quick view ajax response, to do this we hook the product image filter. | |
| 7 | 7 | */ |
| 8 | 8 | class Optml_yith_quick_view extends Optml_compatibility { |
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | - * Optml_yith_quick_view constructor. | |
| 12 | - */ | |
| 13 | - public function __construct() { | |
| 14 | - add_filter( 'optml_force_replacement_on', [ $this, 'force_replacement' ] ); | |
| 15 | - } | |
| 16 | - | |
| 17 | - /** | |
| 18 | - * Allow image replacement even if we are logged in. | |
| 19 | - * | |
| 20 | - * @param bool $status Old status. | |
| 21 | - * | |
| 22 | - * @return bool Replacement status. | |
| 23 | - */ | |
| 24 | - public function force_replacement( $status ) { | |
| 25 | - if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'yith_load_product_quick_view' ) { | |
| 26 | - return true; | |
| 27 | - } | |
| 28 | - | |
| 29 | - return false; | |
| 30 | - } | |
| 31 | - | |
| 32 | - /** | |
| 33 | 11 | * Should we load the integration logic. |
| 34 | 12 | * |
| 35 | 13 | * @return bool Should we load. |
| 36 | 14 | */ |
| 37 | - function should_load() { | |
| 38 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 15 | + public function should_load() { | |
| 16 | + include_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 39 | 17 | |
| 40 | - return ( is_plugin_active( 'yith-woocommerce-quick-view/init.php' ) ); | |
| 18 | + return is_plugin_active( 'yith-woocommerce-quick-view/init.php' ); | |
| 41 | 19 | } |
| 42 | 20 | |
| 43 | 21 | /** |
| 44 | 22 | * Register integration details. |
| @@ -43,15 +21,22 @@ | ||
| 43 | 21 | /** |
| 44 | 22 | * Register integration details. |
| 45 | 23 | */ |
| 46 | 24 | public function register() { |
| 47 | - add_action( | |
| 48 | - 'wp_ajax_yith_load_product_quick_view', | |
| 49 | - [ | |
| 50 | - Optml_Main::instance()->manager, | |
| 51 | - 'process_template_redirect_content', | |
| 52 | - ], | |
| 53 | - PHP_INT_MIN | |
| 25 | + Optml_Url_Replacer::instance()->init(); | |
| 26 | + add_filter( | |
| 27 | + 'woocommerce_single_product_image_thumbnail_html', | |
| 28 | + function ( $html ) { | |
| 29 | + return Optml_Main::instance()->manager->replace_content( $html, true ); | |
| 30 | + } | |
| 54 | 31 | ); |
| 55 | 32 | } |
| 56 | 33 | |
| 34 | + /** | |
| 35 | + * Should we early load the compatibility? | |
| 36 | + * | |
| 37 | + * @return bool Whether to load the compatibility or not. | |
| 38 | + */ | |
| 39 | + public function should_load_early() { | |
| 40 | + return true; | |
| 41 | + } | |
| 57 | 42 | } |