Changeset 2991 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
- Timestamp:
- 04/21/2016 05:57:55 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
r2985 r2991 29 29 30 30 add_filter( 'map_meta_cap', array( __NAMESPACE__ . '\Capabilities', 'map_meta_cap' ), 10, 4 ); 31 32 // Shim in postmeta support for data which doesn't yet live in postmeta 33 add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 4 ); 31 34 32 35 // Load the API routes … … 405 408 } 406 409 410 411 /** 412 * Shim in some postmeta values which get retrieved from other locations temporarily. 413 * 414 * @param null|array|string $value The value get_metadata() should return - a single metadata value, 415 * or an array of values. 416 * @param int $object_id Object ID. 417 * @param string $meta_key Meta key. 418 * @param bool $single Whether to return only the first value of the specified $meta_key. 419 */ 420 public function filter_shim_postmeta( $value, $object_id, $meta_key, $single ) { 421 switch ( $meta_key ) { 422 case 'downloads': 423 $post = get_post( $object_id ); 424 $count = Template::get_downloads_count( $post ); 425 426 return $single ? $count : array( $count ); 427 break; 428 } 429 return $value; 430 } 431 407 432 /** 408 433 * Returns an array of pages based on section comments in the content.
Note: See TracChangeset
for help on using the changeset viewer.