Exemple #1
0
 public function reports_page()
 {
     global $user_ID, $current_user, $wp_post_types, $wpdb;
     if (Word_Stats_State::is_worker_needed()) {
         _e('Stats collection hasn\'t completed yet. Try again later.', 'word-stats');
         return false;
     }
     # Relevant when going straight to the graphs page right after installing the plugin.
     if (isset($_GET['view-all'])) {
         $period_start = '1900-01-01';
         $period_end = date('Y-m-d');
     } else {
         $period_start = isset($_GET['period-start']) ? $_GET['period-start'] : date('Y-m-d', time() - 15552000);
         $period_end = isset($_GET['period-end']) ? $_GET['period-end'] : date('Y-m-d');
     }
     $author_graph = isset($_GET['author-tab']) ? intval($_GET['author-tab']) : $user_ID;
     $report = Word_Stats_Admin::load_report_stats($author_graph, $period_start, $period_end);
     if ($report) {
         # Get oldest date (for the graph)
         if (isset($_GET['view-all'])) {
             $period_start = date('Y-m-d', min(bst_Ym_to_unix(bst_array_first($report['author_count'][$author_graph]['post'])), bst_Ym_to_unix(bst_array_first($report['author_count'][$author_graph]['page'])), bst_Ym_to_unix(bst_array_first($report['author_count'][$author_graph]['custom']))));
         }
         include 'graph-options.php';
         $diagnostic_tables = Word_Stats_Admin::diagnostics_tables($report);
         include 'view-report-graphs.php';
     } else {
         _e('Sorry, word counting failed for an unknown reason.', 'word-stats');
     }
 }