Plugin Directory

Changeset 3040128


Ignore:
Timestamp:
02/23/2024 09:53:30 AM (2 years ago)
Author:
eurisko
Message:

v2.3.8 (Feb 23, 2024)

  • Resolved issues on rating percentage calculation based on backend settings.
Location:
reviews-sorted/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • reviews-sorted/trunk/README.txt

    r3025635 r3040128  
    44Tags: review, schema.org, rating, schema, user rating, google rating, star rating, product review
    55Requires at least: 5.6
    6 Tested up to: 6.4.2
    7 Requires PHP: 7.2
    8 Stable tag: 2.3.7
     6Tested up to: 6.4.3
     7Requires PHP: 7.4
     8Stable tag: 2.3.8
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    107107== Changelog ==
    108108
     109= v2.3.8 (Feb 23, 2024) =
     110* Resolved issues on rating percentage calculation based on backend settings.
     111
    109112= v2.3.7 (Jan 23, 2024) =
    110113* Resolved issues and incorporated suggestions.
  • reviews-sorted/trunk/functions/do.php

    r2986785 r3040128  
    9393           
    9494            wp_send_json_error();
    95        
     95           
    9696        } else {
    97        
     97           
    9898            // process form data
    9999            foreach ($_REQUEST as &$param) {
     
    127127
    128128    function reviews_slider($atts){
    129    
     129       
    130130        $options = shortcode_atts( array(
    131131            'space'         => 20,
     
    146146       
    147147        $settings   = ReviewsSortedCommon::get_options();
    148         $reviews    = $RS_Review->query([$RS_Review::STATUS_PUBLISHED]);
    149         $data       = $RS_Review->get_total([$RS_Review::STATUS_PUBLISHED]);
    150            
     148        $reviews    = $RS_Review->custom_query([$RS_Review::STATUS_PUBLISHED]);
     149        $data       = $RS_Review->get_custom_total([$RS_Review::STATUS_PUBLISHED]);
     150       
    151151
    152152        $template = 'reviews-slider-'. $options['layout'] .'.php';
     
    162162       
    163163        $settings   = ReviewsSortedCommon::get_options();   
    164         $data       = $RS_Review->get_total([$RS_Review::STATUS_PUBLISHED]);
    165         $reviews    = $RS_Review->query([$RS_Review::STATUS_PUBLISHED]);
     164        $data       = $RS_Review->get_custom_total([$RS_Review::STATUS_PUBLISHED]);
     165        $reviews    = $RS_Review->custom_query([$RS_Review::STATUS_PUBLISHED]);
     166       
    166167        return ReviewsSortedCommon::get_template( 'reviews-average.php', ['settings' => $settings, 'reviews' => $reviews,'data' => $data, 'atts'=> $atts] );
    167168    }
     
    246247        $reviews    = $RS_Review->query([$RS_Review::STATUS_PUBLISHED]);
    247248        $data       = $RS_Review->get_total([$RS_Review::STATUS_PUBLISHED]);
    248            
     249       
    249250
    250251        $template = 'reviews-testimonials-'. $options['layout'] .'.php';
     
    264265            $row_key = 'icon_for_'. $i .'_star';
    265266            $image_id = isset($settings[$icon_key]) ? intval($settings[$row_key]) : 0;
    266                        
     267           
    267268            if( $image = wp_get_attachment_image_src( $image_id ) ) {               
    268269                $icons[] = 'url(' . esc_url($image[0]) . ')';
     
    279280            .reviews-sorted{
    280281                <?php if(isset($settings['star_color'])): ?>
    281                 --star-background: <?php echo esc_html($settings['star_color']); ?>;
     282                    --star-background: <?php echo esc_html($settings['star_color']); ?>;
    282283                <?php endif; ?>
    283284            }
     
    295296            }
    296297
    297             .reviews-sorted .rs-custom-icons.rs-rating::before{display:none;}
     298            .reviews-sorted .rs-custom-icons.rs-rating::before{display:none;}
    298299
    299300            .reviews-sorted .rs-bg-rating:after {
    300301                background: #ccc;
    301302                -webkit-filter: grayscale(100%);
    302     filter: grayscale(100%);
    303             }
    304 
    305             .star-icons-gray, .star-icons{
    306                 display: flex;
    307                 column-gap: 1px;
    308                 align-items: center;
    309                 justify-content: center;
    310             }
    311 
    312             .star-icons-gray span, .star-icons span {
    313                 background-color: var(--star-background);
    314             }
    315                
    316             .star-icons-gray img, span.star-icons img{
    317                 width: 34px;
    318                 padding: 3px 5px 0px 5px;
    319                 height: 28px;
    320             }
    321 
    322             .star-icons-gray img, span.star-icons img{
    323              filter: grayscale(100%);
    324             }
    325 
    326             .star-icons-gray .rs-star-active img, span.star-icons .rs-star-active img{filter: grayscale(0);}
    327             .rs-rating.rs-custom-icons {
    328     font-size: 25px !important;position: relative;
     303                filter: grayscale(100%);
     304            }
     305
     306            .star-icons-gray, .star-icons{
     307             display: flex;
     308             column-gap: 1px;
     309             align-items: center;
     310             justify-content: center;
     311         }
     312
     313         .star-icons-gray span, .star-icons span {
     314            background-color: var(--star-background);
     315        }
     316       
     317        .star-icons-gray img, span.star-icons img{
     318            width: 34px;
     319            padding: 3px 5px 0px 5px;
     320            height: 28px;
     321        }
     322
     323        .star-icons-gray img, span.star-icons img{
     324            filter: grayscale(100%);
     325        }
     326
     327        .star-icons-gray .rs-star-active img, span.star-icons .rs-star-active img{filter: grayscale(0);}
     328        .rs-rating.rs-custom-icons {
     329            font-size: 25px !important;position: relative;
     330        }
     331        .reviews-average .star-icons {
     332            position: absolute;
     333            top: 0;
     334            width: calc(var(--rating) / 5 * 100%);
     335            overflow: hidden;
     336            padding-left: var(--left-spacing);
     337            transform: translateX(var(--left-pspacing));
     338            left: 50%;
     339        }
     340
     341    </style>
     342    <?php
    329343}
    330 .reviews-average .star-icons {
    331     position: absolute;
    332     top: 0;
    333     width: calc(var(--rating) / 5 * 100%);
    334     overflow: hidden;
    335     padding-left: var(--left-spacing);
    336     transform: translateX(var(--left-pspacing));
    337         left: 50%;
     344
    338345}
    339346
    340         </style>
    341         <?php
    342     }
    343    
    344 }
    345 
    346347ReviewsSortedFrontend::get_instance();
  • reviews-sorted/trunk/functions/review.php

    r2986785 r3040128  
    55    const STATUS_PUBLISHED  = 'Published';
    66    const STATUS_DECLINED   = 'Declined';
     7    const RATING            = '5.0';
    78    const LIMIT_PER_PAGE    = 20;
     9    const LIMIT_PER_PAGEL    = 999999;
    810
    911    protected $fillable     = [];
     
    164166    }
    165167
     168    /**
     169     * Custom query function for frontend
     170     *
     171     * @since 2.3.8
     172     */
     173    function custom_query($status = []){
     174
     175        global $wpdb;
     176       
     177        $status       = implode("','", $status);
     178        $settings = get_option('reviews_sorted_settings', []);
     179   
     180        $paged = isset($_GET['paged']) ? intval($_GET['paged']) : 1;
     181        $limit = self::LIMIT_PER_PAGEL;
     182        $months = strtolower($settings['rating_month_label']);
     183   
     184        $rating_status = self::RATING;
     185        $start_date = date('Y-m-d', strtotime('-'.$months));
     186        $end_date = date('Y-m-d');
     187   
     188        $start = ($paged-1)*$limit;
     189   
     190        $sql     = "SELECT * FROM {$wpdb->prefix}reviews WHERE rating IN ('{$rating_status}') AND created_at BETWEEN '{$start_date}' AND '{$end_date}'";
     191        //$sql     = "SELECT * FROM {$wpdb->prefix}reviews WHERE rating IN ('{$rating_status}') AND created_at BETWEEN '{$start_date}' AND '{$end_date}' AND status IN ('{$status}')";
     192       
     193        $results = $wpdb->get_results( $sql, OBJECT );
     194   
     195        return $results;
     196    }
     197
    166198    function get_total($status = []){
    167199        global $wpdb;
     
    174206
    175207        return ['totalReviews' => $totalReviews, 'totalRatings' => $totalRatings];
     208    }
     209
     210    /**
     211     * Custom query function for frontend
     212     *
     213     * @since 2.3.8
     214     */
     215    function get_custom_total($status = []){
     216        global $wpdb;
     217        $settings = get_option('reviews_sorted_settings', []);
     218   
     219        // $status       = count($status) ? $status : [self::STATUS_PENDING, self::STATUS_PUBLISHED, self::STATUS_DECLINED];
     220        // $status       = implode("','", $status);
     221   
     222        $paged = isset($_GET['paged']) ? intval($_GET['paged']) : 1;
     223        $limit = self::LIMIT_PER_PAGEL;
     224        $start = ($paged-1)*$limit;
     225        $months = strtolower($settings['rating_month_label']);
     226   
     227        $rating_status = self::RATING;
     228        $start_date = date('Y-m-d', strtotime('-'.$months));
     229        $end_date = date('Y-m-d');
     230
     231        $totalReviews = $wpdb->get_var( "SELECT count(*) FROM {$wpdb->prefix}reviews WHERE rating IN ('{$rating_status}') AND created_at BETWEEN '{$start_date}' AND '{$end_date}'" );
     232   
     233        // $totalRatingss = $wpdb->get_var( "SELECT SUM(rating) FROM {$wpdb->prefix}reviews WHERE rating IN ('{$rating_status}') AND created_at BETWEEN '{$start_date}' AND '{$end_date}'" );
     234        // $totalRatings = number_format($totalRatingss);
     235       
     236        //$totalReviews = $wpdb->get_var( "SELECT count(*) FROM {$wpdb->prefix}reviews WHERE created_at BETWEEN '{$start_date}' AND '{$end_date}'" );
     237       
     238        $totalRatings = $wpdb->get_var( "SELECT SUM(rating) FROM {$wpdb->prefix}reviews WHERE created_at BETWEEN '{$start_date}' AND '{$end_date}'" );
     239   
     240          return ['totalReviews' => $totalReviews, 'totalRatings' => $totalRatings];
    176241    }
    177242
  • reviews-sorted/trunk/reviews-sorted.php

    r3025635 r3040128  
    66 * Author: Reviews Sorted
    77 * Author URI: https://reviewssorted.com/
    8  * Version: 2.3.7
     8 * Version: 2.3.8
    99 * Text Domain: reviews-sorted
    1010 * Domain Path: /languages
  • reviews-sorted/trunk/templates/reviews-slider.php

    r3003574 r3040128  
    4545            <!-- Slides -->
    4646            <?php foreach($reviews as $review): ?>
     47                <?php if($review->status == 'Published'){ ?>
    4748                <div class="swiper-slide">
    4849                    <div class="inner">
     
    7273                    </div>
    7374                </div><!-- .swiper-slide -->
     75                <?php } ?>
    7476            <?php endforeach; ?>
    7577        </div><!-- .swiper-wrapper -->
Note: See TracChangeset for help on using the changeset viewer.