Plugin Directory

Changeset 2916256


Ignore:
Timestamp:
05/23/2023 08:53:09 AM (3 years ago)
Author:
ryviu
Message:

Update Ryviu Short Code

Location:
ryviu/trunk/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ryviu/trunk/includes/functions.php

    r2915558 r2916256  
    697697// Total shortcode
    698698
     699function ryviu_widget_total_func( $atts ) {
     700    $a = shortcode_atts( array(
     701        'product_id' => 0
     702    ), $atts );
     703
     704    ob_start();
     705   
     706    ryviu_widget_rating_total();
     707   
     708    return ob_get_clean();
     709}
    699710add_shortcode( 'ryviu_widget_total', 'ryviu_widget_total_func' );
    700711
    701 function ryviu_widget_total_func( $atts ) {
    702     $atts = shortcode_atts( array(
    703         'product_id' => 0,
     712// Reviews shortcode
     713
     714function ryviu_widget_sc( $atts ) {
     715    $a = shortcode_atts( array(
     716        'product_id' => 0
    704717    ), $atts );
    705718
    706     ryviu_widget_rating_total();
    707 }
    708 
    709 // Reviews shortcode
    710 
     719    ob_start();
     720   
     721    ryviu_product_display_review();
     722   
     723    return ob_get_clean();
     724}
    711725add_shortcode( 'ryviu_widget', 'ryviu_widget_sc' );
    712726
    713 function ryviu_widget_sc( $atts ) {
    714     $atts = shortcode_atts( array(
    715         'product_id' => 0,
     727// Collection shortcode
     728
     729function ryviu_widget_colection_func( $atts ) {
     730    $a = shortcode_atts( array(
     731        'product_id' => 0
    716732    ), $atts );
    717733
    718     ryviu_product_display_review();
    719 }
    720 
    721 // Collection shortcode
    722 
     734    ob_start();
     735   
     736    ryviu_widget_rating_total_in_product_category();
     737   
     738    return ob_get_clean();
     739}
    723740add_shortcode( 'ryviu_widget_colection', 'ryviu_widget_colection_func' );
    724741
    725 function ryviu_widget_colection_func( $atts ) {
    726     $atts = shortcode_atts( array(
    727         'product_id' => 0,
    728     ), $atts );
    729 
    730     ryviu_widget_rating_total_in_product_category();
    731 }
    732 
    733742// Question and answer shortcode
    734 
    735 add_shortcode( 'ryviu_question_and_answer', 'question_and_answer_func' );
    736743
    737744function question_and_answer_func( $atts ) {
     
    739746        'product_id' => 0,
    740747    ), $atts );
     748    ob_start();
    741749
    742750    ryviu_add_questions_answers_section();
    743 }
     751
     752    return ob_get_clean();
     753}
     754
     755add_shortcode( 'ryviu_question_and_answer', 'question_and_answer_func' );
  • ryviu/trunk/includes/settings.php

    r2915558 r2916256  
    9999        );
    100100
    101         add_settings_section(
    102             'stars_section_id', // ID
    103             'Star rating', // Title
    104             array( $this, 'print_stars_info' ), // Callback
    105             'ryviu-setting-admin' // Page
    106         );
    107 
    108         foreach ($this->star_rating_settings() as $field) {
    109             add_settings_field(
    110                 $field['name'], // name
    111                 $field['title'], // Title
    112                 array( $this, $field['name'].'_callback' ), // Callback
    113                 'ryviu-setting-admin', // Page
    114                 'stars_section_id' // Section
    115             );
    116         }
    117 
    118         add_settings_section(
    119             'ryviu_widget_id', // ID
    120             'Ryviu widget', // Title
    121             array( $this, 'print_reviews_info' ), // Callback
    122             'ryviu-setting-admin' // Page
    123         );
    124 
    125         foreach ($this->reviews_widget_settings() as $field) {
    126             add_settings_field(
    127                 $field['name'], // name
    128                 $field['title'], // Title
    129                 array( $this, $field['name'].'_callback' ), // Callback
    130                 'ryviu-setting-admin', // Page
    131                 'ryviu_widget_id' // Section
    132             );
    133         }
    134 
    135         add_settings_section(
    136             'question_widget_id', // ID
    137             'Question and answer', // Title
    138             array( $this, 'print_question_info' ), // Callback
    139             'ryviu-setting-admin' // Page
    140         );
    141 
    142         foreach ($this->questions_and_answer_settings() as $field) {
    143             add_settings_field(
    144                 $field['name'], // name
    145                 $field['title'], // Title
    146                 array( $this, $field['name'].'_callback' ), // Callback
    147                 'ryviu-setting-admin', // Page
    148                 'question_widget_id' // Section
    149             );
    150         }
    151101
    152102        add_settings_section(
    153103            'general_id', // ID
    154             'Other settings', // Title
     104            'Ryviu settings', // Title
    155105            array( $this, 'print_section_info' ), // Callback
    156106            'ryviu-setting-admin' // Page
     
    167117        }
    168118    }
    169     public function star_rating_settings(){
     119   
     120    public function general_settings(){
    170121        $fields = [
    171122            'position_display_widget' => 'Star rating on product page',
    172123            'show_average_rating' => 'Show average rating',
    173124            'position_display_widget_in_loop' => 'Star rating on collection page',
    174         ];
    175    
    176         return array_map(function($name, $title) {
    177             return ['name' => $name, 'title' => $title];
    178         }, array_keys($fields), array_values($fields));
    179     }
    180     public function general_settings(){
    181         $fields = [
     125            'position_display' => 'Review box on product page',
     126            'custom_tab_title' => 'Title reviews tab',
     127            'active_reviews_tab' => 'Default active review tab',
     128            'one_column_mobile' => '1 column on mobile',
     129            'element_trigger_click' => 'Title reviews tab HTML',
     130            'question_and_answer' => 'Question and Answer',
     131            'custom_question_tab_title' => 'Title Question & Answer tab',
    182132            'wordpress_theme' => 'Wordpress Theme',
    183133            'data_rocket_status' => 'Cloudfare CDN & Data Rocket',
     
    189139    }
    190140
    191     public function reviews_widget_settings(){
    192         $fields = [
    193             'position_display' => 'Review box on product page',
    194             'custom_tab_title' => 'Title reviews tab',
    195             'active_reviews_tab' => 'Default active review tab',
    196             'one_column_mobile' => '1 column on mobile',
    197             'element_trigger_click' => 'Title reviews tab HTML',
    198         ];
    199    
    200         return array_map(function($name, $title) {
    201             return ['name' => $name, 'title' => $title];
    202         }, array_keys($fields), array_values($fields));
    203     }
    204 
    205     public function questions_and_answer_settings(){
    206         $fields = [
    207             'question_and_answer' => 'Question and Answer',
    208             'custom_question_tab_title' => 'Title Question & Answer tab',
    209         ];
    210    
    211         return array_map(function($name, $title) {
    212             return ['name' => $name, 'title' => $title];
    213         }, array_keys($fields), array_values($fields));
    214     }
    215 
    216141    public function check_selected($val1 = '1', $val2 = '2'){
    217142        if($val1 == $val2){
     
    230155        $new_input = array();
    231156
    232         $star_rating_settings = $this->star_rating_settings();
    233         $general_settings = $this->general_settings();
    234         $reviews_widget_settings = $this->reviews_widget_settings();
    235         $questions_and_answer_settings = $this->questions_and_answer_settings();
    236 
    237         $fields_setting = array_merge($star_rating_settings, $general_settings, $reviews_widget_settings, $questions_and_answer_settings);
    238 
     157        $fields_setting = $this->general_settings();
    239158
    240159        $fields_setting[] = array(
     
    262181     */
    263182    public function print_section_info(){
    264         print '';
     183        print 'Enter your settings below:';
    265184    }
    266185
Note: See TracChangeset for help on using the changeset viewer.