| @@ -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 | } |
| @@ -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,55 @@ | ||
| 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 | + if (typeof rtsbFilters === 'function') { | |
| 441 | + rtsbFilters(); | |
| 442 | + } | |
| 443 | + | |
| 444 | + setTimeout( function (){ | |
| 445 | + window.rtsbCountdownApply(); | |
| 446 | + }, 1000 ); | |
| 447 | + } else { | |
| 448 | + if (typeof elementorFrontend !== 'undefined') { | |
| 449 | + window.waitForRTSB((RTSB) => { | |
| 450 | + RTSB.modules.get('countdownPro')?.refresh(); | |
| 451 | + RTSB.modules.get('elementorInitPro')?.refresh(); | |
| 452 | + RTSB.modules.get('ajaxProductFiltersPro')?.refresh(); | |
| 453 | + }); | |
| 454 | + } | |
| 455 | + } | |
| 413 | 456 | <?php } ?> |
| 414 | 457 | </script> |
| 415 | 458 | |
| 416 | 459 | <?php |
| @@ -656,13 +699,16 @@ | ||
| 656 | 699 | |
| 657 | 700 | case 'text-stroke': |
| 658 | 701 | $type = Group_Control_Text_Stroke::get_type(); |
| 659 | 702 | break; |
| 703 | + | |
| 704 | + case 'css-filter': | |
| 705 | + $type = Group_Control_Css_Filter::get_type(); | |
| 706 | + break; | |
| 660 | 707 | default: |
| 661 | 708 | $type = constant( 'Elementor\Controls_Manager::' . strtoupper( $type ) ); |
| 662 | 709 | |
| 663 | 710 | } |
| 664 | - | |
| 665 | 711 | return $type; |
| 666 | 712 | } |
| 667 | 713 | |
| 668 | 714 | /** |
| @@ -693,9 +739,11 @@ | ||
| 693 | 739 | } |
| 694 | 740 | /** |
| 695 | 741 | * Archive Custom Layout Widget Rendering. |
| 696 | 742 | * |
| 697 | - * @return void | |
| 743 | + * @param array $classes class list. | |
| 744 | + * | |
| 745 | + * @return array | |
| 698 | 746 | */ |
| 699 | 747 | public function countdown_campaign_parent_class( $classes ) { |
| 700 | 748 | $settings = $this->get_settings_for_display(); |
| 701 | 749 | $layout = $settings['countdown_layout'] ?? 'horizontal'; |
| @@ -711,9 +759,9 @@ | ||
| 711 | 759 | ]; |
| 712 | 760 | $classes = array_filter( |
| 713 | 761 | $classes, |
| 714 | 762 | function ( $item ) use ( $remove ) { |
| 715 | - return ! in_array( $item, $remove ); | |
| 763 | + return ! in_array( $item, $remove ); // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 716 | 764 | } |
| 717 | 765 | ); |
| 718 | 766 | $new_class = 'rtsb-countdown-' . esc_attr( $countdown_preset ); |
| 719 | 767 | $new_class .= ' rtsb-countdown-' . esc_attr( $layout ); |
| @@ -744,9 +792,9 @@ | ||
| 744 | 792 | |
| 745 | 793 | /** |
| 746 | 794 | * Elementor controls marge all settings |
| 747 | 795 | * |
| 748 | - * @return array | |
| 796 | + * @return void | |
| 749 | 797 | */ |
| 750 | 798 | protected function apply_hooks_before_render() { |
| 751 | 799 | if ( $this->is_edit_mode() ) { |
| 752 | 800 | add_filter( 'wp_calculate_image_srcset_meta', '__return_null' ); |
| @@ -762,6 +810,21 @@ | ||
| 762 | 810 | protected function has_checkout_restriction() { |
| 763 | 811 | $checkout = WC()->checkout(); |
| 764 | 812 | |
| 765 | 813 | return ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in(); |
| 814 | + } | |
| 815 | + | |
| 816 | + /** | |
| 817 | + * Widget Exceptions. | |
| 818 | + * | |
| 819 | + * @return bool | |
| 820 | + */ | |
| 821 | + private function widget_exceptions() { | |
| 822 | + $exceptions = [ | |
| 823 | + 'rtsb-product-filters', | |
| 824 | + 'rtsb-wishlist', | |
| 825 | + 'rtsb-product-breadcrumbs', | |
| 826 | + ]; | |
| 827 | + | |
| 828 | + return in_array( $this->rtsb_base, $exceptions, true ); | |
| 766 | 829 | } |
| 767 | 830 | } |