コード例 #1
0
 /**
  * Dispatcher function.  All requests enter through here
  * and are routed based upon the p3_action request variable
  * @return void
  */
 public static function dispatcher()
 {
     // If there's a scan, create a viewer object
     if (!empty(self::$scan)) {
         try {
             self::$profile = new P3_Profiler_Reader(self::$scan);
         } catch (P3_Profiler_No_Data_Exception $e) {
             echo '<div class="error"><p>' . sprintf(__('No visits recorded during this profiling session.  Check the <a href="%s">help</a> page for more information', 'p3-profiler'), add_query_arg(array('p3_action' => 'help', 'current_scan' => null)) . '#q-circumvent-cache"') . '</p></div>';
             self::$scan = null;
             self::$profile = null;
             self::$action = 'list-scans';
         } catch (Exception $e) {
             echo '<div class="error"><p>' . __('Error reading scan', 'p3-profiler') . '</p></div>';
         }
     } else {
         self::$profile = null;
     }
     // Usability message
     if (!defined('WPP_PROFILING_STARTED')) {
         echo '<div class="updated usability-msg"><p>' . __('Click "Start Scan" to run a performance scan of your website.', 'p3-profiler') . '</p></div>';
     }
     // Load the list table, let it handle any bulk actions
     if (empty(self::$profile) && in_array(self::$action, array('list-scans', 'current-scan'))) {
         self::$scan_table = new P3_Profiler_Table();
         self::$scan_table->prepare_items();
     }
     // Load scripts & styles
     self::load_scripts();
     self::load_styles();
     // Show the page
     require_once P3_PATH . '/templates/template.php';
 }