Changeset 2991
- Timestamp:
- 04/21/2016 05:57:55 AM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php
r2986 r2991 199 199 */ 200 200 public function column_downloads( $post ) { 201 if ( ! empty( $this->plugin_meta->downloaded ) ) { 202 echo number_format_i18n( $this->plugin_meta->downloaded ); 203 } 201 echo number_format_i18n( get_post_meta( $post->ID, 'downloads', true ) ); 204 202 } 205 203 -
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. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r2986 r2991 20 20 21 21 /** 22 * @param \WP_Post|int $post Optional. 23 * @return int 24 */ 25 static function get_downloads_count( $post = null ) { 26 $post = get_post( $post ); 27 28 if ( false === ( $count = wp_cache_get( $post->ID, 'plugin_download_count' ) ) ) { 29 global $wpdb; 30 31 // TODO: While the plugin ZIPs are still being served by bbPress, the download stats are stored there. 32 $count = $wpdb->get_var( $wpdb->prepare( "SELECT downloads FROM `" . PLUGINS_TABLE_PREFIX . "download_counts` WHERE topic_id = (SELECT topic_id FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE topic_slug = %s )", $post->post_name ) ); 33 34 wp_cache_set( $post->ID, $count, 'plugin_download_count', HOUR_IN_SECONDS ); 35 } 36 37 return (int) $count; 38 } 39 40 /** 22 41 * @return int 23 42 */ … … 26 45 global $wpdb; 27 46 28 $count = $wpdb->get_var( "SELECT SUM(downloads) FROM ` plugin_2_stats`" );29 wp_cache_ add( 'plugin_download_count', $count, 'plugin_download_count', DAY_IN_SECONDS );47 $count = $wpdb->get_var( "SELECT SUM(downloads) FROM `" . PLUGINS_TABLE_PREFIX . "stats`" ); 48 wp_cache_set( 'plugin_download_count', $count, 'plugin_download_count', DAY_IN_SECONDS ); 30 49 } 31 50
Note: See TracChangeset
for help on using the changeset viewer.