Changeset 6287 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/quick-stats.php
- Timestamp:
- 12/19/2017 04:22:37 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/quick-stats.php
r6261 r6287 20 20 $_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH ); 21 21 22 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';22 require rtrim( $opts['abspath'], '/' ) . '/wp-load.php'; 23 23 24 24 if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) { … … 26 26 if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) { 27 27 fwrite( STDERR, "Run the following command instead:\n" ); 28 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . " --url ". get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );28 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . ' --url ' . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" ); 29 29 } 30 30 die(); … … 38 38 function display_top_table( $stats, $n = 20 ) { 39 39 40 $top = array_slice( $stats, 0, $n );40 $top = array_slice( $stats, 0, $n ); 41 41 $tail = array_slice( $stats, $n ); 42 42 43 43 foreach ( $top as $row ) { 44 #$vals = array_values( (array) $row );44 // $vals = array_values( (array) $row ); 45 45 echo $row[0] . "\t\t\t" . number_format( $row[1] ) . "\n"; 46 46 } 47 47 48 echo "Top $n Total: " . number_format( array_reduce( $top, __NAMESPACE__ .'\callback_sum' ) ) . "\n";48 echo "Top $n Total: " . number_format( array_reduce( $top, __NAMESPACE__ . '\callback_sum' ) ) . "\n"; 49 49 50 50 $tail_n = count( $tail ); 51 echo "Other $tail_n: " . number_format( array_reduce( $tail, __NAMESPACE__ .'\callback_sum' ) ) . "\n";51 echo "Other $tail_n: " . number_format( array_reduce( $tail, __NAMESPACE__ . '\callback_sum' ) ) . "\n"; 52 52 53 53 } 54 54 55 function tested_to_summary( $pfx_where = '1=1') {55 function tested_to_summary( $pfx_where = '1=1' ) { 56 56 global $wpdb; 57 57 … … 61 61 } 62 62 63 $where = $wpdb->prepare( "post_status = %s", 'publish' );63 $where = $wpdb->prepare( 'post_status = %s', 'publish' ); 64 64 65 if ( !empty( $opts['age'] ) && strtotime( $opts['age'] ) > 0 ) 66 $where .= $wpdb->prepare( " AND post_modified >= %s", strftime( '%Y-%m-%d', strtotime( $opts['age'] ) ) ); 65 if ( ! empty( $opts['age'] ) && strtotime( $opts['age'] ) > 0 ) { 66 $where .= $wpdb->prepare( ' AND post_modified >= %s', strftime( '%Y-%m-%d', strtotime( $opts['age'] ) ) ); 67 } 67 68 68 // TODO: add some more reports, and a CLI argument for choosing them69 // TODO: add some more reports, and a CLI argument for choosing them 69 70 display_top_table( tested_to_summary( $where ) );
Note: See TracChangeset
for help on using the changeset viewer.