Changeset 3040128
- Timestamp:
- 02/23/2024 09:53:30 AM (2 years ago)
- Location:
- reviews-sorted/trunk
- Files:
-
- 5 edited
-
README.txt (modified) (2 diffs)
-
functions/do.php (modified) (8 diffs)
-
functions/review.php (modified) (3 diffs)
-
reviews-sorted.php (modified) (1 diff)
-
templates/reviews-slider.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
reviews-sorted/trunk/README.txt
r3025635 r3040128 4 4 Tags: review, schema.org, rating, schema, user rating, google rating, star rating, product review 5 5 Requires at least: 5.6 6 Tested up to: 6.4. 27 Requires PHP: 7. 28 Stable tag: 2.3. 76 Tested up to: 6.4.3 7 Requires PHP: 7.4 8 Stable tag: 2.3.8 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 107 107 == Changelog == 108 108 109 = v2.3.8 (Feb 23, 2024) = 110 * Resolved issues on rating percentage calculation based on backend settings. 111 109 112 = v2.3.7 (Jan 23, 2024) = 110 113 * Resolved issues and incorporated suggestions. -
reviews-sorted/trunk/functions/do.php
r2986785 r3040128 93 93 94 94 wp_send_json_error(); 95 95 96 96 } else { 97 97 98 98 // process form data 99 99 foreach ($_REQUEST as &$param) { … … 127 127 128 128 function reviews_slider($atts){ 129 129 130 130 $options = shortcode_atts( array( 131 131 'space' => 20, … … 146 146 147 147 $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 151 151 152 152 $template = 'reviews-slider-'. $options['layout'] .'.php'; … … 162 162 163 163 $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 166 167 return ReviewsSortedCommon::get_template( 'reviews-average.php', ['settings' => $settings, 'reviews' => $reviews,'data' => $data, 'atts'=> $atts] ); 167 168 } … … 246 247 $reviews = $RS_Review->query([$RS_Review::STATUS_PUBLISHED]); 247 248 $data = $RS_Review->get_total([$RS_Review::STATUS_PUBLISHED]); 248 249 249 250 250 251 $template = 'reviews-testimonials-'. $options['layout'] .'.php'; … … 264 265 $row_key = 'icon_for_'. $i .'_star'; 265 266 $image_id = isset($settings[$icon_key]) ? intval($settings[$row_key]) : 0; 266 267 267 268 if( $image = wp_get_attachment_image_src( $image_id ) ) { 268 269 $icons[] = 'url(' . esc_url($image[0]) . ')'; … … 279 280 .reviews-sorted{ 280 281 <?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']); ?>; 282 283 <?php endif; ?> 283 284 } … … 295 296 } 296 297 297 .reviews-sorted .rs-custom-icons.rs-rating::before{display:none;}298 .reviews-sorted .rs-custom-icons.rs-rating::before{display:none;} 298 299 299 300 .reviews-sorted .rs-bg-rating:after { 300 301 background: #ccc; 301 302 -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 329 343 } 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 338 345 } 339 346 340 </style>341 <?php342 }343 344 }345 346 347 ReviewsSortedFrontend::get_instance(); -
reviews-sorted/trunk/functions/review.php
r2986785 r3040128 5 5 const STATUS_PUBLISHED = 'Published'; 6 6 const STATUS_DECLINED = 'Declined'; 7 const RATING = '5.0'; 7 8 const LIMIT_PER_PAGE = 20; 9 const LIMIT_PER_PAGEL = 999999; 8 10 9 11 protected $fillable = []; … … 164 166 } 165 167 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 166 198 function get_total($status = []){ 167 199 global $wpdb; … … 174 206 175 207 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]; 176 241 } 177 242 -
reviews-sorted/trunk/reviews-sorted.php
r3025635 r3040128 6 6 * Author: Reviews Sorted 7 7 * Author URI: https://reviewssorted.com/ 8 * Version: 2.3. 78 * Version: 2.3.8 9 9 * Text Domain: reviews-sorted 10 10 * Domain Path: /languages -
reviews-sorted/trunk/templates/reviews-slider.php
r3003574 r3040128 45 45 <!-- Slides --> 46 46 <?php foreach($reviews as $review): ?> 47 <?php if($review->status == 'Published'){ ?> 47 48 <div class="swiper-slide"> 48 49 <div class="inner"> … … 72 73 </div> 73 74 </div><!-- .swiper-slide --> 75 <?php } ?> 74 76 <?php endforeach; ?> 75 77 </div><!-- .swiper-wrapper -->
Note: See TracChangeset
for help on using the changeset viewer.