| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* Astra theme compatibility layer |
| 8 |
*/ |
| 9 |
if ( ! class_exists( 'Merchant_Astra_Theme' ) ) { |
| 10 |
class Merchant_Astra_Theme { |
| 11 |
|
| 12 |
/** |
| 13 |
* Constructor. |
| 14 |
*/ |
| 15 |
public function __construct() { |
| 16 |
add_filter( 'astra_woo_shop_product_structure', array( $this, 'fix_astra_shop_structure' ) ); |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Disable the add to cart button in the shop loop while product swatches module is active. |
| 21 |
* |
| 22 |
* @param $shop_structure |
| 23 |
* |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public function fix_astra_shop_structure( $shop_structure ) { |
| 27 |
if ( ! Merchant_Modules::is_module_active( 'product-swatches' ) ) { |
| 28 |
return $shop_structure; |
| 29 |
} |
| 30 |
if ( is_array( $shop_structure ) && ! empty( $shop_structure ) ) { |
| 31 |
foreach ( $shop_structure as $key => $value ) { |
| 32 |
if ( $value === 'add_cart' ) { |
| 33 |
unset( $shop_structure[ $key ] ); |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
return $shop_structure; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* The class object can be accessed with "global $merchant_astra_compatibility", to allow removing actions. |
| 44 |
* Improving Third-party integrations. |
| 45 |
*/ |
| 46 |
$merchant_astra_compatibility = new Merchant_Astra_Theme(); |
| 47 |
} |
| 48 |
|