| @@ -6,8 +6,9 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace RadiusTheme\SB\Abstracts; |
| 9 | 9 | |
| 10 | +use Elementor\Group_Control_Css_Filter; | |
| 10 | 11 | use Elementor\Plugin; |
| 11 | 12 | use Elementor\Repeater; |
| 12 | 13 | use Elementor\Widget_Base; |
| 13 | 14 | use Elementor\Controls_Manager; |
| @@ -19,8 +20,9 @@ | ||
| 19 | 20 | use Elementor\Group_Control_Box_Shadow; |
| 20 | 21 | use Elementor\Group_Control_Text_Shadow; |
| 21 | 22 | use Elementor\Group_Control_Text_Stroke; |
| 22 | 23 | use RadiusTheme\SB\Elementor\Helper\ControlSelectors; |
| 24 | +use RadiusTheme\SB\Helpers\Fns; | |
| 23 | 25 | |
| 24 | 26 | |
| 25 | 27 | // Do not allow directly accessing this file. |
| 26 | 28 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -186,9 +188,9 @@ | ||
| 186 | 188 | * |
| 187 | 189 | * @return array |
| 188 | 190 | */ |
| 189 | 191 | public function promo_content() { |
| 190 | - if ( rtsb()->has_pro() ) { | |
| 192 | + if ( rtsb()->has_pro() || $this->widget_exceptions() ) { | |
| 191 | 193 | return []; |
| 192 | 194 | } |
| 193 | 195 | |
| 194 | 196 | $promo_fields = []; |
| @@ -296,8 +298,14 @@ | ||
| 296 | 298 | } |
| 297 | 299 | if ( isset( $value['mode'] ) && 'responsive' === $value['mode'] ) { |
| 298 | 300 | unset( $value['mode'] ); |
| 299 | 301 | $repeater->add_responsive_control( $rf_id, $value ); |
| 302 | + } elseif ( isset( $value['mode'] ) && 'group' === $value['mode'] ) { | |
| 303 | + $type = $value['type']; | |
| 304 | + $value['name'] = $rf_id; | |
| 305 | + unset( $value['mode'] ); | |
| 306 | + unset( $value['type'] ); | |
| 307 | + $repeater->add_group_control( $type, $value ); | |
| 300 | 308 | } else { |
| 301 | 309 | $repeater->add_control( $rf_id, $value ); |
| 302 | 310 | } |
| 303 | 311 | } |
| @@ -336,9 +344,9 @@ | ||
| 336 | 344 | * |
| 337 | 345 | * @return void |
| 338 | 346 | */ |
| 339 | 347 | public function editor_slider_script() { |
| 340 | - if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { | |
| 348 | + if ( ! empty( \Elementor\Plugin::$instance->editor ) && \Elementor\Plugin::$instance->editor->is_edit_mode() ) { | |
| 341 | 349 | $selector = $this->get_unique_selector() . ' .rtsb-carousel-slider'; |
| 342 | 350 | ?> |
| 343 | 351 | <script> |
| 344 | 352 | jQuery('<?php echo esc_attr( $selector ); ?>').rtsb_slider(); |
| @@ -365,9 +373,8 @@ | ||
| 365 | 373 | var cartButton = cartWrpper.find( |
| 366 | 374 | '.product_type_grouped, .add_to_cart_button, .single_add_to_cart_button ' |
| 367 | 375 | ); |
| 368 | 376 | if (cartIcon) { |
| 369 | - console.log( cartButton.find('svg') ) | |
| 370 | 377 | cartButton.find('i').remove(); |
| 371 | 378 | cartButton.find('svg').remove(); |
| 372 | 379 | cartButton.find('img').remove(); |
| 373 | 380 | cartButton.prepend(cartIcon); |
| @@ -388,8 +395,10 @@ | ||
| 388 | 395 | if ( ! $this->is_edit_mode() ) { |
| 389 | 396 | return; |
| 390 | 397 | } |
| 391 | 398 | $ajaxurl = admin_url( 'admin-ajax.php' ); |
| 399 | + | |
| 400 | + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 392 | 401 | if ( in_array( 'sitepress-multilingual-cms/sitepress.php', get_option( 'active_plugins' ) ) ) { |
| 393 | 402 | $ajaxurl = admin_url( 'admin-ajax.php?lang=' . ICL_LANGUAGE_CODE ); |
| 394 | 403 | } |
| 395 | 404 | ?> |
| @@ -396,21 +405,59 @@ | ||
| 396 | 405 | <script> |
| 397 | 406 | var rtsb = { |
| 398 | 407 | ajaxurl: '<?php echo esc_url( $ajaxurl ); ?>', |
| 399 | 408 | nonce: '<?php echo esc_attr( wp_create_nonce( rtsb()->nonceId ) ); ?>', |
| 400 | - is_pro: '<?php echo esc_attr( rtsb()->has_pro() ? 'true' : 'false' ); ?>' | |
| 409 | + is_pro: '<?php echo esc_attr( rtsb()->has_pro() ? 'true' : 'false' ); ?>', | |
| 410 | + isOptimizationEnabled: '<?php echo esc_attr( Fns::is_optimization_enabled() ); ?>' | |
| 401 | 411 | }; |
| 402 | 412 | |
| 403 | - rtsbElFrontend(); | |
| 413 | + if (!rtsb.isOptimizationEnabled) { | |
| 414 | + rtsbElFrontend(); | |
| 404 | 415 | |
| 405 | - setTimeout(function() { | |
| 406 | - rtsbProductPageInit(); | |
| 407 | - }, 1000); | |
| 416 | + setTimeout(function() { | |
| 417 | + rtsbProductPageInit(); | |
| 418 | + }, 1000); | |
| 419 | + } else { | |
| 420 | + if (typeof elementorFrontend !== 'undefined') { | |
| 421 | + window.waitForRTSB((RTSB) => { | |
| 422 | + RTSB.modules.get('elementorInit')?.refresh(); | |
| 423 | + RTSB.modules.get('singleProductTabs')?.refresh(); | |
| 424 | + RTSB.modules.get('reviewFormStar')?.refresh(); | |
| 425 | + RTSB.modules.get('addCartIcon')?.refresh(); | |
| 426 | + RTSB.modules.get('productImage')?.refresh(); | |
| 427 | + RTSB.modules.get('CartQuantityHandler')?.refresh(); | |
| 428 | + }); | |
| 429 | + } | |
| 430 | + } | |
| 431 | + | |
| 408 | 432 | <?php if ( rtsb()->has_pro() ) { ?> |
| 409 | - rtsbFilters(); | |
| 410 | - setTimeout( function (){ | |
| 411 | - window.rtsbCountdownApply(); | |
| 412 | - }, 1000 ); | |
| 433 | + var isMasonry = jQuery('.rtsb-elementor-container .rtsb-masonry'); | |
| 434 | + | |
| 435 | + if(isMasonry.length > 0) { | |
| 436 | + isMasonry.masonry(); | |
| 437 | + } | |
| 438 | + | |
| 439 | + if (!'<?php echo esc_attr( Fns::is_optimization_enabled() ); ?>') { | |
| 440 | + <?php if ( 'rtsb-ajax-product-filters' === $this->rtsb_base ) { ?> | |
| 441 | + if (typeof rtsbFilters === 'function') { | |
| 442 | + rtsbFilters(); | |
| 443 | + } | |
| 444 | + <?php } ?> | |
| 445 | + | |
| 446 | + setTimeout( function (){ | |
| 447 | + window.rtsbCountdownApply(); | |
| 448 | + }, 1000 ); | |
| 449 | + } else { | |
| 450 | + if (typeof elementorFrontend !== 'undefined') { | |
| 451 | + window.waitForRTSB((RTSB) => { | |
| 452 | + RTSB.modules.get('countdownPro')?.refresh(); | |
| 453 | + RTSB.modules.get('elementorInitPro')?.refresh(); | |
| 454 | + <?php if ( 'rtsb-ajax-product-filters' === $this->rtsb_base ) { ?> | |
| 455 | + RTSB.modules.get('ajaxProductFiltersPro')?.refresh(); | |
| 456 | + <?php } ?> | |
| 457 | + }); | |
| 458 | + } | |
| 459 | + } | |
| 413 | 460 | <?php } ?> |
| 414 | 461 | </script> |
| 415 | 462 | |
| 416 | 463 | <?php |
| @@ -656,13 +703,16 @@ | ||
| 656 | 703 | |
| 657 | 704 | case 'text-stroke': |
| 658 | 705 | $type = Group_Control_Text_Stroke::get_type(); |
| 659 | 706 | break; |
| 707 | + | |
| 708 | + case 'css-filter': | |
| 709 | + $type = Group_Control_Css_Filter::get_type(); | |
| 710 | + break; | |
| 660 | 711 | default: |
| 661 | 712 | $type = constant( 'Elementor\Controls_Manager::' . strtoupper( $type ) ); |
| 662 | 713 | |
| 663 | 714 | } |
| 664 | - | |
| 665 | 715 | return $type; |
| 666 | 716 | } |
| 667 | 717 | |
| 668 | 718 | /** |
| @@ -693,9 +743,11 @@ | ||
| 693 | 743 | } |
| 694 | 744 | /** |
| 695 | 745 | * Archive Custom Layout Widget Rendering. |
| 696 | 746 | * |
| 697 | - * @return void | |
| 747 | + * @param array $classes class list. | |
| 748 | + * | |
| 749 | + * @return array | |
| 698 | 750 | */ |
| 699 | 751 | public function countdown_campaign_parent_class( $classes ) { |
| 700 | 752 | $settings = $this->get_settings_for_display(); |
| 701 | 753 | $layout = $settings['countdown_layout'] ?? 'horizontal'; |
| @@ -711,9 +763,9 @@ | ||
| 711 | 763 | ]; |
| 712 | 764 | $classes = array_filter( |
| 713 | 765 | $classes, |
| 714 | 766 | function ( $item ) use ( $remove ) { |
| 715 | - return ! in_array( $item, $remove ); | |
| 767 | + return ! in_array( $item, $remove ); // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 716 | 768 | } |
| 717 | 769 | ); |
| 718 | 770 | $new_class = 'rtsb-countdown-' . esc_attr( $countdown_preset ); |
| 719 | 771 | $new_class .= ' rtsb-countdown-' . esc_attr( $layout ); |
| @@ -744,9 +796,9 @@ | ||
| 744 | 796 | |
| 745 | 797 | /** |
| 746 | 798 | * Elementor controls marge all settings |
| 747 | 799 | * |
| 748 | - * @return array | |
| 800 | + * @return void | |
| 749 | 801 | */ |
| 750 | 802 | protected function apply_hooks_before_render() { |
| 751 | 803 | if ( $this->is_edit_mode() ) { |
| 752 | 804 | add_filter( 'wp_calculate_image_srcset_meta', '__return_null' ); |
| @@ -762,6 +814,21 @@ | ||
| 762 | 814 | protected function has_checkout_restriction() { |
| 763 | 815 | $checkout = WC()->checkout(); |
| 764 | 816 | |
| 765 | 817 | return ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in(); |
| 818 | + } | |
| 819 | + | |
| 820 | + /** | |
| 821 | + * Widget Exceptions. | |
| 822 | + * | |
| 823 | + * @return bool | |
| 824 | + */ | |
| 825 | + private function widget_exceptions() { | |
| 826 | + $exceptions = [ | |
| 827 | + 'rtsb-product-filters', | |
| 828 | + 'rtsb-wishlist', | |
| 829 | + 'rtsb-product-breadcrumbs', | |
| 830 | + ]; | |
| 831 | + | |
| 832 | + return in_array( $this->rtsb_base, $exceptions, true ); | |
| 766 | 833 | } |
| 767 | 834 | } |