Making WordPress.org


Ignore:
Timestamp:
06/07/2018 04:32:31 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: Use WPORG_Ratings for the plugin rating/ratings when available.

Fixes #2606.

File:
1 edited

Legend:

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

    r7075 r7282  
    231231        $post = get_post( $post );
    232232
    233         $rating      = get_post_meta( $post->ID, 'rating', true ) ?: 0;
    234         $ratings     = get_post_meta( $post->ID, 'ratings', true ) ?: array();
     233        if ( class_exists( '\WPORG_Ratings' ) ) {
     234            $rating  = \WPORG_Ratings::get_avg_rating( 'plugin', $post->post_name ) ?: 0;
     235            $ratings = \WPORG_Ratings::get_rating_counts( 'plugin', $post->post_name ) ?: array();
     236        } else {
     237            $rating  = get_post_meta( $post->ID, 'rating', true ) ?: 0;
     238            $ratings = get_post_meta( $post->ID, 'ratings', true ) ?: array();
     239        }
     240
    235241        $num_ratings = array_sum( $ratings );
    236242
Note: See TracChangeset for help on using the changeset viewer.