Changeset 3009 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
- Timestamp:
- 04/26/2016 07:33:28 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r2998 r3009 22 22 add_action( 'init', array( $this, 'init' ) ); 23 23 add_action( 'init', array( $this, 'register_shortcodes' ) ); 24 add_action( 'widgets_init', array( $this, 'register_widgets' ) ); 24 25 add_filter( 'post_type_link', array( $this, 'package_link' ), 10, 2 ); 25 26 add_filter( 'pre_insert_term', array( $this, 'pre_insert_term_prevent' ) ); … … 32 33 33 34 // Shim in postmeta support for data which doesn't yet live in postmeta 34 add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 4);35 add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 3 ); 35 36 36 37 // Load the API routes … … 196 197 } 197 198 199 public function register_widgets() { 200 register_widget( __NAMESPACE__ . '\Widgets\Metadata' ); 201 register_widget( __NAMESPACE__ . '\Widgets\Ratings' ); 202 } 203 198 204 /** 199 205 * Upon plugin activation, set up the current site for acting … … 423 429 * @param int $object_id Object ID. 424 430 * @param string $meta_key Meta key. 425 * @param bool $single Whether to return only the first value of the specified $meta_key. 426 */ 427 public function filter_shim_postmeta( $value, $object_id, $meta_key, $single ) { 431 */ 432 public function filter_shim_postmeta( $value, $object_id, $meta_key ) { 428 433 switch ( $meta_key ) { 429 434 case 'downloads': … … 431 436 $count = Template::get_downloads_count( $post ); 432 437 433 return $single ? $count :array( $count );438 return array( $count ); 434 439 break; 435 440 case 'rating': … … 441 446 $rating = wporg_get_rating_avg( 'plugin', $post->post_name ); 442 447 443 return $single ? $rating : array( $rating ); 448 return array( $rating ); 449 break; 450 case 'ratings': 451 $post = get_post( $object_id ); 452 if ( ! function_exists( 'wporg_get_rating_counts' ) ) { 453 break; 454 } 455 $ratings = wporg_get_rating_counts( 'plugin', $post->post_name ); 456 457 return array( $ratings ); 444 458 break; 445 459 }
Note: See TracChangeset
for help on using the changeset viewer.