| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Bricks Builder compatibility layer |
| 9 |
*/ |
| 10 |
if ( ! class_exists( 'Merchant_Bricks_Builder' ) ) { |
| 11 |
class Merchant_Bricks_Builder { |
| 12 |
|
| 13 |
/** |
| 14 |
* Constructor. |
| 15 |
*/ |
| 16 |
public function __construct() { |
| 17 |
|
| 18 |
if ( ( is_admin() && ! wp_doing_ajax() ) || ! merchant_is_bricks_builder_active() ) { |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
add_filter( 'merchant_enqueue_module_scripts', array( $this, 'should_enqueue_scripts' ), 10, 2 ); |
| 23 |
|
| 24 |
// Custom CSS. |
| 25 |
add_filter( 'merchant_custom_css', array( $this, 'frontend_custom_css' ) ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Determines whether to enqueue scripts for modules. |
| 30 |
* |
| 31 |
* @param $enqueue |
| 32 |
* @param $module |
| 33 |
* |
| 34 |
* @return mixed|true |
| 35 |
*/ |
| 36 |
public function should_enqueue_scripts( $enqueue, $module ) { |
| 37 |
$module_id = $module->module_id ?? ''; |
| 38 |
|
| 39 |
if ( $module_id === 'product-swatches' ) { |
| 40 |
return true; |
| 41 |
} |
| 42 |
|
| 43 |
return $enqueue; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Frontend custom CSS. |
| 48 |
* |
| 49 |
* @param string $css The custom CSS. |
| 50 |
* @return string $css The custom CSS. |
| 51 |
*/ |
| 52 |
public function frontend_custom_css( $css ) { |
| 53 |
|
| 54 |
// Wishlist |
| 55 |
if ( Merchant_Modules::is_module_active( Merchant_Wishlist::MODULE_ID ) && Merchant_Admin_Options::get( 'wishlist', 'display_on_cart_page', false ) ) { |
| 56 |
$css .= ' |
| 57 |
.merchant-wishlist-items-cart ul.products li.product { |
| 58 |
display: flex; |
| 59 |
flex-direction: column; |
| 60 |
gap: 10px; |
| 61 |
} |
| 62 |
'; |
| 63 |
} |
| 64 |
|
| 65 |
// Delivery & Pickup |
| 66 |
if ( Merchant_Modules::is_module_active( Merchant_Delivery_Pickup::MODULE_ID ) ) { |
| 67 |
$css .= $this->delivery_pickup_css(); |
| 68 |
} |
| 69 |
|
| 70 |
return $css; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Delivery & Pickup sizes and edges, restated where Bricks' own CSS changes them. |
| 75 |
* |
| 76 |
* `html { font-size: 62.5% }` renders every `rem` at 10px, the checkout table pads |
| 77 |
* cells 20px and separates its product rows only, and the order table makes every |
| 78 |
* cell 50% wide and hides the head. Bricks also dequeues every WooCommerce |
| 79 |
* stylesheet, so the tables share an edge and nothing stacks the summary on a phone, |
| 80 |
* which is why the head shows at every width. Its own CSS sits in `@layer bricks`, |
| 81 |
* but a store can switch that off, so each selector wins on specificity as well. |
| 82 |
* |
| 83 |
* @return string |
| 84 |
*/ |
| 85 |
private function delivery_pickup_css() { |
| 86 |
return ' |
| 87 |
body .merchant-dp-line, |
| 88 |
body .merchant-dp-line-hint, |
| 89 |
body .merchant-dp-section .merchant-dp-shipments { |
| 90 |
font-size: 13px; |
| 91 |
} |
| 92 |
|
| 93 |
body .merchant-dp-line-label { |
| 94 |
font-size: 11px; |
| 95 |
} |
| 96 |
|
| 97 |
body .merchant-dp-section .merchant-dp-shipments-title, |
| 98 |
body .merchant-dp-change-panel > summary, |
| 99 |
body .merchant-dp-part-heading { |
| 100 |
font-size: 16px; |
| 101 |
} |
| 102 |
|
| 103 |
body .merchant-dp-section, |
| 104 |
body .merchant-dp-order-actions { |
| 105 |
--merchant-dp-gap: 8px; |
| 106 |
} |
| 107 |
|
| 108 |
body .merchant-dp-reschedule .merchant-dp-line-label { |
| 109 |
font-size: 12px; |
| 110 |
} |
| 111 |
|
| 112 |
body .merchant-dp-reschedule .merchant-dp-line-select { |
| 113 |
padding: 6px 28px 6px 10px; |
| 114 |
font-size: 15px; |
| 115 |
} |
| 116 |
|
| 117 |
body .merchant-dp-reschedule .merchant-dp-submit { |
| 118 |
padding: 10px 20px; |
| 119 |
font-size: 14px; |
| 120 |
} |
| 121 |
|
| 122 |
body .wp-block-woocommerce-checkout .merchant-dp-line-mount, |
| 123 |
body .wp-block-woocommerce-cart .merchant-dp-line-mount, |
| 124 |
body .wp-block-woocommerce-checkout .merchant-dp-line-hint, |
| 125 |
body .wp-block-woocommerce-cart .merchant-dp-line-hint, |
| 126 |
body .wp-block-woocommerce-checkout .merchant-dp-shipment { |
| 127 |
font-size: 13px; |
| 128 |
} |
| 129 |
|
| 130 |
body .wp-block-woocommerce-checkout .merchant-dp-line-label, |
| 131 |
body .wp-block-woocommerce-cart .merchant-dp-line-label { |
| 132 |
font-size: 11px; |
| 133 |
} |
| 134 |
|
| 135 |
body .woocommerce-checkout-review-order-table .merchant-dp-checkout-row > td { |
| 136 |
padding-inline: 20px; |
| 137 |
border-top: 1px solid var(--bricks-border-color, #dddedf); |
| 138 |
border-bottom: 1px solid var(--bricks-border-color, #dddedf); |
| 139 |
} |
| 140 |
|
| 141 |
body .brxe-woocommerce-checkout-order-table .woocommerce-checkout-review-order-table .merchant-dp-checkout-row > td { |
| 142 |
padding-inline: 0; |
| 143 |
} |
| 144 |
|
| 145 |
body .woocommerce-order-details .merchant-dp-summary { |
| 146 |
margin-top: 30px; |
| 147 |
} |
| 148 |
|
| 149 |
body .woocommerce-order-details .merchant-dp-summary th, |
| 150 |
body .woocommerce-order-details .merchant-dp-summary td { |
| 151 |
width: auto; |
| 152 |
padding: 12px 20px; |
| 153 |
line-height: 1.4; |
| 154 |
} |
| 155 |
|
| 156 |
body .woocommerce-order-details .merchant-dp-summary thead { |
| 157 |
display: table-header-group; |
| 158 |
} |
| 159 |
'; |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
add_action( 'init', function() { |
| 164 |
new Merchant_Bricks_Builder(); |
| 165 |
} ); |
| 166 |
} |
| 167 |
|