Plugin Directory

Changeset 2144904


Ignore:
Timestamp:
08/24/2019 04:59:21 PM (7 years ago)
Author:
krishna121
Message:

version1.0.3

Location:
wp-rate-and-review
Files:
30 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp-rate-and-review/tags/1.0.2/readme.txt

    r2143294 r2144904  
    4444* fixed summary show.
    4545
    46 
    4746= 1.0.1 =
    4847* Auto disable plugin if woocommerce not installed.
  • wp-rate-and-review/trunk/include/view/welcome.php

    r2142261 r2144904  
    1111                <li><?php esc_html_e('Rate And Review Summary :- You could show rate and review summary including to average rating of product','wp-rate-and-review-products');?></li>
    1212                <li><?php esc_html_e('Progress Bar Color Manageable :- You could manage progress bar colors from plugin settings according to your theme layout.','wp-rate-and-review-products');?></li>
     13                <li><?php esc_html_e('Plugin Auto disable if woocommerce not installed.','wp-rate-and-review-products');?></li>
     14
    1315            </ul>
    1416        <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
  • wp-rate-and-review/trunk/readme.txt

    r2143294 r2144904  
    44Tags: woocommerce, woocommerce rating, woocommerce review, woocommerce rating progress bar, rating progress bar
    55Requires at least: 5.2
    6 Stable tag: 1.0.2
     6Stable tag: 1.0.0
    77Requires PHP: 5.6
    88Tested up to: 5.2
     
    4141== Changelog ==
    4242
     43= 1.0.3 =
     44* Show product summary using shortcode.
     45
    4346= 1.0.2 =
    4447* fixed summary show.
    45 
    4648
    4749= 1.0.1 =
  • wp-rate-and-review/trunk/wp-rate-and-review-products.php

    r2143292 r2144904  
    33 * Plugin Name: WP Rate And Review
    44 * Description: A WooCommerce Add-on which provides complete feature to show your rating and review with progressbar.
    5  * Version: 1.0.2
     5 * Version: 1.0.3
    66 * Author: K.Kumar
    77 * Author URI: https://profiles.wordpress.org/krishna121/
     
    2222        function __construct(){
    2323
    24 
    2524            $check_wooEnable = $this->wcrr_check_woo_enable();
    26 
    2725            if($check_wooEnable){
    2826                $this->wcrr_setup_plugin();
     
    3533
    3634            $enable= false;
    37 
    3835            $enable = in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) );
    3936            if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
     
    6764        }
    6865
    69 
    7066        function wcrr_frontend_hook(){
    7167            add_filter( 'comments_template', array( $this, 'wcrr_enhance_review_rating' ) );
    7268            add_action( 'wp_enqueue_scripts', array($this,'wcrr_theme_name_scripts' ));
    73 
    74         }
    75 
    76 
     69            add_shortcode('wp_rate_review', array($this,'wcrr_review_markup_via_shortcode'));
     70        }
    7771
    7872        function wcrr_backend_hook(){
     
    157151
    158152        }
    159 
    160153
    161154        function wcrr_plugin_overview(){
     
    318311        }
    319312
    320         function wcrr_get_number_ratings($rating_number){
    321 
    322             global $wpdb,$product;
     313        function wcrr_review_markup_via_shortcode($atts){
     314            $html='';
     315
     316            $atts = shortcode_atts( array(
     317                    'product_id' => '',
     318                ), $atts );
     319
     320            $product_id = isset($atts['product_id']) ? $atts['product_id'] : null;
     321
     322            if($product_id){
     323                $html=$this->wcrr_prepare_review_markup($product_id);
     324            }
     325            return $html;
     326        }
     327
     328        function wcrr_get_number_ratings($rating_number,$product_id){
     329
     330            global $wpdb;
     331
    323332            $no_of_ratings = $wpdb->get_var(
    324333                $wpdb->prepare(
     
    330339                AND comment_approved = '1'
    331340                AND meta_value = %d
    332             ", $product->get_id(),$rating_number)
     341            ", $product_id,$rating_number)
    333342            );
    334343
    335344            return $no_of_ratings;
    336345        }
    337        
    338         function wcrr_enhance_review_rating($html){
    339 
    340                 global $product,$post;
     346
     347
     348        function wcrr_prepare_review_markup($product_id){
     349
    341350                $plugin_settings = maybe_unserialize(get_option('wcr_options_group'));
    342351                $wp_enable_progress_bar = (!empty($plugin_settings['wp_enable_progress_bar'])) ? true:false;
    343352                $wp_enable_number_rating = (!empty($plugin_settings['wp_enable_number_rating'])) ? true:false;
    344353
    345 
    346354                if(empty($plugin_settings['wp_enable_rate_review']))
    347355                    return;
     
    350358                    return;
    351359
    352                 $is_product_single = ($post->post_type =='product' && is_single()) ? true : false;
    353 
    354                 if(!$is_product_single)
    355                     return;
    356360
    357361               if(!empty($plugin_settings['wphp_exclude_products']) && in_array($post->ID, $plugin_settings['wphp_exclude_products'])) 
    358362                  return;
    359363
     364                $product = new WC_Product($product_id);
    360365
    361366                $wp_pbar_bg_color = (!empty($plugin_settings['wp_pbar_bg_color'])) ?$plugin_settings['wp_pbar_bg_color']:'';
    362367                $wp_pbar_fill_color = (!empty($plugin_settings['wp_pbar_fill_color'])) ?$plugin_settings['wp_pbar_fill_color']:'';
    363368               
    364 
    365369                $total_review_count = $product->get_review_count();
    366370                $rating_count = $product->get_rating_count();
    367371                $average      = $product->get_average_rating();
    368                 $no_of_ratings_for_one_star = $this->wcrr_get_number_ratings(1);
    369                 $no_of_ratings_for_two_stars = $this->wcrr_get_number_ratings(2);
    370                 $no_of_ratings_for_three_stars = $this->wcrr_get_number_ratings(3);
    371                 $no_of_ratings_for_four_stars = $this->wcrr_get_number_ratings(4);
    372                 $no_of_ratings_for_five_stars = $this->wcrr_get_number_ratings(5);
    373 
     372
     373
     374                $html='';
    374375                if($rating_count){
    375                 $html='';
    376                 $html.='<div class="wcrrp_product_review_wrapper">
    377                             <h1>'.esc_html__('Ratings & Reviews','wp-rate-and-review-products').'</h1>
    378                                 <div class="wcrr_average_review_rating">
    379                                     <div>'.$average.'</div>
    380                                     <span>'.$rating_count.' Ratings</span>
    381                                     <span> & </span>
    382                                     <span>'.$total_review_count.' Reviews</span>
    383                                 </div>
    384                                 <div class="wcrr_total_review_rating">';
    385                                 for ($i=5; $i >= 1; $i--) {
    386                                     $no_of_ratings_for_star = $this->wcrr_get_number_ratings($i);
    387                                     $html.='<div class="wcrr_rating_wrapper"><em>'.$i.esc_html__(' *','wp-rate-and-review-products').' </em>';
    388                                     $width = ($no_of_ratings_for_star/$rating_count)*100;
    389                                     if($wp_enable_progress_bar){
    390                                         $html.='<div class="w3-light-grey">
    391                                           <div class="w3-grey" style="width:'.$width.'%"></div>
    392                                         </div>';
     376                    $html.='<div class="wcrrp_product_review_wrapper">
     377                                <h1>'.esc_html__('Ratings & Reviews','wp-rate-and-review-products').'</h1>
     378                                    <div class="wcrr_average_review_rating">
     379                                        <div>'.$average.'</div>
     380                                        <span>'.$rating_count.' Ratings</span>
     381                                        <span> & </span>
     382                                        <span>'.$total_review_count.' Reviews</span>
     383                                    </div>
     384                                    <div class="wcrr_total_review_rating">';
     385                                    for ($i=5; $i >= 1; $i--) {
     386                                        $no_of_ratings_for_star = $this->wcrr_get_number_ratings($i,$product_id);
     387                                        $html.='<div class="wcrr_rating_wrapper"><em>'.$i.esc_html__(' *','wp-rate-and-review-products').' </em>';
     388                                        $width = ($no_of_ratings_for_star/$rating_count)*100;
     389                                        if($wp_enable_progress_bar){
     390                                            $html.='<div class="w3-light-grey">
     391                                              <div class="w3-grey" style="width:'.$width.'%"></div>
     392                                            </div>';
     393                                        }
     394                                        if($wp_enable_number_rating){
     395                                            $html.='<span class="no_of_ratings_for_star">'.$no_of_ratings_for_star.'</span>';
     396
     397                                        }
     398                                        $html.='</div><br>';
    393399                                    }
    394                                     if($wp_enable_number_rating){
    395                                         $html.='<span class="no_of_ratings_for_star">'.$no_of_ratings_for_star.'</span>';
    396 
    397                                     }
    398                                     $html.='</div><br>';
    399                                 }
    400                 $html.='</div></div>';
    401                 echo $html;
    402 
     400                    $html.='</div></div>';
    403401                }
     402                return $html;
     403        }
     404       
     405        function wcrr_enhance_review_rating($html){
     406
     407                global $product,$post;
     408
     409                $is_product_single = ($post->post_type =='product' && is_single()) ? true : false;
     410
     411                if(!$is_product_single)
     412                    return;
     413
     414                echo do_shortcode('[wp_rate_review product_id="'.$post->ID.'"]');
    404415
    405416        }
Note: See TracChangeset for help on using the changeset viewer.