Making WordPress.org

Changeset 9486


Ignore:
Timestamp:
02/11/2020 01:32:11 AM (5 years ago)
Author:
dd32
Message:

Plugin Directory: Schema: Use WPORG_Ratings when fetching the review details for a plugin (when possible), the post-meta isn't always up-to-date.

Fixes #5021.

File:
1 edited

Legend:

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

    r9473 r9486  
    6464     */
    6565    protected static function plugin_json_jd_schema( $plugin ) {
    66         $rating      = get_post_meta( $plugin->ID, 'rating', true ) ?: 0;
    67         $ratings     = get_post_meta( $plugin->ID, 'ratings', true ) ?: [];
     66        if ( class_exists( '\WPORG_Ratings' ) ) {
     67            $rating  = \WPORG_Ratings::get_avg_rating( 'plugin', $plugin->post_name ) ?: 0;
     68            $ratings = \WPORG_Ratings::get_rating_counts( 'plugin', $plugin->post_name ) ?: [];
     69        } else {
     70            $rating  = get_post_meta( $plugin->ID, 'rating', true ) ?: 0;
     71            $ratings = get_post_meta( $plugin->ID, 'ratings', true ) ?: [];
     72        }
     73
    6874        $num_ratings = array_sum( $ratings );
    6975        $banners     = self::get_plugin_banner( $plugin );
Note: See TracChangeset for help on using the changeset viewer.