Making WordPress.org


Ignore:
Timestamp:
06/09/2016 11:03:34 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Move download stats to wp-admin.

Download stats are not terribly useful to users.

See #1596.

File:
1 edited

Legend:

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

    r3221 r3327  
    22namespace WordPressdotorg\Plugin_Directory\Shortcodes;
    33use WordPressdotorg\Plugin_Directory;
    4 use WordPressdotorg\Plugin_Directory\Template;
    54
    65/**
     
    1211
    1312    /**
    14      * @global \wpdb $wpdb WordPress database abstraction object.
    1513     *
    1614     * @return string
    1715     */
    1816    static function display() {
    19         global $wpdb;
    20 
    2117        $post = get_post();
    2218
     
    3329        ) );
    3430
    35         $today     = $wpdb->get_var( $wpdb->prepare( "SELECT downloads FROM " . PLUGINS_TABLE_PREFIX . "stats WHERE stamp >= %s AND plugin_slug = %s", gmdate( 'Y-m-d' ), $post->post_name ) );
    36         $yesterday = $wpdb->get_var( $wpdb->prepare( "SELECT downloads FROM " . PLUGINS_TABLE_PREFIX . "stats WHERE stamp >= %s AND stamp < %s AND plugin_slug = %s",
    37             gmdate( 'Y-m-d', time() - DAY_IN_SECONDS ), gmdate( 'Y-m-d' ), $post->post_name
    38         ) );
    39         $last_week = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(downloads) FROM " . PLUGINS_TABLE_PREFIX . "stats WHERE stamp >= %s AND plugin_slug = %s",
    40             gmdate( 'Y-m-d', time() - WEEK_IN_SECONDS ), $post->post_name
    41         ) );
    42 
    43         return
    44             '<h5>' . __( 'Active versions', 'wporg-plugins' ) . '</h5>' .
    45             '<div id="plugin-version-stats" class="chart"></div>' .
    46 
    47             '<h5>' . __( 'Downloads Per Day', 'wporg-plugins' ) . '</h5>' .
    48             '<div id="plugin-download-stats" class="chart"></div>' .
    49 
    50             '<h5>' . __( 'Downloads history', 'wporg-plugins' ) . '</h5>' .
    51             '<table>' .
    52                 '<tr>' .
    53                     '<th scope="row">' . __( 'Today', 'wporg-plugins' ) . '</th>' .
    54                     '<td>' . number_format_i18n( $today ) . '</td>' .
    55                 '</tr>' .
    56                 '<tr>' .
    57                     '<th scope="row">' . __( 'Yesterday', 'wporg-plugins' ) . '</th>' .
    58                     '<td>' . number_format_i18n( $yesterday ) . '</td>' .
    59                 '</tr>' .
    60                 '<tr>' .
    61                     '<th scope="row">' . __( 'Last Week', 'wporg-plugins' ) . '</th>'.
    62                     '<td>' . number_format_i18n( $last_week ) . '</td>'.
    63                 '</tr>' .
    64                 '<tr>' .
    65                     '<th scope="row">' . __( 'All Time', 'wporg-plugins' ) . '</th>' .
    66                     '<td>' . number_format_i18n( Template::get_downloads_count( $post ) ) . '</td>' .
    67                 '</tr>'.
    68             '</table>';
     31        return '<h5>' . __( 'Active versions', 'wporg-plugins' ) . '</h5>' .
     32            '<div id="plugin-version-stats" class="chart"></div>';
    6933    }
    7034}
Note: See TracChangeset for help on using the changeset viewer.