| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* OceanWP theme compatibility layer |
| 8 |
*/ |
| 9 |
if ( ! class_exists( 'Merchant_OceanWP_Theme' ) ) { |
| 10 |
class Merchant_OceanWP_Theme { |
| 11 |
|
| 12 |
/** |
| 13 |
* Constructor. |
| 14 |
*/ |
| 15 |
public function __construct() { |
| 16 |
add_action( 'wp_enqueue_scripts', array( $this, 'styles' ) ); |
| 17 |
add_filter('ocean_woo_product_elements_positioning', array( $this, 'fix_oceanwp_shop_structure' ) ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Disable the add to cart button in the shop loop while product swatches module is active. |
| 22 |
* |
| 23 |
* @param $sections |
| 24 |
* |
| 25 |
* @return void |
| 26 |
*/ |
| 27 |
public function fix_oceanwp_shop_structure( $sections ) { |
| 28 |
if( ! Merchant_Modules::is_module_active( 'product-swatches' ) ) { |
| 29 |
return $sections; |
| 30 |
} |
| 31 |
|
| 32 |
if ( is_array( $sections ) && ! empty( $sections ) ) { |
| 33 |
foreach ( $sections as $key => $value ) { |
| 34 |
if ( $value === 'button' ) { |
| 35 |
unset( $sections[ $key ] ); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
return $sections; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Load compatibility styles if the OceanWP theme is installed and active. |
| 45 |
* |
| 46 |
* @return void |
| 47 |
*/ |
| 48 |
public function styles() { |
| 49 |
if ( ! merchant_is_oceanwp_active() ) { |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
wp_enqueue_style( |
| 54 |
'merchant-oceanwp-compatibility', |
| 55 |
MERCHANT_URI . 'assets/css/compatibility/oceanwp/style.min.css', |
| 56 |
array(), |
| 57 |
MERCHANT_VERSION |
| 58 |
); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* The class object can be accessed with "global $oceanWP_compatibility", to allow removing actions. |
| 64 |
* Improving Third-party integrations. |
| 65 |
*/ |
| 66 |
$merchant_oceanWP_compatibility = new Merchant_OceanWP_Theme(); |
| 67 |
} |
| 68 |
|