| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class Optml_shortcode_ultimate. |
| 5 |
* |
| 6 |
* @reason We need to turn on the image replacement on quick view ajax response, even if the user is logged in. |
| 7 |
*/ |
| 8 |
class Optml_yith_quick_view extends Optml_compatibility { |
| 9 |
|
| 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 |
* Should we load the integration logic. |
| 34 |
* |
| 35 |
* @return bool Should we load. |
| 36 |
*/ |
| 37 |
function should_load() { |
| 38 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 39 |
|
| 40 |
return ( is_plugin_active( 'yith-woocommerce-quick-view/init.php' ) ); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Register integration details. |
| 45 |
*/ |
| 46 |
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 |
| 54 |
); |
| 55 |
} |
| 56 |
|
| 57 |
} |
| 58 |
|