Making WordPress.org


Ignore:
Timestamp:
09/15/2019 04:47:58 PM (6 years ago)
Author:
tellyworth
Message:

Plugin directory: calculate and update author average ratings for block plugins.

File:
1 edited

Legend:

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

    r9127 r9140  
    222222        $result['block_assets'] = get_post_meta( $post_id, 'block_files', true ) ?: [];
    223223        $result['author_block_count'] = get_post_meta( $post_id, 'author_block_count' ) ?: intval( count( $result['blocks'] ) > 0 );
    224         $result['author_block_rating'] = get_post_meta( $post_id, 'author_block_rating' ) ?: $result['rating'];
     224        // Fun fact: ratings are stored as 1-5 in postmeta, but returned as percentages by the API
     225        $result['author_block_rating'] = get_post_meta( $post_id, 'author_block_rating' ) ? 20 * get_post_meta( $post_id, 'author_block_rating' ) : $result['rating'];
    225226
    226227        // That's all folks!
Note: See TracChangeset for help on using the changeset viewer.