| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Main ProductDescription class. |
| 5 |
* |
| 6 |
* @package RadiusTheme\SB |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace RadiusTheme\SB\Controllers\ThemesSupport\Astra; |
| 10 |
|
| 11 |
// Do not allow directly accessing this file. |
| 12 |
use Rtwpvsp\Controllers\ShopPage; |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit( 'This script cannot be accessed directly.' ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Product Description class |
| 20 |
*/ |
| 21 |
class WidgetsSupport { |
| 22 |
|
| 23 |
/** |
| 24 |
* The single instance of the class. |
| 25 |
* |
| 26 |
* @var object |
| 27 |
*/ |
| 28 |
protected static $instance = null; |
| 29 |
|
| 30 |
/** |
| 31 |
* The single instance of the class. |
| 32 |
* |
| 33 |
* @var object |
| 34 |
*/ |
| 35 |
private $widgets; |
| 36 |
|
| 37 |
/** |
| 38 |
* Construct function |
| 39 |
*/ |
| 40 |
private function __construct() {} |
| 41 |
/** |
| 42 |
* Get class instance. |
| 43 |
* |
| 44 |
* @return object Instance. |
| 45 |
*/ |
| 46 |
public static function instance( $widgets ) { |
| 47 |
if ( ! self::$instance ) { |
| 48 |
self::$instance = new self(); |
| 49 |
} |
| 50 |
self::$instance->widgets = $widgets; |
| 51 |
return self::$instance; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Astra Wrapper |
| 56 |
* |
| 57 |
* @return void |
| 58 |
*/ |
| 59 |
public function astra_woo_shop_thumbnail_wrap_start() { |
| 60 |
echo '<div class="astra-shop-thumbnail-wrap rtsb-image-wrapper">'; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Product Loop content Modify. |
| 65 |
* |
| 66 |
* @return void |
| 67 |
*/ |
| 68 |
public function astra_product_loop() { |
| 69 |
if ( ! apply_filters( 'astra_woo_shop_product_structure_override', false ) ) { |
| 70 |
// Remove some hooks. |
| 71 |
remove_action( 'woocommerce_before_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_start', 6 ); |
| 72 |
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 ); |
| 73 |
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 ); |
| 74 |
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); |
| 75 |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); |
| 76 |
|
| 77 |
// Adding some hooks. |
| 78 |
add_action( 'woocommerce_before_shop_loop_item', [ $this, 'astra_woo_shop_thumbnail_wrap_start' ], 6 ); |
| 79 |
add_action( 'woocommerce_after_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_end', 8 ); |
| 80 |
add_action( 'woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content' ); |
| 81 |
add_action( 'astra_woo_shop_before_summary_wrap', [ $this->widgets, 'product_content_wrapper' ], 6 ); |
| 82 |
add_action( 'astra_woo_shop_after_summary_wrap', [ $this->widgets, 'div_close' ], 6 ); |
| 83 |
} |
| 84 |
$this->widgets->apply_hooks_set_default(); |
| 85 |
|
| 86 |
// Variation Swatch fix |
| 87 |
if ( class_exists('WooProductVariationSwatches') ) { |
| 88 |
$swatches_position = rtwpvs()->get_option( 'archive_swatches_position' ); |
| 89 |
if( 'before_title_and_price' == $swatches_position && class_exists( ShopPage::class ) ){ |
| 90 |
remove_action('woocommerce_before_shop_loop_item_title', [ |
| 91 |
ShopPage::class, |
| 92 |
'archive_variation_swatches', |
| 93 |
], 35); |
| 94 |
add_action('astra_woo_shop_title_before', [ |
| 95 |
ShopPage::class, |
| 96 |
'archive_variation_swatches', |
| 97 |
], 35); |
| 98 |
} |
| 99 |
|
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
// Remove Action Button. |
| 104 |
add_filter( 'rtsb/module/wishlist/show_button', '__return_false' ); |
| 105 |
add_filter( 'rtsb/module/quick_view/show_button', '__return_false' ); |
| 106 |
add_filter( 'rtsb/module/compare/show_button', '__return_false' ); |
| 107 |
|
| 108 |
} |
| 109 |
/** |
| 110 |
* Product Content Reset. |
| 111 |
* |
| 112 |
* @return void |
| 113 |
*/ |
| 114 |
public function astra_product_loop_reset_default() { |
| 115 |
if ( ! apply_filters( 'astra_woo_shop_product_structure_override', false ) ) { |
| 116 |
// Remove Product Content Wrapper. |
| 117 |
remove_action( 'astra_woo_shop_before_summary_wrap', [ $this->widgets, 'product_content_wrapper' ], 6 ); |
| 118 |
remove_action( 'astra_woo_shop_after_summary_wrap', [ $this->widgets, 'div_close' ], 6 ); |
| 119 |
} |
| 120 |
} |
| 121 |
/** |
| 122 |
* The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with render. |
| 123 |
* |
| 124 |
* @return void |
| 125 |
*/ |
| 126 |
public function render_rtsb_products_archive() { |
| 127 |
$this->astra_product_loop(); |
| 128 |
} |
| 129 |
/** |
| 130 |
* . |
| 131 |
* |
| 132 |
* @return void |
| 133 |
*/ |
| 134 |
public function render_reset_rtsb_products_archive() { |
| 135 |
$this->astra_product_loop_reset_default(); |
| 136 |
} |
| 137 |
/** |
| 138 |
* The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with render. |
| 139 |
* |
| 140 |
* @return void |
| 141 |
*/ |
| 142 |
public function render_rtsb_upsells_product() { |
| 143 |
$this->astra_product_loop(); |
| 144 |
} |
| 145 |
/** |
| 146 |
* Reset Hooks. |
| 147 |
* |
| 148 |
* @return void |
| 149 |
*/ |
| 150 |
public function render_reset_rtsb_upsells_product() { |
| 151 |
$this->astra_product_loop_reset_default(); |
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* Related Product. |
| 156 |
* |
| 157 |
* @return void |
| 158 |
*/ |
| 159 |
public function render_rtsb_related_product() { |
| 160 |
$this->astra_product_loop(); |
| 161 |
} |
| 162 |
/** |
| 163 |
* Related Product. |
| 164 |
* |
| 165 |
* @return void |
| 166 |
*/ |
| 167 |
public function render_reset_rtsb_related_product() { |
| 168 |
$this->astra_product_loop_reset_default(); |
| 169 |
} |
| 170 |
/** |
| 171 |
* Cross Sell Product. |
| 172 |
* |
| 173 |
* @return void |
| 174 |
*/ |
| 175 |
public function render_rtsb_cross_sells() { |
| 176 |
$this->astra_product_loop(); |
| 177 |
} |
| 178 |
/** |
| 179 |
* Cross Sell Product. |
| 180 |
* |
| 181 |
* @return void |
| 182 |
*/ |
| 183 |
public function render_reset_rtsb_cross_sells() { |
| 184 |
$this->astra_product_loop_reset_default(); |
| 185 |
} |
| 186 |
|
| 187 |
/** |
| 188 |
* Cross Sell Product. |
| 189 |
* |
| 190 |
* @return void |
| 191 |
*/ |
| 192 |
public function render_rtsb_product_onsale() { |
| 193 |
add_filter( 'woocommerce_sale_flash', array( \Astra_Woocommerce::get_instance(), 'get_sale_flash_markup' ), 10, 3 ); |
| 194 |
} |
| 195 |
|
| 196 |
/** |
| 197 |
* The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with widget_controls. |
| 198 |
* |
| 199 |
* @return void |
| 200 |
*/ |
| 201 |
public function widget_controls_rtsb_product_tabs() { |
| 202 |
add_filter( 'rtsb/elements/elementor/single/rtsb-product-tabs', [ $this, 'product_tabs_widget_controls_support' ] ); |
| 203 |
} |
| 204 |
/** |
| 205 |
* Widget Field. |
| 206 |
* |
| 207 |
* @return array |
| 208 |
*/ |
| 209 |
public function product_tabs_widget_controls_support( $fields ) { |
| 210 |
$fields['nav_active_border_color']['selectors'] = array_merge( |
| 211 |
$fields['nav_active_border_color']['selectors'], |
| 212 |
[ |
| 213 |
'{{WRAPPER}} .woocommerce-tabs ul.tabs li.active:before' => 'background: {{VALUE}}', |
| 214 |
] |
| 215 |
); |
| 216 |
$fields['nav_active_hover_border_color']['selectors'] = array_merge( |
| 217 |
$fields['nav_active_hover_border_color']['selectors'], |
| 218 |
[ |
| 219 |
'{{WRAPPER}} .woocommerce-tabs ul.tabs li.active:hover:before' => 'background: {{VALUE}}', |
| 220 |
] |
| 221 |
); |
| 222 |
return $fields; |
| 223 |
} |
| 224 |
/** |
| 225 |
* The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with "widget_controls". |
| 226 |
* |
| 227 |
* @return void |
| 228 |
*/ |
| 229 |
public function widget_controls_rtsb_products_archive() { |
| 230 |
add_filter( 'rtsb/elements/elementor/rtsb_product_loop/rtsb-products-archive', [ $this, 'product_loop_widget_controls_support' ], 11 ); |
| 231 |
} |
| 232 |
/** |
| 233 |
* Widget Field. |
| 234 |
* |
| 235 |
* @return array |
| 236 |
*/ |
| 237 |
public function product_loop_widget_controls_support( $fields ) { |
| 238 |
if ( $this->widgets->has_pagination ) { |
| 239 |
$fields['prev_icon']['default'] = [ |
| 240 |
'value' => 'fas fa-long-arrow-alt-left', |
| 241 |
'library' => 'fa-solid', |
| 242 |
]; |
| 243 |
$fields['next_icon']['default'] = [ |
| 244 |
'value' => 'fas fa-long-arrow-alt-right', |
| 245 |
'library' => 'fa-solid', |
| 246 |
]; |
| 247 |
} |
| 248 |
return $fields; |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
} |
| 253 |
|
| 254 |
// woocommerce_pagination_args |
| 255 |
|