Plugin Directory

Changeset 3384483


Ignore:
Timestamp:
10/25/2025 02:28:46 PM (5 months ago)
Author:
ivole
Message:

5.86.1

Location:
customer-reviews-woocommerce
Files:
876 added
7 edited

Legend:

Unmodified
Added
Removed
  • customer-reviews-woocommerce/trunk/class-ivole.php

    r3382233 r3384483  
    8585
    8686class Ivole {
    87     const CR_VERSION = '5.86.0';
     87    const CR_VERSION = '5.86.1';
    8888
    8989    public function __construct() {
  • customer-reviews-woocommerce/trunk/includes/blocks/class-cr-all-reviews.php

    r3372938 r3384483  
    675675                // Load gallery scripts on product pages only if supported.
    676676                if ( ! $disable_lightbox ) {
    677                     $this->enqueue_wc_script( 'photoswipe-ui-default' );
     677                    $this->enqueue_wc_script( 'wc-photoswipe-ui-default' );
    678678                    $this->enqueue_wc_style( 'photoswipe-default-skin' );
    679679                    add_action( 'wp_footer', array( $this, 'cr_photoswipe' ) );
  • customer-reviews-woocommerce/trunk/includes/blocks/class-cr-reviews-slider.php

    r3330640 r3384483  
    4949            $max_reviews = $attributes['count'];
    5050            $order_by = $attributes['sort_by'] === 'date' ? 'comment_date_gmt' : 'rating';
    51             $order = $attributes['sort'];
     51            $order = strtoupper( $attributes['sort'] );
    5252            $inactive_products = $attributes['inactive_products'];
    5353            $avatars = 'initials';
     
    5858                    $avatars = 'standard';
    5959                }
     60            }
     61            if ( 'RAND' === $order ) {
     62                $order_by = $order;
    6063            }
    6164
     
    165168                add_filter( 'comments_clauses', array( $this, 'min_chars_comments_clauses' ) );
    166169            }
    167             if( 'RAND' === $order ) {
    168                 $all_product_reviews = get_comments( $args );
    169                 $count_all_product_reviews = count( $all_product_reviews );
    170                 if (
    171                     0 < $count_all_product_reviews &&
    172                     0 < $max_reviews
    173                 ) {
    174                     $max_reviews = ( $count_all_product_reviews < $max_reviews ) ? $count_all_product_reviews : $max_reviews;
    175                     $random_keys = array_rand( $all_product_reviews, $max_reviews );
    176                     if( is_array( $random_keys ) ) {
    177                         for( $i = 0; $i < $max_reviews; $i++ ) {
    178                             $reviews[] = $all_product_reviews[$random_keys[$i]];
    179                         }
    180                     } else {
    181                         $reviews[] = $all_product_reviews[$random_keys];
    182                     }
    183                 }
    184             } else {
    185                 if( 0 < $max_reviews ) {
    186                     $args['order'] = $order;
    187                     $args['number'] = $max_reviews;
    188                     $reviews = get_comments( $args );
    189                 }
     170            // Query needs to be modified if random sorting is required
     171            if ( 'RAND' === $order ) {
     172                add_filter( 'comments_clauses', array( $this, 'random_order_comments_clauses' ), 10, 2 );
     173            }
     174            if ( 0 < $max_reviews ) {
     175                $args['order'] = $order;
     176                $args['number'] = $max_reviews;
     177                $reviews = get_comments( $args );
    190178            }
    191179
     
    207195                    }
    208196                    $shop_reviews = [];
    209                     if( 'RAND' === $order ) {
    210                         $all_shop_reviews = get_comments( $args_s );
    211                         $count_all_shop_reviews = count( $all_shop_reviews );
    212                         if( 0 < $count_all_shop_reviews ) {
    213                             $max_shop_reviews = ( $count_all_shop_reviews < $max_shop_reviews ) ? $count_all_shop_reviews : $max_shop_reviews;
    214                             $random_keys = array_rand( $all_shop_reviews, $max_shop_reviews );
    215                             if( is_array( $random_keys ) ) {
    216                                 for( $i = 0; $i < $max_shop_reviews; $i++ ) {
    217                                     $shop_reviews[] = $all_shop_reviews[$random_keys[$i]];
    218                                 }
    219                             } else {
    220                                 $shop_reviews[] = $all_shop_reviews[$random_keys];
    221                             }
    222                         }
    223                     } else {
    224                         if( 0 < $max_shop_reviews ) {
    225                             $args_s['order'] = $order;
    226                             $args_s['number'] = $max_shop_reviews;
    227                             $shop_reviews = get_comments( $args_s );
    228                         }
    229                     }
    230 
    231                     if( is_array( $reviews ) && is_array( $shop_reviews ) ) {
     197                    if ( 0 < $max_shop_reviews ) {
     198                        $args_s['order'] = $order;
     199                        $args_s['number'] = $max_shop_reviews;
     200                        $shop_reviews = get_comments( $args_s );
     201                    }
     202
     203                    if ( is_array( $reviews ) && is_array( $shop_reviews ) ) {
    232204                        $reviews = array_merge( $reviews, $shop_reviews );
    233205                        CR_Reviews_Slider::$sort_order_by = $order_by;
     
    238210            }
    239211            remove_filter( 'comments_clauses', array( $this, 'min_chars_comments_clauses' ) );
     212            remove_filter( 'comments_clauses', array( $this, 'random_order_comments_clauses' ), 10 );
    240213
    241214            // WPML compatibility
     
    505478        public function min_chars_comments_clauses( $clauses ) {
    506479            global $wpdb;
    507 
    508480            $clauses['where'] .= " AND CHAR_LENGTH({$wpdb->comments}.comment_content) >= " . $this->min_chars;
    509 
     481            return $clauses;
     482        }
     483
     484        public function random_order_comments_clauses( $clauses, $comment_query ) {
     485            global $wpdb;
     486            if ( ! empty( $comment_query->query_vars['orderby'] ) && 'RAND' === $comment_query->query_vars['orderby'] ) {
     487                $clauses['orderby'] = 'RAND()';
     488            }
    510489            return $clauses;
    511490        }
  • customer-reviews-woocommerce/trunk/includes/import-export/class-cr-import-reviews.php

    r3382233 r3384483  
    861861                                $fileDesc = sprintf( __( 'Review of %s by %s', 'customer-reviews-woocommerce' ), $reviewedItem, $customerName );
    862862                                $customerUserId = $line_obj->user_id ? $line_obj->user_id : 0;
    863                                 $reviewId = sprintf( __( 'Review ID: %s', 'customer-reviews-woocommerce' ), $review_id );
    864                                 $mediaId = media_handle_sideload( $file_array, $line_obj->comment_post_ID, $fileDesc, array( 'post_author' => $customerUserId, 'post_date' => $review_obj->comment_date, 'post_content' => $reviewId ) );
     863                                $reviewId = sprintf( __( 'Review ID: %s', 'customer-reviews-woocommerce' ), $line_id );
     864                                $mediaId = media_handle_sideload( $file_array, $line_obj->comment_post_ID, $fileDesc, array( 'post_author' => $customerUserId, 'post_date' => $line_obj->comment_date, 'post_content' => $reviewId ) );
    865865                                if ( is_wp_error( $mediaId ) ) {
    866866                                    $results['errors']++;
     
    868868                                } else {
    869869                                    if ( wp_attachment_is( 'image', $mediaId ) ) {
    870                                         add_comment_meta( $review_id, CR_Reviews::REVIEWS_META_LCL_IMG, $mediaId, false );
     870                                        add_comment_meta( $line_id, CR_Reviews::REVIEWS_META_LCL_IMG, $mediaId, false );
    871871                                    } else if( wp_attachment_is( 'video', $mediaId ) ) {
    872                                         add_comment_meta( $review_id, CR_Reviews::REVIEWS_META_LCL_VID, $mediaId, false );
     872                                        add_comment_meta( $line_id, CR_Reviews::REVIEWS_META_LCL_VID, $mediaId, false );
    873873                                    } else {
    874874                                        $results['errors']++;
  • customer-reviews-woocommerce/trunk/includes/reviews/class-cr-reviews.php

    r3372938 r3384483  
    385385                $assets_version = Ivole::CR_VERSION;
    386386                if( ! $this->disable_lightbox ) {
    387                     wp_enqueue_script( 'photoswipe-ui-default' );
     387                    wp_enqueue_script( 'wc-photoswipe-ui-default' );
    388388                    wp_enqueue_style( 'photoswipe-default-skin' );
    389389                }
  • customer-reviews-woocommerce/trunk/ivole.php

    r3382233 r3384483  
    44Description: Customer Reviews for WooCommerce plugin helps you get more customer reviews for your shop by sending automated reminders and coupons.
    55Plugin URI: https://wordpress.org/plugins/customer-reviews-woocommerce/
    6 Version: 5.86.0
     6Version: 5.86.1
    77Author: CusRev
    88Author URI: https://www.cusrev.com/business/
     
    1111Requires at least: 4.5
    1212WC requires at least: 3.6
    13 WC tested up to: 10.2
     13WC tested up to: 10.3
    1414License: GPLv3
    1515
  • customer-reviews-woocommerce/trunk/readme.txt

    r3382233 r3384483  
    55Tested up to: 6.8
    66Requires PHP: 7.2
    7 Stable tag: 5.86.0
     7Stable tag: 5.86.1
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl.html
     
    234234== Changelog ==
    235235
     236= 5.86.1 =
     237* Bug fix: media files were uploaded to the Media Library but not attached to reviews during import
     238* Bug fix: random sorting in [cusrev_reviews_slider] shortcode didn't work correctly in some scenarios
    236239= 5.86.0 =
    237240* New feature: include replies to reviews when importing reviews
Note: See TracChangeset for help on using the changeset viewer.