Plugin Directory

Changeset 3138712


Ignore:
Timestamp:
08/21/2024 06:57:55 AM (17 months ago)
Author:
ryviu
Message:

Ryviu bug

Location:
ryviu
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • ryviu/tags/3.1.25/includes/class-ryviu-hook.php

    r3137895 r3138712  
    3333            'permission_callback' => '__return_true',
    3434        ));
     35
     36        register_rest_route($namespace, '/update-featured', array(
     37            'methods'  => 'POST',
     38            'callback' => array($this, 'webhook_update_featured_callback'),
     39            'permission_callback' => '__return_true',
     40        ));
     41
     42    }
     43
     44    public function webhook_update_featured_callback(WP_REST_Request $request) {
     45        $params = $request->get_params();
     46       
     47        return new WP_REST_Response(array(
     48            'success' => true,
     49            'message' => 'Updated successfully'
     50        ), 200);
     51
     52        if(isset($params['featured_static'])){
     53            $featured_static = isset($params['featured_static']) ? $params['featured_static'] : '';
     54            CommonFunctions::updateOption('featured_ryviu_data', $featured_static);
     55            CommonFunctions::clearStoreCache();
     56        }
     57
     58        return new WP_REST_Response(array(
     59            'success' => true,
     60            'message' => 'Updated successfully'
     61        ), 200);
     62
    3563    }
    3664
     
    4876            $settings_param = isset($params['settings']) ? $params['settings'] : null;
    4977            $settings = base64_decode($settings_param);
    50             CommonFunctions::updateSettings('ryviu_client_settings', json_decode($settings));
     78            CommonFunctions::updateOption('ryviu_client_settings', json_decode($settings));
    5179            CommonFunctions::clearStoreCache();
    5280        }
     
    5482        if(isset($params['api_id'])){
    5583            $key_id = $params['api_id'];
    56             CommonFunctions::updateSettings('ryviu_user_api_key_id', $key_id);
     84            CommonFunctions::updateOption('ryviu_user_api_key_id', $key_id);
    5785            CommonFunctions::clearStoreCache();
    5886        }
  • ryviu/tags/3.1.25/includes/class-ryviu.php

    r3137890 r3138712  
    201201            if(!$ryviu_version || ($ryviu_version && $ryviu_version == 1)){
    202202                $ryviu_scripts_app = array(
    203                     'ryviu-local' => RYVIU_URL_ASSETS.'js/local-ryviu.js',
    204203                    'ryviu-app' => 'https://cdn.ryviu.com/v/static/js/app.js?shop='.constant( 'RYVIU_SHOP_DOMAIN' ).$rocket_param.'&t='.time()
    205204                );
    206205            }else{
    207206                $ryviu_scripts_app = array(
    208                     'ryviu-local' => RYVIU_URL_ASSETS.'js/local-ryviu.js',
    209207                    'ryviu-app' => 'https://cdn2.ryviu.com/v/static/js/app.js?shop='.constant( 'RYVIU_SHOP_DOMAIN' ).$rocket_param.'&t='.time()
    210208                );
  • ryviu/tags/3.1.25/includes/common-functions.php

    r3137895 r3138712  
    22    class CommonFunctions {
    33
    4         public static function updateSettings($option_key, $option_value){
     4        public static function updateOption($option_key, $option_value){
    55            update_option($option_key, $option_value);
    66        }
  • ryviu/tags/3.1.25/includes/functions.php

    r3137890 r3138712  
    228228}
    229229
    230 function ryviu_badge_section(){
    231     $featured_ryviu_data = get_option( 'featured_ryviu_data' );
    232     if($featured_ryviu_data){
    233         echo '<ryviu-feature-extend reviews_badge="1" reviews_data="'.$featured_ryviu_data.'"></ryviu-feature-extend>';
    234     }else{
    235         echo '<ryviu-feature-extend reviews_badge="1"></ryviu-feature-extend>';
    236     }
     230function ryviu_badge_section() {
     231    $featured_ryviu_data = get_option('featured_ryviu_data');
     232    $reviews_data_attr = !empty($featured_ryviu_data) ? ' reviews_data="' . esc_attr($featured_ryviu_data) . '"' : '';
     233    echo '<ryviu-feature-extend reviews_badge="1"' . $reviews_data_attr . '></ryviu-feature-extend>';
    237234}
    238235
     
    472469
    473470        return $tabs;
     471    }
     472}
     473
     474// Add script active reviews tab and click ratting scroll to reviews widget
     475add_action('wp_footer', 'auto_open_reviews_tab_if_exists', 100);
     476
     477function auto_open_reviews_tab_if_exists() {
     478    global $product;
     479    $tabs = apply_filters('woocommerce_product_tabs', []);
     480
     481    if (isset($tabs['ryviu_reviews_tab']) && is_product()) {
     482        // Use either the default or user-defined selector
     483        $active_reviews_tab = RyviuSettings::get_option('active_reviews_tab');
     484        $review_tab_selector = RyviuSettings::get_option('element_trigger_click', '.ryviu_reviews_tab_tab a');
     485        if($review_tab_selector == ''){
     486            $review_tab_selector = '.ryviu_reviews_tab_tab a';
     487        }
     488        $position_display = RyviuSettings::get_option( 'position_display' );
     489        $position_display = (isset($position_display) && !empty($position_display )) ? $position_display : 1;
     490
     491        ?>
     492        <script type="text/javascript">
     493            jQuery(document).ready(function($) {
     494                var reviewTabSelector = '<?php echo esc_js($review_tab_selector); ?>';
     495                var reviewPositionDisplay = '<?php echo esc_js($position_display); ?>';
     496                <?php if ($active_reviews_tab == 1) : ?>
     497                    setTimeout(function() {
     498                        if ($(reviewTabSelector).length) {
     499                            $(reviewTabSelector).trigger('click');
     500                        }
     501                    }, 300);
     502                <?php endif; ?>
     503
     504                if (reviewPositionDisplay == 1 || reviewTabSelector != '.ryviu_reviews_tab_tab > a') {
     505                    $(document).on('click', '.product-widget__ryviu', function () {
     506                        if ($('ryviu-widget').length) {
     507                            $(reviewTabSelector).trigger('click');
     508                            $('html, body').animate({
     509                                scrollTop: $("ryviu-widget").offset().top
     510                            }, 0)
     511                        }
     512                    });
     513                }
     514            });
     515        </script>
     516        <?php
    474517    }
    475518}
  • ryviu/tags/3.1.25/includes/ryviu-api-controller.php

    r3137890 r3138712  
    158158
    159159                if($settings){
    160                     CommonFunctions::updateSettings('ryviu_client_settings', json_decode($settings));
     160                    CommonFunctions::updateOption('ryviu_client_settings', json_decode($settings));
    161161                    CommonFunctions::clearStoreCache();
    162162                }
    163163
    164164                if($key_id){
    165                     CommonFunctions::updateSettings('ryviu_user_api_key_id', $key_id);
     165                    CommonFunctions::updateOption('ryviu_user_api_key_id', $key_id);
    166166                    CommonFunctions::clearStoreCache();
    167167                }
  • ryviu/trunk/includes/class-ryviu-hook.php

    r3137894 r3138712  
    3333            'permission_callback' => '__return_true',
    3434        ));
     35
     36        register_rest_route($namespace, '/update-featured', array(
     37            'methods'  => 'POST',
     38            'callback' => array($this, 'webhook_update_featured_callback'),
     39            'permission_callback' => '__return_true',
     40        ));
     41
     42    }
     43
     44    public function webhook_update_featured_callback(WP_REST_Request $request) {
     45        $params = $request->get_params();
     46       
     47        return new WP_REST_Response(array(
     48            'success' => true,
     49            'message' => 'Updated successfully'
     50        ), 200);
     51
     52        if(isset($params['featured_static'])){
     53            $featured_static = isset($params['featured_static']) ? $params['featured_static'] : '';
     54            CommonFunctions::updateOption('featured_ryviu_data', $featured_static);
     55            CommonFunctions::clearStoreCache();
     56        }
     57
     58        return new WP_REST_Response(array(
     59            'success' => true,
     60            'message' => 'Updated successfully'
     61        ), 200);
     62
    3563    }
    3664
     
    4876            $settings_param = isset($params['settings']) ? $params['settings'] : null;
    4977            $settings = base64_decode($settings_param);
    50             CommonFunctions::updateSettings('ryviu_client_settings', json_decode($settings));
     78            CommonFunctions::updateOption('ryviu_client_settings', json_decode($settings));
    5179            CommonFunctions::clearStoreCache();
    5280        }
     
    5482        if(isset($params['api_id'])){
    5583            $key_id = $params['api_id'];
    56             CommonFunctions::updateSettings('ryviu_user_api_key_id', $key_id);
     84            CommonFunctions::updateOption('ryviu_user_api_key_id', $key_id);
    5785            CommonFunctions::clearStoreCache();
    5886        }
  • ryviu/trunk/includes/class-ryviu.php

    r3137890 r3138712  
    201201            if(!$ryviu_version || ($ryviu_version && $ryviu_version == 1)){
    202202                $ryviu_scripts_app = array(
    203                     'ryviu-local' => RYVIU_URL_ASSETS.'js/local-ryviu.js',
    204203                    'ryviu-app' => 'https://cdn.ryviu.com/v/static/js/app.js?shop='.constant( 'RYVIU_SHOP_DOMAIN' ).$rocket_param.'&t='.time()
    205204                );
    206205            }else{
    207206                $ryviu_scripts_app = array(
    208                     'ryviu-local' => RYVIU_URL_ASSETS.'js/local-ryviu.js',
    209207                    'ryviu-app' => 'https://cdn2.ryviu.com/v/static/js/app.js?shop='.constant( 'RYVIU_SHOP_DOMAIN' ).$rocket_param.'&t='.time()
    210208                );
  • ryviu/trunk/includes/common-functions.php

    r3137895 r3138712  
    22    class CommonFunctions {
    33
    4         public static function updateSettings($option_key, $option_value){
     4        public static function updateOption($option_key, $option_value){
    55            update_option($option_key, $option_value);
    66        }
  • ryviu/trunk/includes/functions.php

    r3137890 r3138712  
    228228}
    229229
    230 function ryviu_badge_section(){
    231     $featured_ryviu_data = get_option( 'featured_ryviu_data' );
    232     if($featured_ryviu_data){
    233         echo '<ryviu-feature-extend reviews_badge="1" reviews_data="'.$featured_ryviu_data.'"></ryviu-feature-extend>';
    234     }else{
    235         echo '<ryviu-feature-extend reviews_badge="1"></ryviu-feature-extend>';
    236     }
     230function ryviu_badge_section() {
     231    $featured_ryviu_data = get_option('featured_ryviu_data');
     232    $reviews_data_attr = !empty($featured_ryviu_data) ? ' reviews_data="' . esc_attr($featured_ryviu_data) . '"' : '';
     233    echo '<ryviu-feature-extend reviews_badge="1"' . $reviews_data_attr . '></ryviu-feature-extend>';
    237234}
    238235
     
    472469
    473470        return $tabs;
     471    }
     472}
     473
     474// Add script active reviews tab and click ratting scroll to reviews widget
     475add_action('wp_footer', 'auto_open_reviews_tab_if_exists', 100);
     476
     477function auto_open_reviews_tab_if_exists() {
     478    global $product;
     479    $tabs = apply_filters('woocommerce_product_tabs', []);
     480
     481    if (isset($tabs['ryviu_reviews_tab']) && is_product()) {
     482        // Use either the default or user-defined selector
     483        $active_reviews_tab = RyviuSettings::get_option('active_reviews_tab');
     484        $review_tab_selector = RyviuSettings::get_option('element_trigger_click', '.ryviu_reviews_tab_tab a');
     485        if($review_tab_selector == ''){
     486            $review_tab_selector = '.ryviu_reviews_tab_tab a';
     487        }
     488        $position_display = RyviuSettings::get_option( 'position_display' );
     489        $position_display = (isset($position_display) && !empty($position_display )) ? $position_display : 1;
     490
     491        ?>
     492        <script type="text/javascript">
     493            jQuery(document).ready(function($) {
     494                var reviewTabSelector = '<?php echo esc_js($review_tab_selector); ?>';
     495                var reviewPositionDisplay = '<?php echo esc_js($position_display); ?>';
     496                <?php if ($active_reviews_tab == 1) : ?>
     497                    setTimeout(function() {
     498                        if ($(reviewTabSelector).length) {
     499                            $(reviewTabSelector).trigger('click');
     500                        }
     501                    }, 300);
     502                <?php endif; ?>
     503
     504                if (reviewPositionDisplay == 1 || reviewTabSelector != '.ryviu_reviews_tab_tab > a') {
     505                    $(document).on('click', '.product-widget__ryviu', function () {
     506                        if ($('ryviu-widget').length) {
     507                            $(reviewTabSelector).trigger('click');
     508                            $('html, body').animate({
     509                                scrollTop: $("ryviu-widget").offset().top
     510                            }, 0)
     511                        }
     512                    });
     513                }
     514            });
     515        </script>
     516        <?php
    474517    }
    475518}
  • ryviu/trunk/includes/ryviu-api-controller.php

    r3137890 r3138712  
    158158
    159159                if($settings){
    160                     CommonFunctions::updateSettings('ryviu_client_settings', json_decode($settings));
     160                    CommonFunctions::updateOption('ryviu_client_settings', json_decode($settings));
    161161                    CommonFunctions::clearStoreCache();
    162162                }
    163163
    164164                if($key_id){
    165                     CommonFunctions::updateSettings('ryviu_user_api_key_id', $key_id);
     165                    CommonFunctions::updateOption('ryviu_user_api_key_id', $key_id);
    166166                    CommonFunctions::clearStoreCache();
    167167                }
Note: See TracChangeset for help on using the changeset viewer.