Changeset 3327
- Timestamp:
- 06/09/2016 11:03:34 PM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r3324 r3327 425 425 'plugin', 'side' 426 426 ); 427 428 if ( current_user_can( 'plugin_add_committer', $post ) ) { 429 add_meta_box( 430 'plugin-stats', 431 __( 'Plugin Stats', 'wporg-plugins' ), 432 array( __NAMESPACE__ . '\Metabox\Stats', 'display' ), 433 'plugin', 'normal' 434 ); 435 } 427 436 } 428 437 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-stats.php
r3221 r3327 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 use WordPressdotorg\Plugin_Directory; 4 use WordPressdotorg\Plugin_Directory\Template;5 4 6 5 /** … … 12 11 13 12 /** 14 * @global \wpdb $wpdb WordPress database abstraction object.15 13 * 16 14 * @return string 17 15 */ 18 16 static function display() { 19 global $wpdb;20 21 17 $post = get_post(); 22 18 … … 33 29 ) ); 34 30 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>'; 69 33 } 70 34 }
Note: See TracChangeset
for help on using the changeset viewer.