Making WordPress.org


Ignore:
Timestamp:
04/20/2016 11:59:45 AM (10 years ago)
Author:
dd32
Message:

Plugin Directory: Use the new stat fields introduced with r2985.

See #1596

File:
1 edited

Legend:

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

    r2621 r2986  
    1010
    1111        /**
    12          * @param string $plugin_slug
     12         * @param \WP_Post|int $post Optional.
    1313         * @return int
    1414         */
    15         static function get_active_installs_count( $plugin_slug ) {
    16                 if ( false === ( $count = wp_cache_get( $plugin_slug, 'plugin_active_installs' ) ) ) {
    17                         global $wpdb;
    18 
    19                         $count = (int) $wpdb->get_var( $wpdb->prepare(
    20                                 "SELECT count FROM rev2_daily_stat_summary WHERE type = 'plugin' AND type_name = %s AND stat = 'active_installs' LIMIT 1",
    21                                 $plugin_slug
    22                         ) );
    23                         wp_cache_add( $plugin_slug, $count, 'plugin_active_installs', 1200 );
    24                 }
    25 
    26                 if ( $count < 10 ) {
    27                         return 0;
    28                 }
    29 
    30                 if ( $count >= 1000000 ) {
    31                         return 1000000;
    32                 }
    33 
    34                 return strval( $count )[0] * pow( 10, floor( log10( $count ) ) );
     15        static function get_active_installs_count( $post = null ) {
     16                $post = get_post( $post );
     17
     18                return get_post_meta( $post->ID, 'active_installs', true );
    3519        }
    3620
Note: See TracChangeset for help on using the changeset viewer.