Making WordPress.org

Changeset 2986


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

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

See #1596

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php

    r2927 r2986  
    142142        $this->plugin_meta = \plugins_api( 'plugin_information', array(
    143143            'slug'   => $post->post_name,
    144             'fields' => array( 'active_installs' => true ),
    145144        ) );
    146145        ?>
     
    184183     */
    185184    public function column_installs( $post ) {
    186         if ( ! empty( $this->plugin_meta->active_installs ) ) {
    187             echo number_format_i18n( $this->plugin_meta->active_installs ) . '+';
     185        $active_installs = get_post_meta( $post->ID, 'active_installs', true );
     186        if ( $active_installs >= 1000000 ) {
     187            _e( '1+ million', 'wporg-plugins' );
     188        } elseif ( $active_installs <= 10 ) {
     189            _e( 'Less than 10', 'wporg-plugins' );
     190        } else {
     191            printf( "%s+", number_format_i18n( $active_installs ) );
    188192        }
    189193    }
     
    206210     */
    207211    public function column_support( $post ) {
    208         $resolutions = get_post_meta( $post->ID, 'support_resolutions', true );
    209         $unresolved  = empty( $resolutions ) ? 0 : $resolutions['no'];
    210         $link_text   = sprintf( __( '%d unresolved', 'wporg-plugins' ), $unresolved );
     212        $threads    = get_post_meta( $post->ID, 'support_threads', true );
     213        $resolved   = get_post_meta( $post->ID, 'support_threads_resolved', true );
     214        $unresolved = max( 0, $threads - $resolved );
     215        $link_text  = sprintf( __( '%d unresolved', 'wporg-plugins' ), $unresolved );
    211216
    212217        printf( '<a href="%s">%s</a>', esc_url( 'https://wordpress.org/support/plugin/' . $post->post_name ), $link_text );
  • 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
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r2983 r2986  
    183183                'header_textdomain'   => $this->plugin['TextDomain'],
    184184                'header_description'  => $this->plugin['Description'],
    185                 'support_resolutions' => 0,
     185                'support_threads'     => 0,
     186                'support_threads_resolved' => 0,
    186187            ),
    187188        ) );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-tags.php

    r2612 r2986  
    3535
    3636function worg_plugins_template_active_installs( $full = true ) {
    37     $count = WordPressdotorg\Plugin_Directory\Template::get_active_installs_count( get_post()->post_name );
     37    $count = WordPressdotorg\Plugin_Directory\Template::get_active_installs_count();
    3838
    39     if ( ! $count ) {
     39    if ( $count <= 10 ) {
    4040        $text = __( 'Less than 10', 'wporg-plugins' );
    4141    } elseif ( $count >= 1000000 ) {
Note: See TracChangeset for help on using the changeset viewer.