Making WordPress.org


Ignore:
Timestamp:
10/31/2016 02:47:42 AM (10 years ago)
Author:
dd32
Message:

Plugin Directory: Pull reviews from bbPress2 rather than the old bbPress1 support forums.

See #1579

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php

    r4214 r4311  
    4545         * @return array|false
    4646         */
    47         public static function get_plugin_reviews( $plugin_slug ) {
    48                 if ( false === ( $reviews = wp_cache_get( "{$plugin_slug}_reviews", 'wporg-plugins' ) ) ) {
     47        public static function get_plugin_reviews( $plugin_slug, $number = 2 ) {
     48                $number = absint( $number );
     49                if ( $number < 1 || $number > 100 ) {
     50                        $number = 2;
     51                }
     52                if ( false === ( $reviews = wp_cache_get( "{$plugin_slug}_last{$number}_reviews", 'wporg-plugins' ) ) ) {
    4953                        global $wpdb;
    5054
    51                         $reviews = $wpdb->get_results( $wpdb->prepare( "
    52                         SELECT posts.post_text AS post_content, topics.topic_title AS post_title, ratings.rating AS post_rating, ratings.user_id AS post_author
    53                         FROM ratings
    54                                 INNER JOIN minibb_topics AS topics ON ( ratings.review_id = topics.topic_id )
    55                                 INNER JOIN minibb_posts AS posts ON ( ratings.review_id = posts.topic_id )
    56                         WHERE
    57                                 ratings.object_type = 'plugin' AND
    58                                 ratings.object_slug = %s AND
    59                                 posts.post_position = 1 AND
    60                                 topics.topic_status = 0 AND
    61                                 topics.topic_sticky = 0
    62                         ORDER BY ratings.review_id DESC LIMIT 2", $plugin_slug ) );
    63 
    64                         wp_cache_set( "{$plugin_slug}_reviews", $reviews, 'wporg-plugins', HOUR_IN_SECONDS );
     55                        $reviews = $wpdb->get_results( $wpdb->prepare(
     56                        "SELECT
     57                                        post_content, post_title, post_author, post_modified,
     58                                        r.rating as post_rating
     59                        FROM ratings r
     60                                LEFT JOIN wporg_419_posts p ON r.post_id = p.ID
     61                        WHERE r.object_type = 'plugin' AND r.object_slug = %s AND p.post_status = 'publish'
     62                        ORDER BY r.review_id DESC
     63                        LIMIT %d", $plugin_slug, $number ) );
     64
     65                        wp_cache_set( "{$plugin_slug}_last{$number}_reviews", $reviews, 'wporg-plugins', HOUR_IN_SECONDS );
    6566                }
    6667
Note: See TracChangeset for help on using the changeset viewer.