diff --git wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
index 9d679a035..9acbffa46 100644
|
|
class Tools { |
74 | 74 | return $reviews; |
75 | 75 | } |
76 | 76 | |
| 77 | /** |
| 78 | * Returns the replies for a list reviews. |
| 79 | * |
| 80 | * @static |
| 81 | * @global \wpdb $wpdb WordPress database abstraction object. |
| 82 | * |
| 83 | * @param string[] $topic_ids List of topic ids. |
| 84 | * @return array |
| 85 | */ |
| 86 | public static function get_reviews_replies( $topic_ids ) { |
| 87 | |
| 88 | if( empty( $topic_ids ) ) { |
| 89 | return []; |
| 90 | } |
| 91 | |
| 92 | $topics_string = implode( ',', $topic_ids ); |
| 93 | $cache_slug = "reviews_{$topics_string}_replies"; |
| 94 | $replies = wp_cache_get( $cache_slug, 'plugin-reviews' ); |
| 95 | |
| 96 | if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) && false === $replies ) { |
| 97 | global $wpdb; |
| 98 | |
| 99 | $placeholders = array_fill(0, count( $topic_ids ), '%d'); |
| 100 | $ph = implode(', ', $placeholders); |
| 101 | |
| 102 | $query = "SELECT * FROM " . $wpdb->base_prefix . WPORG_SUPPORT_FORUMS_BLOGID . "_posts p |
| 103 | WHERE p.post_type = 'reply' AND p.post_parent IN ( $ph ) AND p.post_status = 'publish'"; |
| 104 | |
| 105 | $replies = $wpdb->get_results( $wpdb->prepare( $query, $topic_ids ) ); |
| 106 | |
| 107 | wp_cache_set( $cache_slug, $replies, 'plugin-reviews', HOUR_IN_SECONDS ); |
| 108 | } |
| 109 | |
| 110 | return $replies; |
| 111 | } |
| 112 | |
77 | 113 | /** |
78 | 114 | * Retrieve a list of users who have commit to a specific plugin. |
79 | 115 | * |
diff --git wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-reviews.php wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-reviews.php
index 049a66d92..e5deab69b 100644
|
|
class Reviews { |
16 | 16 | */ |
17 | 17 | static function display() { |
18 | 18 | $reviews = Tools::get_plugin_reviews( get_post()->post_name ); |
| 19 | $replies = Tools::get_reviews_replies( wp_list_pluck( $reviews, 'ID' ) ); |
19 | 20 | $ratings = get_post_meta( get_the_ID(), 'ratings', true ) ?: array(); |
20 | 21 | $review_count = array_sum( $ratings ); |
21 | 22 | |
… |
… |
class Reviews { |
39 | 40 | foreach ( $reviews as $review ) { |
40 | 41 | $GLOBALS['post'] = $review; // Override the_post(); |
41 | 42 | setup_postdata( $review ); |
| 43 | $reply_matches = wp_list_filter( $replies, [ 'post_parent' => $review->ID ] ); |
| 44 | $reply_count = Count( $reply_matches ); |
| 45 | |
42 | 46 | ?> |
43 | 47 | <article class="plugin-review"> |
44 | 48 | <div class="review-avatar"> |
… |
… |
class Reviews { |
47 | 51 | <header> |
48 | 52 | <div class="header-top"> |
49 | 53 | <?php echo Template::dashicons_stars( $review->post_rating ); ?> |
50 | | <h3 class="review-title"><a class="url" href="<?php echo esc_url( 'https://wordpress.org/support/topic/' . $review->post_name . '/' ); ?>"><?php echo get_the_title( $review ); ?></a></h3> |
| 54 | <h3 class="review-title"> |
| 55 | <a class="url" href="<?php echo esc_url( 'https://wordpress.org/support/topic/' . $review->post_name . '/' ); ?>"><?php echo get_the_title( $review ); ?></a> |
| 56 | <span class="review-title-comments"> |
| 57 | <?php printf( _n( '%s comment', '%s comments', $reply_count, 'wporg-plugins' ), number_format_i18n( $reply_count ) ); ?> |
| 58 | </span> |
| 59 | </h3> |
51 | 60 | </div> |
52 | 61 | <div class="header-bottom"> |
53 | 62 | <span class="review-author author vcard"><?php the_author_posts_link(); ?></span> |
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/sections/reviews/style.scss wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/sections/reviews/style.scss
index 6244018a5..a76a7ad21 100644
|
|
|
49 | 49 | line-height: 1.25; |
50 | 50 | } |
51 | 51 | |
| 52 | .review-title-comments { |
| 53 | padding-left: 8px; |
| 54 | font-size: 13px; |
| 55 | font-weight: normal; |
| 56 | font-style: italic; |
| 57 | color: #666; |
| 58 | } |
| 59 | |
52 | 60 | .review-author, |
53 | 61 | .review-date { |
54 | 62 | line-height: 1.25; |