Changeset 3187 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
- Timestamp:
- 05/19/2016 10:20:54 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r3186 r3187 62 62 63 63 return (int) $count; 64 } 65 66 /** 67 * Displays a plugin's rating with the amount of ratings it has received. 68 * 69 * @param \WP_Post|int $post 70 * @return string 71 */ 72 public static function get_star_rating( $post = 0 ) { 73 $post = get_post( $post ); 74 75 $rating = get_post_meta( $post->ID, 'rating', true ) ?: 0; 76 $ratings = get_post_meta( $post->ID, 'ratings', true ) ?: array(); 77 $num_ratings = array_sum( $ratings ); 78 79 return '<div class="plugin-rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">' . 80 '<meta itemprop="ratingCount" content="' . esc_attr( $num_ratings ) . '"/>' . 81 '<meta itemprop="ratingValue" content="' . esc_attr( $rating ) . '"/>' . 82 Template::dashicons_stars( $rating ) . 83 '<span class="rating-count">(' . esc_html( $num_ratings ) . ')</span>' . 84 '</div>'; 64 85 } 65 86
Note: See TracChangeset
for help on using the changeset viewer.