| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main ProductDescription class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\Controls; |
| 9 |
|
| 10 |
use Elementor\Controls_Manager; |
| 11 |
use RadiusTheme\SB\Helpers\Fns; |
| 12 |
|
| 13 |
// Do not allow directly accessing this file. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit( 'This script cannot be accessed directly.' ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Product Description class |
| 20 |
*/ |
| 21 |
class ModuleBtnControls { |
| 22 |
/** |
| 23 |
* Widget Field |
| 24 |
* |
| 25 |
* @param object $widget Widget Object. |
| 26 |
* |
| 27 |
* @return array |
| 28 |
*/ |
| 29 |
public static function module_button_style( $widget ) { |
| 30 |
$selector = $widget->selectors; |
| 31 |
$module_btn_active = Fns::is_module_active( 'wishlist' ) || Fns::is_module_active( 'compare' ) || Fns::is_module_active( 'quick_view' ); |
| 32 |
$fields = []; |
| 33 |
if ( ! $module_btn_active ) { |
| 34 |
return $fields; |
| 35 |
} |
| 36 |
|
| 37 |
$fields = [ |
| 38 |
'module_section' => [ |
| 39 |
'mode' => 'section_start', |
| 40 |
'tab' => 'style', |
| 41 |
'label' => esc_html__( 'Wishlist, Compare & Quick view', 'shopbuilder' ), |
| 42 |
'conditions' => [ |
| 43 |
'relation' => 'or', |
| 44 |
'terms' => [], |
| 45 |
], |
| 46 |
], |
| 47 |
'module_width' => [ |
| 48 |
'label' => esc_html__( 'Width', 'shopbuilder' ), |
| 49 |
'type' => 'slider', |
| 50 |
'separator' => 'default', |
| 51 |
'range' => [ |
| 52 |
'px' => [ |
| 53 |
'min' => 10, |
| 54 |
'max' => 200, |
| 55 |
], |
| 56 |
], |
| 57 |
'default' => [ |
| 58 |
'size' => 20, |
| 59 |
], |
| 60 |
'selectors' => [ |
| 61 |
$selector['module_width'] => 'width: {{SIZE}}{{UNIT}};', |
| 62 |
], |
| 63 |
], |
| 64 |
'module_height' => [ |
| 65 |
'label' => esc_html__( 'Height', 'shopbuilder' ), |
| 66 |
'type' => 'slider', |
| 67 |
'range' => [ |
| 68 |
'px' => [ |
| 69 |
'min' => 10, |
| 70 |
'max' => 200, |
| 71 |
], |
| 72 |
], |
| 73 |
'default' => [ |
| 74 |
'size' => 20, |
| 75 |
], |
| 76 |
'selectors' => [ |
| 77 |
$selector['module_height'] => 'height: {{SIZE}}{{UNIT}};', |
| 78 |
], |
| 79 |
], |
| 80 |
'module_item_gap' => [ |
| 81 |
'label' => esc_html__( 'Item Gap (px)', 'shopbuilder' ), |
| 82 |
'type' => 'slider', |
| 83 |
'separator' => 'default', |
| 84 |
'range' => [ |
| 85 |
'px' => [ |
| 86 |
'min' => 0, |
| 87 |
'max' => 100, |
| 88 |
], |
| 89 |
], |
| 90 |
'default' => [ |
| 91 |
'size' => 5, |
| 92 |
], |
| 93 |
'selectors' => [ |
| 94 |
$selector['module_item_gap'] => 'gap: {{SIZE}}{{UNIT}};', |
| 95 |
], |
| 96 |
], |
| 97 |
'module_item_alignment' => [ |
| 98 |
'mode' => 'responsive', |
| 99 |
'type' => 'choose', |
| 100 |
'label' => esc_html__( 'Elements Alignment', 'shopbuilder' ), |
| 101 |
'options' => [ |
| 102 |
'left' => [ |
| 103 |
'title' => esc_html__( 'Left', 'shopbuilder' ), |
| 104 |
'icon' => 'eicon-text-align-left', |
| 105 |
], |
| 106 |
'center' => [ |
| 107 |
'title' => esc_html__( 'Center', 'shopbuilder' ), |
| 108 |
'icon' => 'eicon-text-align-center', |
| 109 |
], |
| 110 |
'right' => [ |
| 111 |
'title' => esc_html__( 'Right', 'shopbuilder' ), |
| 112 |
'icon' => 'eicon-text-align-right', |
| 113 |
], |
| 114 |
], |
| 115 |
'selectors' => [ |
| 116 |
$selector['module_item_alignment'] => 'justify-content: {{VALUE}}!important;', |
| 117 |
], |
| 118 |
], |
| 119 |
'module_tabs_start' => [ |
| 120 |
'mode' => 'tabs_start', |
| 121 |
], |
| 122 |
// Tab For normal view. |
| 123 |
'module_normal' => [ |
| 124 |
'mode' => 'tab_start', |
| 125 |
'label' => esc_html__( 'Normal', 'shopbuilder' ), |
| 126 |
], |
| 127 |
'module_text_color_normal' => [ |
| 128 |
'label' => esc_html__( 'Color', 'shopbuilder' ), |
| 129 |
'type' => 'color', |
| 130 |
'separator' => 'default', |
| 131 |
'selectors' => [ |
| 132 |
$selector['module_text_color_normal'] => 'color: {{VALUE}};', |
| 133 |
], |
| 134 |
], |
| 135 |
'module_bg_color_normal' => [ |
| 136 |
'label' => esc_html__( 'Background Color', 'shopbuilder' ), |
| 137 |
'type' => 'color', |
| 138 |
|
| 139 |
'selectors' => [ |
| 140 |
$selector['module_bg_color_normal'] => 'background-color: {{VALUE}};', |
| 141 |
], |
| 142 |
], |
| 143 |
|
| 144 |
'module_border' => [ |
| 145 |
'mode' => 'group', |
| 146 |
'type' => 'border', |
| 147 |
'selector' => $selector['module_border'], |
| 148 |
'size_units' => [ 'px' ], |
| 149 |
], |
| 150 |
'module_normal_end' => [ |
| 151 |
'mode' => 'tab_end', |
| 152 |
], |
| 153 |
'module_hover' => [ |
| 154 |
'mode' => 'tab_start', |
| 155 |
'label' => esc_html__( 'Hover', 'shopbuilder' ), |
| 156 |
], |
| 157 |
'module_text_color_hover' => [ |
| 158 |
'label' => esc_html__( 'Color', 'shopbuilder' ), |
| 159 |
'type' => 'color', |
| 160 |
|
| 161 |
'separator' => 'default', |
| 162 |
'selectors' => [ |
| 163 |
$selector['module_text_color_hover'] => 'color: {{VALUE}};', |
| 164 |
], |
| 165 |
], |
| 166 |
'module_bg_color_hover' => [ |
| 167 |
'label' => esc_html__( 'Background Color', 'shopbuilder' ), |
| 168 |
'type' => 'color', |
| 169 |
|
| 170 |
'selectors' => [ |
| 171 |
$selector['module_bg_color_hover'] => 'background-color: {{VALUE}};', |
| 172 |
], |
| 173 |
], |
| 174 |
'module_border_hover_color' => [ |
| 175 |
'label' => esc_html__( 'Border Color', 'shopbuilder' ), |
| 176 |
'type' => 'color', |
| 177 |
|
| 178 |
'selectors' => [ |
| 179 |
$selector['module_border_hover_color'] => 'border-color: {{VALUE}};', |
| 180 |
], |
| 181 |
], |
| 182 |
'module_hover_end' => [ |
| 183 |
'mode' => 'tab_end', |
| 184 |
], |
| 185 |
'module_tabs_end' => [ |
| 186 |
'mode' => 'tabs_end', |
| 187 |
], |
| 188 |
'module_border_radius' => [ |
| 189 |
'label' => esc_html__( 'Border Radius (px)', 'shopbuilder' ), |
| 190 |
'type' => 'dimensions', |
| 191 |
'mode' => 'responsive', |
| 192 |
'separator' => 'before', |
| 193 |
'size_units' => [ 'px' ], |
| 194 |
'selectors' => [ |
| 195 |
$selector['module_border_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 196 |
], |
| 197 |
], |
| 198 |
|
| 199 |
'icon_size' => [ |
| 200 |
'label' => esc_html__( 'Icon Size', 'shopbuilder' ), |
| 201 |
'type' => 'slider', |
| 202 |
'separator' => 'before', |
| 203 |
'range' => [ |
| 204 |
'px' => [ |
| 205 |
'min' => 10, |
| 206 |
'max' => 200, |
| 207 |
], |
| 208 |
], |
| 209 |
'default' => [ |
| 210 |
'size' => 15, |
| 211 |
], |
| 212 |
'selectors' => [ |
| 213 |
$selector['icon_size']['icon'] => 'font-size: {{SIZE}}{{UNIT}};', |
| 214 |
$selector['icon_size']['svg'] => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};', |
| 215 |
], |
| 216 |
], |
| 217 |
'module_wrapper_margin' => [ |
| 218 |
'label' => esc_html__( 'Module Wrapper Gap (px)', 'shopbuilder' ), |
| 219 |
'type' => 'dimensions', |
| 220 |
'mode' => 'responsive', |
| 221 |
'size_units' => [ 'px' ], |
| 222 |
'selectors' => [ |
| 223 |
$selector['module_wrapper_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 224 |
], |
| 225 |
], |
| 226 |
'module_section_end' => [ |
| 227 |
'mode' => 'section_end', |
| 228 |
], |
| 229 |
]; |
| 230 |
|
| 231 |
if ( Fns::is_module_active( 'wishlist' ) ) { |
| 232 |
$fields['module_section']['conditions']['terms'][] = [ |
| 233 |
'name' => 'wishlist_button', |
| 234 |
'operator' => '===', |
| 235 |
'value' => 'yes', |
| 236 |
]; |
| 237 |
} |
| 238 |
if ( Fns::is_module_active( 'compare' ) ) { |
| 239 |
$fields['module_section']['conditions']['terms'][] = [ |
| 240 |
'name' => 'comparison_button', |
| 241 |
'operator' => '===', |
| 242 |
'value' => 'yes', |
| 243 |
]; |
| 244 |
} |
| 245 |
if ( Fns::is_module_active( 'quick_view' ) && isset( $fields['quick_view_button'] ) ) { |
| 246 |
$fields['module_section']['conditions']['terms'][] = [ |
| 247 |
'name' => 'quick_view_button', |
| 248 |
'operator' => '===', |
| 249 |
'value' => 'yes', |
| 250 |
]; |
| 251 |
} |
| 252 |
|
| 253 |
return $fields; |
| 254 |
} |
| 255 |
|
| 256 |
/** |
| 257 |
* Widget Field |
| 258 |
* |
| 259 |
* @return array |
| 260 |
*/ |
| 261 |
public static function module_switch() { |
| 262 |
$fields = []; |
| 263 |
if ( Fns::is_module_active( 'wishlist' ) ) { |
| 264 |
$fields['wishlist_button'] = [ |
| 265 |
'type' => 'switch', |
| 266 |
'label' => esc_html__( 'Show Wishlist Button?', 'shopbuilder' ), |
| 267 |
'description' => esc_html__( 'Switch on to show product wishlist. Ensure "Showcase Button Position" under Wishlist module\'s "Product Showcase Settings" is not set to "Custom Position".', 'shopbuilder' ), |
| 268 |
'default' => 'yes', |
| 269 |
]; |
| 270 |
} |
| 271 |
if ( Fns::is_module_active( 'compare' ) ) { |
| 272 |
$fields['comparison_button'] = [ |
| 273 |
'type' => 'switch', |
| 274 |
'label' => esc_html__( 'Show Compare Button?', 'shopbuilder' ), |
| 275 |
'description' => esc_html__( 'Switch on to show product comparison. Ensure "Showcase Button Position" under Compare module\'s "Product Showcase Settings" is not set to "Custom Position".', 'shopbuilder' ), |
| 276 |
'default' => 'yes', |
| 277 |
]; |
| 278 |
} |
| 279 |
if ( Fns::is_module_active( 'quick_view' ) ) { |
| 280 |
$fields['quick_view_button'] = [ |
| 281 |
'type' => 'switch', |
| 282 |
'label' => esc_html__( 'Show Quick View Button?', 'shopbuilder' ), |
| 283 |
'description' => esc_html__( 'Switch on to show product quick view. Ensure "Showcase Button Position" under Quick View module\'s "Product Showcase Settings" is not set to "Custom Position".', 'shopbuilder' ), |
| 284 |
'default' => 'yes', |
| 285 |
]; |
| 286 |
} |
| 287 |
|
| 288 |
return $fields; |
| 289 |
} |
| 290 |
|
| 291 |
/** |
| 292 |
* Widget Field |
| 293 |
* |
| 294 |
* @return array |
| 295 |
*/ |
| 296 |
public static function module_icons() { |
| 297 |
$module_btn_active = Fns::is_module_active( 'wishlist' ) || Fns::is_module_active( 'compare' ) || Fns::is_module_active( 'quick_view' ); |
| 298 |
$fields = []; |
| 299 |
if ( $module_btn_active ) { |
| 300 |
if ( Fns::is_module_active( 'wishlist' ) ) { |
| 301 |
$fields['wishlist_icon'] = [ |
| 302 |
'label' => esc_html__( 'Wishlist Icon', 'shopbuilder' ), |
| 303 |
'type' => 'icons', |
| 304 |
'separator' => 'default', |
| 305 |
'default' => [ |
| 306 |
'value' => 'rtsb-icon rtsb-icon-heart-empty', |
| 307 |
'library' => 'rtsb-fonts', |
| 308 |
], |
| 309 |
'condition' => [ |
| 310 |
'wishlist_button' => 'yes', |
| 311 |
], |
| 312 |
]; |
| 313 |
$fields['wishlist_icon_added'] = [ |
| 314 |
'label' => esc_html__( 'After Added Wishlist Icon', 'shopbuilder' ), |
| 315 |
'type' => 'icons', |
| 316 |
'default' => [ |
| 317 |
'value' => 'rtsb-icon rtsb-icon-heart', |
| 318 |
'library' => 'rtsb-fonts', |
| 319 |
], |
| 320 |
'condition' => [ |
| 321 |
'wishlist_button' => 'yes', |
| 322 |
], |
| 323 |
]; |
| 324 |
} |
| 325 |
if ( Fns::is_module_active( 'compare' ) ) { |
| 326 |
$fields['comparison_icon'] = [ |
| 327 |
'label' => esc_html__( 'Compare Icon', 'shopbuilder' ), |
| 328 |
'type' => 'icons', |
| 329 |
'default' => [ |
| 330 |
'value' => 'rtsb-icon rtsb-icon-exchange', |
| 331 |
'library' => 'rtsb-fonts', |
| 332 |
], |
| 333 |
'condition' => [ |
| 334 |
'comparison_button' => 'yes', |
| 335 |
], |
| 336 |
]; |
| 337 |
$fields['comparison_icon_added'] = [ |
| 338 |
'label' => esc_html__( 'After Added Compare Icon', 'shopbuilder' ), |
| 339 |
'type' => 'icons', |
| 340 |
'default' => [ |
| 341 |
'value' => 'rtsb-icon rtsb-icon-check', |
| 342 |
'library' => 'rtsb-fonts', |
| 343 |
], |
| 344 |
'condition' => [ |
| 345 |
'comparison_button' => 'yes', |
| 346 |
], |
| 347 |
]; |
| 348 |
} |
| 349 |
if ( Fns::is_module_active( 'quick_view' ) ) { |
| 350 |
$fields['quick_view_icon'] = [ |
| 351 |
'label' => esc_html__( 'Quick View Icon', 'shopbuilder' ), |
| 352 |
'type' => 'icons', |
| 353 |
'default' => [ |
| 354 |
'value' => 'rtsb-icon rtsb-icon-eye', |
| 355 |
'library' => 'rtsb-fonts', |
| 356 |
], |
| 357 |
'condition' => [ |
| 358 |
'quick_view_button' => 'yes', |
| 359 |
], |
| 360 |
]; |
| 361 |
} |
| 362 |
} |
| 363 |
|
| 364 |
return $fields; |
| 365 |
} |
| 366 |
} |
| 367 |
|