P3 (Plugin Performance Profiler) - Version 1.1.2

Version Description

Fix a few bugs reported by users. Upgrading is optional if this plugin is working well for you.

Download this release

Release Info

Developer StarfieldTech
Plugin Icon wp plugin P3 (Plugin Performance Profiler)
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

.htaccess DELETED
@@ -1 +0,0 @@
1
- Options -Indexes
 
class.p3-profile-reader.php CHANGED
@@ -335,7 +335,7 @@ if ( !defined('P3_PATH') )
335
  * @return string
336
  */
337
  private function _get_theme_name( $theme ) {
338
- if ( function_exists( 'get_theme_data' ) ) {
339
  $theme_info = get_theme_data( WP_CONTENT_DIR . '/themes/' . $theme . '/style.css' );
340
  if ( !empty( $theme_info ) && !empty( $theme_info['Name'] ) ) {
341
  return $theme_info['Name'];
335
  * @return string
336
  */
337
  private function _get_theme_name( $theme ) {
338
+ if ( function_exists( 'get_theme_data' ) && file_exists( WP_CONTENT_DIR . '/themes/' . $theme . '/style.css' ) ) {
339
  $theme_info = get_theme_data( WP_CONTENT_DIR . '/themes/' . $theme . '/style.css' );
340
  if ( !empty( $theme_info ) && !empty( $theme_info['Name'] ) ) {
341
  return $theme_info['Name'];
class.p3-profile-table.php CHANGED
@@ -217,11 +217,7 @@ EOD;
217
  }
218
  }
219
  $count = count( $_REQUEST['scan'] );
220
- if ( $count == 1 ) {
221
- $p3_profiler_plugin->add_notice( "Deleted $count scan." );
222
- } else {
223
- $p3_profiler_plugin->add_notice( "Deleted $count scans." );
224
- }
225
  }
226
  }
227
 
217
  }
218
  }
219
  $count = count( $_REQUEST['scan'] );
220
+ printf('<div id="updated"><p>Deleted %d %s.</p></div>', $count, ($count == 1) ? 'scan' : 'scans' );
 
 
 
 
221
  }
222
  }
223
 
class.p3-profiler.php CHANGED
@@ -129,7 +129,7 @@ class P3_Profiler {
129
  return $this;
130
  }
131
  $found = false;
132
- foreach ( (array) $p3_json as $k => $v ) {
133
  if ( 0 === strpos( $_SERVER['REQUEST_URI'], $v->site_url ) && preg_match( '/' . $v->ip . '/', $this->get_ip() ) ) {
134
  $found = true;
135
  break;
@@ -140,8 +140,8 @@ class P3_Profiler {
140
  }
141
 
142
  // Kludge memory limit / time limit
143
- ini_set( 'memory_limit', '128M' );
144
- set_time_limit( 90 );
145
 
146
  // Set the profile file
147
  $this->_profile_filename = $v->name . '.json';
@@ -310,6 +310,13 @@ class P3_Profiler {
310
  } else {
311
  $file = $_SERVER['SCRIPT_FILENAME'];
312
  }
 
 
 
 
 
 
 
313
  unset( $bt );
314
 
315
  // Is it a plugin?
@@ -534,7 +541,7 @@ class P3_Profiler {
534
  ( FALSE !== strpos( $_SERVER['SCRIPT_FILENAME'], '/themes/' ) || FALSE !== stripos( $_SERVER['SCRIPT_FILENAME'], '\\themes\\' ) ) &&
535
  (
536
  FALSE !== strpos( $_SERVER['SCRIPT_FILENAME'], '/' . basename( WP_CONTENT_DIR ) . '/' ) ||
537
- FALSE !== stripos( $file, '\\' . basename( WP_CONTENT_DIR ) . '\\' )
538
  )
539
  ) {
540
  $this->_profile['runtime'] = array(
@@ -601,7 +608,7 @@ class P3_Profiler {
601
  if ( !empty( $_SERVER['REQUEST_URI'] ) ) {
602
  $file = '';
603
  $query_string = '';
604
- $path = $_SERVER['REQUEST_URI'];
605
  } else {
606
  $file = '';
607
  if ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
@@ -615,7 +622,7 @@ class P3_Profiler {
615
  }
616
  $query_string = '';
617
  if ( !empty( $_SERVER['QUERY_STRING'] ) ) {
618
- $query_string = '?' . $_SERVER['QUERY_STRING'];
619
  }
620
  }
621
  return $protocol.$domain.$file.$path.$query_string;
129
  return $this;
130
  }
131
  $found = false;
132
+ foreach ( (array) $p3_json as $v ) {
133
  if ( 0 === strpos( $_SERVER['REQUEST_URI'], $v->site_url ) && preg_match( '/' . $v->ip . '/', $this->get_ip() ) ) {
134
  $found = true;
135
  break;
140
  }
141
 
142
  // Kludge memory limit / time limit
143
+ @ini_set( 'memory_limit', '128M' );
144
+ @set_time_limit( 90 );
145
 
146
  // Set the profile file
147
  $this->_profile_filename = $v->name . '.json';
310
  } else {
311
  $file = $_SERVER['SCRIPT_FILENAME'];
312
  }
313
+
314
+ // Check for "eval()'d code"
315
+ if ( strpos( $file, "eval()'d" ) ) {
316
+ list($file, $junk) = explode(': eval(', $str, 2);
317
+ $file = preg_replace('/\(\d*\)$/', '', $file);
318
+ }
319
+
320
  unset( $bt );
321
 
322
  // Is it a plugin?
541
  ( FALSE !== strpos( $_SERVER['SCRIPT_FILENAME'], '/themes/' ) || FALSE !== stripos( $_SERVER['SCRIPT_FILENAME'], '\\themes\\' ) ) &&
542
  (
543
  FALSE !== strpos( $_SERVER['SCRIPT_FILENAME'], '/' . basename( WP_CONTENT_DIR ) . '/' ) ||
544
+ FALSE !== stripos( $_SERVER['SCRIPT_FILENAME'], '\\' . basename( WP_CONTENT_DIR ) . '\\' )
545
  )
546
  ) {
547
  $this->_profile['runtime'] = array(
608
  if ( !empty( $_SERVER['REQUEST_URI'] ) ) {
609
  $file = '';
610
  $query_string = '';
611
+ $path = preg_replace( '/[?&]P3_NOCACHE=[a-zA-Z0-9]+/', '', $_SERVER['REQUEST_URI'] );
612
  } else {
613
  $file = '';
614
  if ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
622
  }
623
  $query_string = '';
624
  if ( !empty( $_SERVER['QUERY_STRING'] ) ) {
625
+ $query_string = '?' . preg_replace( '/[?&]P3_NOCACHE=[a-zA-Z0-9]+/', '', $_SERVER['QUERY_STRING'] );
626
  }
627
  }
628
  return $protocol.$domain.$file.$path.$query_string;
css/p3.css CHANGED
@@ -277,7 +277,12 @@ p3-glossary-container {
277
  /** Copyright notice **/
278
  #p3-copyright {
279
  text-align: center;
280
- margin: 45px auto 5px auto;
 
 
 
 
 
281
  }
282
  #p3-copyright img {
283
  margin-bottom: 7px;
@@ -353,3 +358,22 @@ div.p3-question h2.p3-help-question {
353
  margin-top: -15px;
354
  border-bottom: 1px solid #cccccc;
355
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  /** Copyright notice **/
278
  #p3-copyright {
279
  text-align: center;
280
+ position: absolute;
281
+ float: left;
282
+ margin-top: 45px;
283
+ margin-left: -158px;
284
+ width: 315px;
285
+ left: 50%;
286
  }
287
  #p3-copyright img {
288
  margin-bottom: 7px;
358
  margin-top: -15px;
359
  border-bottom: 1px solid #cccccc;
360
  }
361
+
362
+
363
+ /** Did you liek this plugin? **/
364
+ div#p3-reminder {
365
+ position: relative;
366
+ z-index: 10;
367
+ float: left;
368
+ bottom: 0;
369
+ left: 0;
370
+ height: 75px;
371
+ width: 200px;
372
+ margin-top: 30px;
373
+ }
374
+ div#p3-reminder-wrapper {
375
+ border: 1px solid #eaeaea;
376
+ padding: 8px 4px 0px 4px;
377
+ text-align: center;
378
+ background-color: #f0f8fe;
379
+ }
p3-profiler.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: P3 (Plugin Performance Profiler)
4
  Plugin URI: http://support.godaddy.com/godaddy/wordpress-p3-plugin/
5
  Description: See which plugins are slowing down your site. Create a profile of your WordPress site's plugins' performance by measuring their impact on your site's load time.
6
  Author: GoDaddy.com
7
- Version: 1.1.1
8
  Author URI: http://www.godaddy.com/
9
  */
10
 
@@ -73,7 +73,6 @@ register_activation_hook( P3_PATH . DIRECTORY_SEPARATOR . 'p3-profiler.php', arr
73
  register_deactivation_hook( P3_PATH . DIRECTORY_SEPARATOR . 'p3-profiler.php', array( $p3_profiler_plugin, 'deactivate' ) );
74
  register_uninstall_hook( P3_PATH . DIRECTORY_SEPARATOR . 'p3-profiler.php', array( 'P3_Profiler_Plugin', 'uninstall' ) );
75
  if ( function_exists( 'is_multisite' ) && is_multisite() ) {
76
- add_action( 'wpmu_add_blog', array( $p3_profiler_plugin, 'add_blog' ) );
77
  add_action( 'wpmu_delete_blog', array( $p3_profiler_plugin, 'delete_blog' ) );
78
  }
79
 
@@ -91,7 +90,25 @@ class P3_Profiler_Plugin {
91
  * @var P3_Profile_Table
92
  */
93
  public $scan_table = null;
 
 
 
 
 
 
94
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  /**
96
  * Remove the admin bar from the customer site when profiling is enabled
97
  * to prevent skewing the numbers, as much as possible. Also prevent ssl
@@ -207,9 +224,47 @@ class P3_Profiler_Plugin {
207
 
208
  // Only for our page
209
  if ( isset( $_REQUEST['page'] ) && basename( __FILE__ ) == $_REQUEST['page'] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  // Load the list table, let it handle any bulk actions
211
- $this->scan_table = new P3_Profile_Table();
212
- $this->scan_table->prepare_items();
 
 
213
 
214
  // Usability message
215
  if ( !defined( 'WPP_PROFILING_STARTED' ) ) {
@@ -221,15 +276,10 @@ class P3_Profiler_Plugin {
221
  /**
222
  * Dispatcher function. All requests enter through here
223
  * and are routed based upon the p3_action request variable
224
- * @uses $_REQUEST['p3_action']
225
  * @return void
226
  */
227
  public function dispatcher() {
228
- $p3_action = '';
229
- if ( ! empty ( $_REQUEST ['p3_action'] ) ) {
230
- $p3_action = $_REQUEST ['p3_action'];
231
- }
232
- switch ( $p3_action ) {
233
  case 'list-scans' :
234
  $this->list_scans();
235
  break;
@@ -249,6 +299,29 @@ class P3_Profiler_Plugin {
249
  $this->scan_settings_page();
250
  }
251
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
  /**
254
  * Write .profiling_enabled file, uses request_filesystem_credentials, if
@@ -268,10 +341,12 @@ class P3_Profiler_Plugin {
268
 
269
  // Ask for credentials, if necessary
270
  if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, $form_fields ) ) ) {
 
271
  return true;
272
  } elseif ( ! WP_Filesystem($creds) ) {
273
  // The credentials are bad, ask again
274
  request_filesystem_credentials( $url, $method, true, false, $form_fields );
 
275
  return true;
276
  } else {
277
  // Once we get here, we should have credentials, do the file system operations
@@ -438,6 +513,7 @@ class P3_Profiler_Plugin {
438
 
439
  // Save the new options
440
  update_option( 'p3-profiler_disable_opcode_cache', 'true' == $_POST['p3_disable_opcode_cache'] );
 
441
  update_option( 'p3-profiler_use_current_ip', 'true' == $_POST['p3_use_current_ip'] );
442
  update_option( 'p3-profiler_ip_address', $_POST['p3_ip_address'] );
443
 
@@ -605,7 +681,7 @@ class P3_Profiler_Plugin {
605
  public function show_notices() {
606
 
607
  // Skip notices if we're fixing the flag file
608
- if ( isset( $_REQUEST['p3_action'] ) && 'fix-flag-file' == $_REQUEST['p3_action'] ) {
609
  return true;
610
  }
611
 
@@ -622,7 +698,7 @@ class P3_Profiler_Plugin {
622
  }
623
 
624
  // Check that we can write .profiling_enabled
625
- if ( isset( $_REQUEST['page'] ) && basename( __FILE__ ) == $_REQUEST['page'] && ( !isset( $_REQUEST['p3_action'] ) || 'fix-flag-file' != $_REQUEST['p3_action'] ) ) {
626
  if ( !file_exists( P3_FLAG_FILE ) || !is_writable( P3_FLAG_FILE ) ) {
627
  @touch( P3_FLAG_FILE );
628
  if ( !file_exists( P3_FLAG_FILE ) || !is_writable( P3_FLAG_FILE ) ) {
@@ -663,7 +739,7 @@ class P3_Profiler_Plugin {
663
 
664
  // mu-plugins doesn't exist
665
  if ( !file_exists( WPMU_PLUGIN_DIR ) && is_writable( WPMU_PLUGIN_DIR . '/../' ) ) {
666
- $flag = wp_mkdir_p( WPMU_PLUGIN_DIR );
667
  }
668
  if ( file_exists( WPMU_PLUGIN_DIR ) && is_writable( WPMU_PLUGIN_DIR ) ) {
669
  file_put_contents(
@@ -754,6 +830,7 @@ class P3_Profiler_Plugin {
754
  delete_option( 'p3-profiler_use_current_ip' );
755
  delete_option( 'p3-profiler_ip_address' );
756
  delete_option( 'p3-profiler_version' );
 
757
  }
758
  restore_current_blog();
759
  } else {
@@ -764,6 +841,7 @@ class P3_Profiler_Plugin {
764
  delete_option( 'p3-profiler_use_current_ip' );
765
  delete_option( 'p3-profiler_ip_address' );
766
  delete_option( 'p3-profiler_version' );
 
767
  }
768
  }
769
 
@@ -801,15 +879,7 @@ class P3_Profiler_Plugin {
801
  $size /= pow( 1024, $pow );
802
  return round( $size, 0 ) . ' ' . $units[$pow];
803
  }
804
-
805
- /**
806
- * Actions to take when a multisite blog is added
807
- * @return void
808
- */
809
- public function add_blog() {
810
- // Reserved for future use
811
- }
812
-
813
  /**
814
  * Actions to take when a multisite blog is removed
815
  * @return void
@@ -822,6 +892,7 @@ class P3_Profiler_Plugin {
822
  delete_option( 'p3-profiler_use_current_ip' );
823
  delete_option( 'p3-profiler_ip_address' );
824
  delete_option( 'p3-profiler_version' );
 
825
  }
826
 
827
  /**
@@ -841,6 +912,12 @@ class P3_Profiler_Plugin {
841
  update_option( 'p3-profiler_ip_address', '' );
842
  update_option( 'p3-profiler_version', '1.1.0' );
843
  }
 
 
 
 
 
 
844
 
845
  // Ensure the profiles folder is there
846
  $uploads_dir = wp_upload_dir();
4
  Plugin URI: http://support.godaddy.com/godaddy/wordpress-p3-plugin/
5
  Description: See which plugins are slowing down your site. Create a profile of your WordPress site's plugins' performance by measuring their impact on your site's load time.
6
  Author: GoDaddy.com
7
+ Version: 1.1.2
8
  Author URI: http://www.godaddy.com/
9
  */
10
 
73
  register_deactivation_hook( P3_PATH . DIRECTORY_SEPARATOR . 'p3-profiler.php', array( $p3_profiler_plugin, 'deactivate' ) );
74
  register_uninstall_hook( P3_PATH . DIRECTORY_SEPARATOR . 'p3-profiler.php', array( 'P3_Profiler_Plugin', 'uninstall' ) );
75
  if ( function_exists( 'is_multisite' ) && is_multisite() ) {
 
76
  add_action( 'wpmu_delete_blog', array( $p3_profiler_plugin, 'delete_blog' ) );
77
  }
78
 
90
  * @var P3_Profile_Table
91
  */
92
  public $scan_table = null;
93
+
94
+ /**
95
+ * Name of the current scan being viewed
96
+ * @var string
97
+ */
98
+ public $scan = '';
99
 
100
+ /**
101
+ * Current action
102
+ * @var string
103
+ */
104
+ public $action = '';
105
+
106
+ /**
107
+ * Profile reader object
108
+ * @var P3_Profile_Reader
109
+ */
110
+ public $profile = '';
111
+
112
  /**
113
  * Remove the admin bar from the customer site when profiling is enabled
114
  * to prevent skewing the numbers, as much as possible. Also prevent ssl
224
 
225
  // Only for our page
226
  if ( isset( $_REQUEST['page'] ) && basename( __FILE__ ) == $_REQUEST['page'] ) {
227
+
228
+ // Set up the request based on p3_action
229
+ if ( !empty( $_REQUEST['p3_action'] ) ) {
230
+ $this->action = $_REQUEST['p3_action'];
231
+ }
232
+ if ( empty( $this->action ) || 'current-scan' == $this->action ) {
233
+ $this->scan = $this->get_latest_profile();
234
+ $this->action = 'current-scan';
235
+ } elseif ( 'view-scan' == $this->action ) {
236
+ $this->scan = '';
237
+ if ( !empty( $_REQUEST['name'] ) ) {
238
+ $this->scan = sanitize_file_name( basename( $_REQUEST['name'] ) );
239
+ }
240
+ if ( empty( $this->scan ) || !file_exists( P3_PROFILES_PATH . "/{$this->scan}" ) ) {
241
+ wp_die( '<div id="message" class="error"><p>Scan does not exist</p></div>' );
242
+ }
243
+ $this->scan = P3_PROFILES_PATH . "/{$this->scan}";
244
+ }
245
+
246
+ // If there's a scan, create a viewer object
247
+ if ( !empty( $this->scan ) ) {
248
+ try {
249
+ $this->profile = new P3_Profile_Reader( $this->scan );
250
+ } catch ( P3_Profile_No_Data_Exception $e ) {
251
+ echo '<div class="error"><p>' . $e->getMessage() . '</p></div>';
252
+ $this->scan = null;
253
+ $this->profile = null;
254
+ $this->action = 'list-scans';
255
+ } catch ( Exception $e ) {
256
+ wp_die( '<div id="message" class="error"><p>Error reading scan</p></div>' );
257
+ }
258
+ } else {
259
+ $this->profile = null;
260
+ }
261
+
262
+
263
  // Load the list table, let it handle any bulk actions
264
+ if ( empty( $this->profile ) && in_array( $this->action, array( 'list-scans', 'current-scan' ) ) ) {
265
+ $this->scan_table = new P3_Profile_Table();
266
+ $this->scan_table->prepare_items();
267
+ }
268
 
269
  // Usability message
270
  if ( !defined( 'WPP_PROFILING_STARTED' ) ) {
276
  /**
277
  * Dispatcher function. All requests enter through here
278
  * and are routed based upon the p3_action request variable
 
279
  * @return void
280
  */
281
  public function dispatcher() {
282
+ switch ( $this->action ) {
 
 
 
 
283
  case 'list-scans' :
284
  $this->list_scans();
285
  break;
299
  $this->scan_settings_page();
300
  }
301
  }
302
+
303
+ /**
304
+ * Explain why P3 is asking for FTP credentials
305
+ * @return string
306
+ */
307
+ public function fix_flag_file_help() {
308
+ ?>
309
+ <div class="wrap">
310
+ <strong>Why am I being asked for this information?</strong>
311
+ <blockquote>
312
+ P3 cannot write to this file:<br />
313
+ <code><?php echo P3_FLAG_FILE; ?></code>
314
+ <br />
315
+ P3 needs to write to this file to toggle profiling for your site.
316
+ If you want to fix this manually, please ensure the file is readable
317
+ and writable by the web server.
318
+ </blockquote>
319
+ <div class="updated">
320
+ <p>P3 does <strong>not</strong> store or re-transmit this information.</p>
321
+ </div>
322
+ </div>
323
+ <?php
324
+ }
325
 
326
  /**
327
  * Write .profiling_enabled file, uses request_filesystem_credentials, if
341
 
342
  // Ask for credentials, if necessary
343
  if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, $form_fields ) ) ) {
344
+ $this->fix_flag_file_help();
345
  return true;
346
  } elseif ( ! WP_Filesystem($creds) ) {
347
  // The credentials are bad, ask again
348
  request_filesystem_credentials( $url, $method, true, false, $form_fields );
349
+ $this->fix_flag_file_help();
350
  return true;
351
  } else {
352
  // Once we get here, we should have credentials, do the file system operations
513
 
514
  // Save the new options
515
  update_option( 'p3-profiler_disable_opcode_cache', 'true' == $_POST['p3_disable_opcode_cache'] );
516
+ update_option( 'p3-profiler_cache_buster', 'true' == $_POST['p3_cache_buster'] );
517
  update_option( 'p3-profiler_use_current_ip', 'true' == $_POST['p3_use_current_ip'] );
518
  update_option( 'p3-profiler_ip_address', $_POST['p3_ip_address'] );
519
 
681
  public function show_notices() {
682
 
683
  // Skip notices if we're fixing the flag file
684
+ if ( 'fix-flag-file' == $this->action ) {
685
  return true;
686
  }
687
 
698
  }
699
 
700
  // Check that we can write .profiling_enabled
701
+ if ( isset( $_REQUEST['page'] ) && basename( __FILE__ ) == $_REQUEST['page'] && 'fix-flag-file' != $this->action ) {
702
  if ( !file_exists( P3_FLAG_FILE ) || !is_writable( P3_FLAG_FILE ) ) {
703
  @touch( P3_FLAG_FILE );
704
  if ( !file_exists( P3_FLAG_FILE ) || !is_writable( P3_FLAG_FILE ) ) {
739
 
740
  // mu-plugins doesn't exist
741
  if ( !file_exists( WPMU_PLUGIN_DIR ) && is_writable( WPMU_PLUGIN_DIR . '/../' ) ) {
742
+ wp_mkdir_p( WPMU_PLUGIN_DIR );
743
  }
744
  if ( file_exists( WPMU_PLUGIN_DIR ) && is_writable( WPMU_PLUGIN_DIR ) ) {
745
  file_put_contents(
830
  delete_option( 'p3-profiler_use_current_ip' );
831
  delete_option( 'p3-profiler_ip_address' );
832
  delete_option( 'p3-profiler_version' );
833
+ delete_option( 'p3-profiler_cache_buster' );
834
  }
835
  restore_current_blog();
836
  } else {
841
  delete_option( 'p3-profiler_use_current_ip' );
842
  delete_option( 'p3-profiler_ip_address' );
843
  delete_option( 'p3-profiler_version' );
844
+ delete_option( 'p3-profiler_cache_buster' );
845
  }
846
  }
847
 
879
  $size /= pow( 1024, $pow );
880
  return round( $size, 0 ) . ' ' . $units[$pow];
881
  }
882
+
 
 
 
 
 
 
 
 
883
  /**
884
  * Actions to take when a multisite blog is removed
885
  * @return void
892
  delete_option( 'p3-profiler_use_current_ip' );
893
  delete_option( 'p3-profiler_ip_address' );
894
  delete_option( 'p3-profiler_version' );
895
+ delete_option( 'p3-profiler_cache_buster' );
896
  }
897
 
898
  /**
912
  update_option( 'p3-profiler_ip_address', '' );
913
  update_option( 'p3-profiler_version', '1.1.0' );
914
  }
915
+
916
+ // Upgrading from < 1.1.2
917
+ elseif ( version_compare( $version, '1.1.2') < 0 ) {
918
+ update_option( 'p3-profiler_cache_buster', true );
919
+ update_option( 'p3-profiler_version', '1.1.2' );
920
+ }
921
 
922
  // Ensure the profiles folder is there
923
  $uploads_dir = wp_upload_dir();
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Godaddy, StarfieldTech
3
  Tags: debug, debugging, developer, development, performance, plugin, profiler, speed
4
  Requires at least: 3.3
5
  Tested up to: 3.3.1
6
- Stable tag: 1.1.1
7
 
8
  See which plugins are slowing down your site. This plugin creates a performance report for your site.
9
 
@@ -43,6 +43,9 @@ Manual installation:
43
 
44
  == Upgrade Notice ==
45
 
 
 
 
46
  = 1.1.1 =
47
  This release addresses a bug which which broke the UI on sites that used other plugins that contained an apostrophe in their name. Upgrading is recommended if you were affected by this bug.
48
 
@@ -64,6 +67,15 @@ Previous version of the plugin (before 1.1.0) did not have theme name detection
64
 
65
  == Changelog ==
66
 
 
 
 
 
 
 
 
 
 
67
  = 1.1.1 =
68
  * Bugfix - Plugin names with apostrophes broke the UI
69
  * Bugfix - Fix a deprecated warning with callt-ime pass by reference
3
  Tags: debug, debugging, developer, development, performance, plugin, profiler, speed
4
  Requires at least: 3.3
5
  Tested up to: 3.3.1
6
+ Stable tag: 1.1.2
7
 
8
  See which plugins are slowing down your site. This plugin creates a performance report for your site.
9
 
43
 
44
  == Upgrade Notice ==
45
 
46
+ = 1.1.2 =
47
+ Fix a few bugs reported by users. Upgrading is optional if this plugin is working well for you.
48
+
49
  = 1.1.1 =
50
  This release addresses a bug which which broke the UI on sites that used other plugins that contained an apostrophe in their name. Upgrading is recommended if you were affected by this bug.
51
 
67
 
68
  == Changelog ==
69
 
70
+ = 1.1.2 =
71
+ * Don't show screen options if there is no table
72
+ * Show a "rate us / tweet us" box
73
+ * Add an option to circumvent browser cache
74
+ * Bugfix - Properly work with encrypted plugins (eval based obfuscation)
75
+ * Bugfix - Work with suhosin/safe mode where ini_set / set_time_limit are disabled
76
+ * Bugfix - Remove "Options -Indexes" because it's causing 500 error in some apache setups
77
+ * Bugfix - Fix a warning with theme name detection if the theme is no longer installed
78
+
79
  = 1.1.1 =
80
  * Bugfix - Plugin names with apostrophes broke the UI
81
  * Bugfix - Fix a deprecated warning with callt-ime pass by reference
templates/callouts.php CHANGED
@@ -20,13 +20,35 @@ if ( !defined('P3_PATH') )
20
  // Pause flag
21
  paused: false,
22
 
 
 
 
 
 
 
 
 
 
 
23
  // Start
24
  start: function() {
25
 
 
 
 
 
 
 
 
 
 
 
 
26
  // Form data
27
  data = {
28
  'p3_ip' : jQuery( '#p3-advanced-ip' ).val(),
29
  'p3_disable_opcode_cache' : jQuery( '#p3-disable-opcode-cache' ).prop( 'checked' ),
 
30
  'p3_scan_name' : jQuery( "#p3-scan-name" ).val(),
31
  'action' : 'p3_start_scan',
32
  'p3_nonce' : jQuery( "#p3_nonce" ).val()
@@ -83,6 +105,7 @@ if ( !defined('P3_PATH') )
83
  data = {
84
  'p3_ip' : jQuery( '#p3-advanced-ip' ).val(),
85
  'p3_disable_opcode_cache' : jQuery( '#p3-disable-opcode-cache' ).prop( 'checked' ),
 
86
  'p3_scan_name' : jQuery( "#p3-scan-name" ).val(),
87
  'action' : 'p3_start_scan',
88
  'p3_nonce' : jQuery( "#p3_nonce" ).val()
@@ -186,7 +209,7 @@ if ( !defined('P3_PATH') )
186
  'resizable' : false,
187
  'modal' : true,
188
  'width' : 450,
189
- 'height' : 305,
190
  'title' : "Advanced Settings",
191
  'buttons' :
192
  [
@@ -201,6 +224,7 @@ if ( !defined('P3_PATH') )
201
  'p3_disable_opcode_cache' : $( '#p3-disable-opcode-cache' ).prop( 'checked' ),
202
  'p3_use_current_ip' : $( '#p3-use-current-ip' ).prop( 'checked' ),
203
  'p3_ip_address' : $( '#p3-advanced-ip' ).val(),
 
204
  'p3_nonce' : '<?php echo wp_create_nonce( 'p3_save_settings' ); ?>'
205
  }
206
  $.post( ajaxurl, data, function( response ) {
@@ -350,6 +374,7 @@ if ( !defined('P3_PATH') )
350
  data = {
351
  'p3_ip' : jQuery( '#p3-advanced-ip' ).val(),
352
  'p3_disable_opcode_cache' : jQuery( '#p3-disable-opcode-cache' ).prop( 'checked' ),
 
353
  'p3_scan_name' : jQuery( "#p3-scan-name" ).val(),
354
  'action' : 'p3_start_scan',
355
  'p3_nonce' : jQuery( "#p3_nonce" ).val()
@@ -421,7 +446,7 @@ if ( !defined('P3_PATH') )
421
  jQuery( "#p3-progress-dialog" ).dialog( "close" );
422
 
423
  // View the scan
424
- location.href = "<?php echo add_query_arg( array( 'p3_action' => 'view-scan', 'current_scan' => '1' ) ); ?>&name=" + $( this ).attr( "data-scan-name" );
425
  });
426
  $( "#p3-view-incomplete-results-submit" ).click( function() {
427
  $( "#p3-view-results-submit" ).trigger( "click" );
@@ -514,14 +539,14 @@ if ( !defined('P3_PATH') )
514
  <!-- Second callout cell -->
515
  <td class="p3-callout">
516
  <div class="p3-callout-outer-wrapper qtip-tip" title="Total number of seconds dedicated to plugin code per visit on your site."
517
- <?php if ( !empty( $scan ) ) { ?>title="From <?php echo basename( $scan ); ?><?php } ?>">
518
  <div class="p3-callout-inner-wrapper">
519
  <div class="p3-callout-caption">Plugin Load Time</div>
520
  <div class="p3-callout-data">
521
- <?php if ( null === $profile ) { ?>
522
  <span class="p3-faded-grey">n/a</span>
523
  <?php } else { ?>
524
- <?php printf( '%.3f', $profile->averages['plugins'] ); ?>
525
  <?php } ?>
526
  </div>
527
  <div class="p3-callout-caption">( sec. per visit )</div>
@@ -532,14 +557,14 @@ if ( !defined('P3_PATH') )
532
  <!-- Third callout cell -->
533
  <td class="p3-callout">
534
  <div class="p3-callout-outer-wrapper qtip-tip" title="Percent of load time on your site dedicated to plugin code."
535
- <?php if ( !empty( $scan ) ) { ?>title="From <?php echo basename( $scan ); ?><?php } ?>">
536
  <div class="p3-callout-inner-wrapper">
537
  <div class="p3-callout-caption">Plugin Impact</div>
538
  <div class="p3-callout-data">
539
- <?php if ( null === $profile ) { ?>
540
  <span class="p3-faded-grey">n/a</span>
541
  <?php } else { ?>
542
- <?php printf( '%.1f%%', $profile->averages['plugin_impact'] ); ?>
543
  <?php } ?>
544
  </div>
545
  <div class="p3-callout-caption">( of page load time )</div>
@@ -550,14 +575,14 @@ if ( !defined('P3_PATH') )
550
  <!-- Fourth callout cell -->
551
  <td class="p3-callout">
552
  <div class="p3-callout-outer-wrapper qtip-tip" title="Total number of database queries per visit."
553
- <?php if ( !empty( $scan ) ) { ?>title="From <?php echo basename( $scan ); ?><?php } ?>">
554
  <div class="p3-callout-inner-wrapper">
555
  <div class="p3-callout-caption">MySQL Queries</div>
556
  <div class="p3-callout-data">
557
- <?php if ( null === $profile ) { ?>
558
  <span class="p3-faded-grey">n/a</span>
559
  <?php } else { ?>
560
- <?php echo round( $profile->averages['queries'] ); ?>
561
  <?php } ?>
562
  </div>
563
  <div class="p3-callout-caption">per visit</div>
@@ -585,7 +610,14 @@ if ( !defined('P3_PATH') )
585
  <label for="p3-disable-opcode-cache">Attempt to disable opcode caches <em>( recommended )</em></label>
586
  <br />
587
  <em class="p3-em">This can increase accuracy in plugin detection, but decrease accuracy in timing</em>
588
- </div>
 
 
 
 
 
 
 
589
  </div>
590
 
591
  <!-- Dialog for iframe scanner -->
20
  // Pause flag
21
  paused: false,
22
 
23
+ // Create a random string
24
+ random: function(length) {
25
+ var ret = "";
26
+ var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
27
+ for ( var i = 0 ; i < length ; i++ ) {
28
+ ret += alphabet.charAt( Math.floor( Math.random() * alphabet.length ) );
29
+ }
30
+ return ret;
31
+ },
32
+
33
  // Start
34
  start: function() {
35
 
36
+ // If cache busting is disabled, remove P3_NOCACHE from the pages
37
+ if ( jQuery( '#p3-cache-buster' ).prop( 'checked' ) ) {
38
+ for ( i = 0 ; i < P3_Scan.pages.length ; i++ ) {
39
+ if ( P3_Scan.pages[i].indexOf('?') > -1 ) {
40
+ P3_Scan.pages[i] += '&P3_NOCACHE=' + P3_Scan.random(8);
41
+ } else {
42
+ P3_Scan.pages[i] += '?P3_NOCACHE=' + P3_Scan.random(8);
43
+ }
44
+ }
45
+ }
46
+
47
  // Form data
48
  data = {
49
  'p3_ip' : jQuery( '#p3-advanced-ip' ).val(),
50
  'p3_disable_opcode_cache' : jQuery( '#p3-disable-opcode-cache' ).prop( 'checked' ),
51
+ 'p3_cache_buster' : jQuery( '#p3-cache-buster' ).prop( 'checked' ),
52
  'p3_scan_name' : jQuery( "#p3-scan-name" ).val(),
53
  'action' : 'p3_start_scan',
54
  'p3_nonce' : jQuery( "#p3_nonce" ).val()
105
  data = {
106
  'p3_ip' : jQuery( '#p3-advanced-ip' ).val(),
107
  'p3_disable_opcode_cache' : jQuery( '#p3-disable-opcode-cache' ).prop( 'checked' ),
108
+ 'p3_cache_buster' : jQuery( '#p3-cache-buster' ).prop( 'checked' ),
109
  'p3_scan_name' : jQuery( "#p3-scan-name" ).val(),
110
  'action' : 'p3_start_scan',
111
  'p3_nonce' : jQuery( "#p3_nonce" ).val()
209
  'resizable' : false,
210
  'modal' : true,
211
  'width' : 450,
212
+ 'height' : 340,
213
  'title' : "Advanced Settings",
214
  'buttons' :
215
  [
224
  'p3_disable_opcode_cache' : $( '#p3-disable-opcode-cache' ).prop( 'checked' ),
225
  'p3_use_current_ip' : $( '#p3-use-current-ip' ).prop( 'checked' ),
226
  'p3_ip_address' : $( '#p3-advanced-ip' ).val(),
227
+ 'p3_cache_buster' : $( '#p3-cache-buster' ).prop( 'checked' ),
228
  'p3_nonce' : '<?php echo wp_create_nonce( 'p3_save_settings' ); ?>'
229
  }
230
  $.post( ajaxurl, data, function( response ) {
374
  data = {
375
  'p3_ip' : jQuery( '#p3-advanced-ip' ).val(),
376
  'p3_disable_opcode_cache' : jQuery( '#p3-disable-opcode-cache' ).prop( 'checked' ),
377
+ 'p3_cache_buster' : jQuery( '#p3-cache-buster' ).prop( 'checked' ),
378
  'p3_scan_name' : jQuery( "#p3-scan-name" ).val(),
379
  'action' : 'p3_start_scan',
380
  'p3_nonce' : jQuery( "#p3_nonce" ).val()
446
  jQuery( "#p3-progress-dialog" ).dialog( "close" );
447
 
448
  // View the scan
449
+ location.href = "<?php echo add_query_arg( array( 'p3_action' => 'view-scan', 'current_scan' => '1', 'name' => null ) ); ?>&name=" + $( this ).attr( "data-scan-name" );
450
  });
451
  $( "#p3-view-incomplete-results-submit" ).click( function() {
452
  $( "#p3-view-results-submit" ).trigger( "click" );
539
  <!-- Second callout cell -->
540
  <td class="p3-callout">
541
  <div class="p3-callout-outer-wrapper qtip-tip" title="Total number of seconds dedicated to plugin code per visit on your site."
542
+ <?php if ( !empty( $this->scan ) ) { ?>title="From <?php echo basename( $this->scan ); ?><?php } ?>">
543
  <div class="p3-callout-inner-wrapper">
544
  <div class="p3-callout-caption">Plugin Load Time</div>
545
  <div class="p3-callout-data">
546
+ <?php if ( null === $this->profile ) { ?>
547
  <span class="p3-faded-grey">n/a</span>
548
  <?php } else { ?>
549
+ <?php printf( '%.3f', $this->profile->averages['plugins'] ); ?>
550
  <?php } ?>
551
  </div>
552
  <div class="p3-callout-caption">( sec. per visit )</div>
557
  <!-- Third callout cell -->
558
  <td class="p3-callout">
559
  <div class="p3-callout-outer-wrapper qtip-tip" title="Percent of load time on your site dedicated to plugin code."
560
+ <?php if ( !empty( $this->scan ) ) { ?>title="From <?php echo basename( $this->scan ); ?><?php } ?>">
561
  <div class="p3-callout-inner-wrapper">
562
  <div class="p3-callout-caption">Plugin Impact</div>
563
  <div class="p3-callout-data">
564
+ <?php if ( null === $this->profile ) { ?>
565
  <span class="p3-faded-grey">n/a</span>
566
  <?php } else { ?>
567
+ <?php printf( '%.1f%%', $this->profile->averages['plugin_impact'] ); ?>
568
  <?php } ?>
569
  </div>
570
  <div class="p3-callout-caption">( of page load time )</div>
575
  <!-- Fourth callout cell -->
576
  <td class="p3-callout">
577
  <div class="p3-callout-outer-wrapper qtip-tip" title="Total number of database queries per visit."
578
+ <?php if ( !empty( $this->scan ) ) { ?>title="From <?php echo basename( $this->scan ); ?><?php } ?>">
579
  <div class="p3-callout-inner-wrapper">
580
  <div class="p3-callout-caption">MySQL Queries</div>
581
  <div class="p3-callout-data">
582
+ <?php if ( null === $this->profile ) { ?>
583
  <span class="p3-faded-grey">n/a</span>
584
  <?php } else { ?>
585
+ <?php echo round( $this->profile->averages['queries'] ); ?>
586
  <?php } ?>
587
  </div>
588
  <div class="p3-callout-caption">per visit</div>
610
  <label for="p3-disable-opcode-cache">Attempt to disable opcode caches <em>( recommended )</em></label>
611
  <br />
612
  <em class="p3-em">This can increase accuracy in plugin detection, but decrease accuracy in timing</em>
613
+ </div>
614
+ <br />
615
+ <div>
616
+ <input type="checkbox" id="p3-cache-buster" <?php if ( true == get_option( 'p3-profiler_cache_buster' ) ) : ?>checked="checked"<?php endif; ?> />
617
+ <label for="p3-cache-buster">Attempt to circumvent browser cache</label>
618
+ <br />
619
+ <em class="p3-em">This may help fix a "No visits in this profile" error message. See the <a href="<?php echo add_query_arg( array( 'p3_action' => 'help', 'current_scan' => null ) ); ?>#q-circumvent-cache">help</a> page for details.</em>
620
+ </div>
621
  </div>
622
 
623
  <!-- Dialog for iframe scanner -->
templates/help.php CHANGED
@@ -40,9 +40,14 @@ if ( !defined('P3_PATH') )
40
  var links = [];
41
  var i = 1;
42
  $( "h2.p3-help-question:not(:first )" ).each( function() {
43
- $( this ).before( '<a name="q' + i + '">&nbsp;</a>' );
44
- links.push( '<li><a href="#q' + i + '">' + $( this ).html() + '</a></li>' );
45
- i++;
 
 
 
 
 
46
  });
47
  $( "div.p3-question blockquote:not(:first )" ).each( function() {
48
  $( this ).after( '<a href="#top">Back to top</a>' );
@@ -95,6 +100,43 @@ if ( !defined('P3_PATH') )
95
  </blockquote>
96
  </div>
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  <div class="p3-question">
99
  <h2 class="p3-help-question">How does this work?</h2>
100
  <blockquote>
@@ -480,11 +522,7 @@ if ( !defined('P3_PATH') )
480
  <blockquote>
481
  <strong>P3 (Plugin Performance Profiler)</strong>
482
  <br />
483
- <?php if (date('Y') > 2011) : ?>
484
- Copyright &copy; 2011-<?php echo date('Y'); ?> <a href="http://www.godaddy.com/" target="_blank">GoDaddy.com</a>. All rights reserved.
485
- <?php else : ?>
486
- Copyright &copy; 2011 <a href="http://www.godaddy.com/" target="_blank">GoDaddy.com</a>. All rights reserved.
487
- <?php endif; ?>
488
  <br /><br />
489
  This program is offered under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation.
490
  <br /><br />
40
  var links = [];
41
  var i = 1;
42
  $( "h2.p3-help-question:not(:first )" ).each( function() {
43
+ if ( $( this ).attr( "data-question-id" ) !== undefined ) {
44
+ $( this ).before( '<a name="' + $( this ).attr( "data-question-id" ) + '">&nbsp;</a>' );
45
+ links.push( '<li><a href="#' + $( this ).attr( "data-question-id" ) + '">' + $( this ).html() + '</a></li>' );
46
+ } else {
47
+ $( this ).before( '<a name="q' + i + '">&nbsp;</a>' );
48
+ links.push( '<li><a href="#q' + i + '">' + $( this ).html() + '</a></li>' );
49
+ i++;
50
+ }
51
  });
52
  $( "div.p3-question blockquote:not(:first )" ).each( function() {
53
  $( this ).after( '<a href="#top">Back to top</a>' );
100
  </blockquote>
101
  </div>
102
 
103
+ <div class="p3-question">
104
+ <h2 class="p3-help-question" data-question-id="q-circumvent-cache">How do I fix "No visits in this profile..." ?</h2>
105
+ <blockquote>
106
+ This error message means that after being disabled, the profiler did not record any traffic on your site. There are several common
107
+ causes for this:
108
+ <ul>
109
+ <li>
110
+ <strong>Cause:</strong> Your site is using a caching plugin. The pages that are being scanned aren't actually loading on
111
+ the server because they're cached in your browser or on the server before WordPress can generate them. The P3 plugin doesn't
112
+ load and doesn't record any traffic.
113
+ <br />
114
+ <strong>Solution:</strong> Enable the "Attempt to circumvent browser cache" option in the advanced settings.
115
+ </li>
116
+ <li>
117
+ <strong>Cause:</strong> The IP address you've entered in the advanced settings dialog doesn't match the IP address you're
118
+ scanning from.
119
+ <br />
120
+ <strong>Solution:</strong> Check the IP address you've entered and try again.
121
+ </li>
122
+ <li>
123
+ <strong>Cause:</strong> You've selected a manual scan, but haven't generated any traffic.
124
+ <br />
125
+ <strong>Solution:</strong> Try the automated scan.
126
+ </li>
127
+ </ul>
128
+ </blockquote>
129
+ </div>
130
+
131
+ <div class="p3-question">
132
+ <h2 class="p3-help-question">Why did P3 only record 2 or 3 visits during the scan?</h2>
133
+ <blockquote>
134
+ If your site is using a caching plugin, some pages might be cached in your browser or on the server and are loading before before WordPress
135
+ can generate them. When this happens, the P3 plugin doesn't load and doesn't record any traffic. Please enable the "Attempt to circumvent
136
+ browser cache" option in the advanced settings.
137
+ </blockquote>
138
+ </div>
139
+
140
  <div class="p3-question">
141
  <h2 class="p3-help-question">How does this work?</h2>
142
  <blockquote>
522
  <blockquote>
523
  <strong>P3 (Plugin Performance Profiler)</strong>
524
  <br />
525
+ Copyright &copy; 2011-<?php echo date('Y'); ?> <a href="http://www.godaddy.com/" target="_blank">GoDaddy.com</a>. All rights reserved.
 
 
 
 
526
  <br /><br />
527
  This program is offered under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation.
528
  <br /><br />
templates/template.php CHANGED
@@ -1,47 +1,16 @@
1
  <?php
2
- if ( !defined('P3_PATH') )
3
- die( 'Forbidden ');
4
- $p3_action = '';
5
- if ( !empty( $_REQUEST['p3_action'] ) ) {
6
- $p3_action = $_REQUEST['p3_action'];
7
- }
8
- if ( empty( $p3_action ) || 'current-scan' == $p3_action ) {
9
- $scan = $this->get_latest_profile();
10
- $p3_action = 'current-scan';
11
- } elseif ( 'view-scan' == $p3_action && !empty( $_REQUEST['name'] ) ) {
12
- $scan = sanitize_file_name( basename( $_REQUEST['name'] ) );
13
- if ( !file_exists( P3_PROFILES_PATH . "/$scan" ) ) {
14
- wp_die( '<div id="message" class="error"><p>Scan does not exist</p></div>' );
15
- }
16
- $scan = P3_PROFILES_PATH . "/$scan";
17
- }
18
  $button_current_checked = '';
19
  $button_history_checked = '';
20
  $button_help_checked = '';
21
- if ( 'current-scan' == $p3_action || !empty( $_REQUEST['current_scan'] ) ) {
22
  $button_current_checked = 'checked="checked"';
23
- } elseif ( 'help' == $p3_action || 'fix-flag-file' == $p3_action ) {
24
  $button_help_checked = 'checked="checked"';
25
  } else {
26
  $button_history_checked = 'checked="checked"';
27
  }
28
 
29
- // If there's a scan, create a viewer object
30
- if ( !empty( $scan ) ) {
31
- try {
32
- $profile = new P3_Profile_Reader( $scan );
33
- } catch ( P3_Profile_No_Data_Exception $e ) {
34
- echo '<div class="error"><p>' . $e->getMessage() . '</p></div>';
35
- $scan = null;
36
- $profile = null;
37
- $p3_action = 'list-scans';
38
- } catch ( Exception $e ) {
39
- wp_die( '<div id="message" class="error"><p>Error reading scan</p></div>' );
40
- }
41
- } else {
42
- $profile = null;
43
- }
44
-
45
  ?>
46
  <script type="text/javascript">
47
  jQuery( document ).ready( function( $) {
@@ -77,6 +46,13 @@ if ( !empty( $scan ) ) {
77
  }
78
  });
79
  });
 
 
 
 
 
 
 
80
  });
81
  </script>
82
  <div class="wrap">
@@ -104,11 +80,11 @@ if ( !empty( $scan ) ) {
104
  <?php require_once P3_PATH . '/templates/callouts.php'; ?>
105
 
106
  <!-- View scan or show a list of scans -->
107
- <?php if ( ( 'current-scan' == $p3_action && !empty( $scan ) ) || 'view-scan' == $p3_action ) { ?>
108
  <?php include_once P3_PATH . '/templates/view-scan.php'; ?>
109
- <?php } elseif ( 'help' == $p3_action ) { ?>
110
  <?php include_once P3_PATH . '/templates/help.php'; ?>
111
- <?php } elseif ( 'fix-flag-file' == $p3_action ) { ?>
112
  <?php include_once P3_PATH . '/templates/fix-flag-file.php'; ?>
113
  <?php } else { ?>
114
  <?php include_once P3_PATH . '/templates/list-scans.php'; ?>
@@ -116,12 +92,18 @@ if ( !empty( $scan ) ) {
116
 
117
  </div>
118
 
 
 
 
 
 
 
 
 
 
 
119
  <div id="p3-copyright">
120
  <img src="<?php echo plugins_url() . '/p3-profiler/logo.gif'; ?>" alt="GoDaddy.com logo" title="GoDaddy.com logo" />
121
  <br />
122
- <?php if (date('Y') > 2011) : ?>
123
- Copyright &copy; 2011-<?php echo date('Y'); ?> <a href="http://www.godaddy.com/" target="_blank">GoDaddy.com</a>. All rights reserved.
124
- <?php else : ?>
125
- Copyright &copy; 2011 <a href="http://www.godaddy.com/" target="_blank">GoDaddy.com</a>. All rights reserved.
126
- <?php endif; ?>
127
  </div>
1
  <?php
2
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  $button_current_checked = '';
4
  $button_history_checked = '';
5
  $button_help_checked = '';
6
+ if ( 'current-scan' == $this->action || !empty( $_REQUEST['current_scan'] ) ) {
7
  $button_current_checked = 'checked="checked"';
8
+ } elseif ( 'help' == $this->action || 'fix-flag-file' == $this->action ) {
9
  $button_help_checked = 'checked="checked"';
10
  } else {
11
  $button_history_checked = 'checked="checked"';
12
  }
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ?>
15
  <script type="text/javascript">
16
  jQuery( document ).ready( function( $) {
46
  }
47
  });
48
  });
49
+
50
+ // Callouts
51
+ $( "div#p3-reminder-wrapper" )
52
+ .corner( "round 8px" )
53
+ .parent()
54
+ .css( "padding", "4px" )
55
+ .corner( "round 10px" );
56
  });
57
  </script>
58
  <div class="wrap">
80
  <?php require_once P3_PATH . '/templates/callouts.php'; ?>
81
 
82
  <!-- View scan or show a list of scans -->
83
+ <?php if ( ( 'current-scan' == $this->action && !empty( $this->scan ) ) || 'view-scan' == $this->action ) { ?>
84
  <?php include_once P3_PATH . '/templates/view-scan.php'; ?>
85
+ <?php } elseif ( 'help' == $this->action ) { ?>
86
  <?php include_once P3_PATH . '/templates/help.php'; ?>
87
+ <?php } elseif ( 'fix-flag-file' == $this->action ) { ?>
88
  <?php include_once P3_PATH . '/templates/fix-flag-file.php'; ?>
89
  <?php } else { ?>
90
  <?php include_once P3_PATH . '/templates/list-scans.php'; ?>
92
 
93
  </div>
94
 
95
+ <div id="p3-reminder">
96
+ <div id="p3-reminder-wrapper">
97
+ Do you like this plugin?
98
+ <ul>
99
+ <li><a href="http://twitter.com/home?status=<?php echo rawurlencode(htmlentities('I just optimized my WordPress site with #p3plugin http://wordpress.org/extend/plugins/p3-profiler/ ')); ?>" target="_blank">Tweet</a> about it</li>
100
+ <li><a href="http://wordpress.org/extend/plugins/p3-profiler/" target="_blank">Rate</a> it on the repository</li>
101
+ </ul>
102
+ </div>
103
+ </div>
104
+
105
  <div id="p3-copyright">
106
  <img src="<?php echo plugins_url() . '/p3-profiler/logo.gif'; ?>" alt="GoDaddy.com logo" title="GoDaddy.com logo" />
107
  <br />
108
+ Copyright &copy; 2011-<?php echo date('Y'); ?> <a href="http://www.godaddy.com/" target="_blank">GoDaddy.com</a>. All rights reserved.
 
 
 
 
109
  </div>
templates/view-scan.php CHANGED
@@ -3,9 +3,9 @@ if ( !defined('P3_PATH') )
3
  die( 'Forbidden ');
4
  $url_stats = array();
5
  $domain = '';
6
- if ( !empty( $profile ) ) {
7
- $url_stats = $profile->get_stats_by_url();
8
- $domain = @parse_url( $profile->report_url, PHP_URL_HOST );
9
  }
10
  $pie_chart_id = substr( md5( uniqid() ), -8 );
11
  $runtime_chart_id = substr( md5( uniqid() ), -8 );
@@ -21,8 +21,8 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
21
 
22
  // Raw json data ( used in the charts for tooltip data
23
  var _data = [];
24
- <?php if ( !empty( $scan ) && file_exists( $scan ) ) { ?>
25
- <?php foreach ( file( $scan, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) as $line ) { ?>
26
  _data.push(<?php echo $line; ?>);
27
  <?php } ?>
28
  <?php } ?>
@@ -165,10 +165,10 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
165
  /** Plugin pie chart **/
166
  /**************************************************************/
167
  var data_<?php echo $pie_chart_id; ?> = [
168
- <?php if ( !empty( $profile ) ){ ?>
169
- <?php foreach ( $profile->plugin_times as $k => $v ) { ?>
170
  {
171
- label: "<?php echo esc_js( $k ); ?>",
172
  data: <?php echo $v; ?>
173
  },
174
  <?php } ?>
@@ -327,7 +327,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
327
  {
328
  label: "# of Queries",
329
  data: [
330
- <?php if ( !empty( $profile ) ){ ?>
331
  <?php foreach ( array_values( $url_stats ) as $k => $v ) { ?>
332
  [
333
  <?php echo $k + 1; ?>,
@@ -406,7 +406,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
406
 
407
 
408
  /**************************************************************/
409
- /** Component bar chart data **/
410
  /**************************************************************/
411
  var chart_<?php echo $component_breakdown_chart_id; ?> = null;
412
  var data_<?php echo $component_breakdown_chart_id; ?> = [
@@ -420,23 +420,23 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
420
  <?php for ( $i = -999 ; $i < 999 + 2; $i++ ) { ?>
421
  [
422
  <?php echo $i; ?>,
423
- <?php echo $profile->averages['site']; ?>
424
  ],
425
  <?php } ?>
426
  ]
427
  },
428
  {
429
  label: 'WP Core Time',
430
- data: [[0, <?php echo $profile->averages['core']; ?>]]
431
  },
432
  {
433
  label: 'Theme',
434
- data: [[1, <?php echo $profile->averages['theme']; ?>]]
435
  },
436
  <?php $i = 2; $other = 0; ?>
437
- <?php foreach ( $profile->plugin_times as $k => $v ) { ?>
438
  {
439
- label: '<?php echo esc_js( $k ); ?>',
440
  data: [[
441
  <?php echo $i++; ?>,
442
  <?php echo $v; ?>
@@ -473,10 +473,10 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
473
  [1, 'WP Core Time'],
474
  [2, 'Theme'],
475
  <?php $i = 3; ?>
476
- <?php foreach ( $profile->plugin_times as $k => $v ) { ?>
477
  [
478
  <?php echo $i++ ?>,
479
- '<?php echo esc_js( $k ); ?>'
480
  ],
481
  <?php } ?>
482
  ],
@@ -526,7 +526,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
526
  {
527
  label: "WP Core Time",
528
  data: [
529
- <?php if ( !empty( $profile ) ){ ?>
530
  <?php foreach ( array_values( $url_stats ) as $k => $v ) { ?>
531
  [
532
  <?php echo $k + 1; ?>,
@@ -539,7 +539,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
539
  {
540
  label: "Theme",
541
  data: [
542
- <?php if ( !empty( $profile ) ){ ?>
543
  <?php foreach ( array_values( $url_stats ) as $k => $v ) { ?>
544
  [
545
  <?php echo $k + 1; ?>,
@@ -549,10 +549,10 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
549
  <?php } ?>
550
  ]
551
  },
552
- <?php if ( !empty( $profile ) && !empty( $profile->detected_plugins ) ) { ?>
553
- <?php foreach ( $profile->detected_plugins as $plugin ) { ?>
554
  {
555
- label: "<?php echo esc_js( $plugin ); ?>",
556
  data: [
557
  <?php foreach ( array_values( $url_stats ) as $k => $v ) { ?>
558
  <?php if ( array_key_exists( $plugin, $v['breakdown'] ) ) { ?>
@@ -571,11 +571,11 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
571
  var detailed_timeline_options = {};
572
 
573
  jQuery( document ).ready( function ( $ ) {
574
- <?php if ( !empty( $profile ) && !empty( $profile->detected_plugins ) ) { ?>
575
  jQuery( "#p3-detailed-series-toggle" ).append( '<div><label><input type="checkbox" checked="checked" class="p3-detailed-series-toggle" data-key="WP Core Time" />WP Core Time</label></div>' );
576
  jQuery( "#p3-detailed-series-toggle" ).append( '<div><label><input type="checkbox" checked="checked" class="p3-detailed-series-toggle" data-key="Theme" />Theme</label></div>' );
577
- <?php foreach ( $profile->detected_plugins as $plugin ) { ?>
578
- jQuery( "#p3-detailed-series-toggle" ).append( '<div><label><input type="checkbox" checked="checked" class="p3-detailed-series-toggle" data-key="<?php echo esc_html( $plugin ); ?>" /><?php echo esc_html( $plugin ); ?></label></div>' );
579
  <?php } ?>
580
  <?php } ?>
581
  jQuery( "input.p3-detailed-series-toggle" ).click( function() {
@@ -879,7 +879,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
879
  <strong>Total Load Time: </strong>
880
  </td>
881
  <td>
882
- <?php printf( '%.4f', $profile->averages['total'] ); ?> seconds <em class="p3-em">avg.</em>
883
  </td>
884
  </tr>
885
  <tr>
@@ -888,7 +888,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
888
  <strong>Site Load Time</small></em></strong>
889
  </td>
890
  <td>
891
- <?php printf( '%.4f', $profile->averages['site'] ); ?> seconds <em class="p3-em">avg.</em>
892
  </td>
893
  </tr>
894
  <tr class="advanced">
@@ -898,7 +898,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
898
  <strong>Profile Overhead: </strong>
899
  </td>
900
  <td>
901
- <?php printf( '%.4f', $profile->averages['profile'] ); ?> seconds <em class="p3-em">avg.</em>
902
  </td>
903
  </tr>
904
  <tr>
@@ -908,7 +908,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
908
  <strong>Plugin Load Time: </strong>
909
  </td>
910
  <td>
911
- <?php printf( '%.4f', $profile->averages['plugins'] ); ?> seconds <em class="p3-em">avg.</em>
912
  </td>
913
  </tr>
914
  <tr>
@@ -918,7 +918,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
918
  <strong>Theme Load Time: </strong>
919
  </td>
920
  <td>
921
- <?php printf( '%.4f', $profile->averages['theme'] ); ?> seconds <em class="p3-em">avg.</em>
922
  </td>
923
  </tr>
924
  <tr>
@@ -928,7 +928,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
928
  <strong>Core Load Time: </strong>
929
  </td>
930
  <td>
931
- <?php printf( '%.4f', $profile->averages['core'] ); ?> seconds <em class="p3-em">avg.</em>
932
  </td>
933
  </tr>
934
  <tr class="advanced">
@@ -942,15 +942,15 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
942
  <strong>Margin of Error: </strong>
943
  </td>
944
  <td>
945
- <?php printf( '%.4f', $profile->averages['drift'] ); ?> seconds <em class="p3-em">avg.</em>
946
  <br />
947
  <em class="p3-em">
948
  (<span class="qtip-tip" title="How long the site took to load. This is an observed measurement (start timing
949
  when the page was requested, stop timing when the page was delivered to the browser, calculate the
950
- difference)."><?php printf( '%.4f', $profile->averages['observed'] ); ?> observed<span>,
951
  <span class="qtip-tip" title="The expected site load time calculated by adding plugin load time, core
952
  load time, theme load time, and profiler overhead.">
953
- <?php printf( '%.4f', $profile->averages['expected'] ); ?> expected</span>)
954
  </em>
955
  </td>
956
  </tr>
@@ -960,7 +960,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
960
  <strong>Visits: </strong>
961
  </td>
962
  <td>
963
- <?php echo number_format( $profile->visits ); ?>
964
  </td>
965
  </tr>
966
  <tr class="advanced">
@@ -968,7 +968,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
968
  <strong>Number of Plugin Function Calls: </strong>
969
  </td>
970
  <td>
971
- <?php echo number_format( $profile->averages['plugin_calls'] ); ?> calls <em class="p3-em">avg.</em>
972
  </td>
973
  </tr>
974
  <tr>
@@ -977,7 +977,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
977
  <strong>Memory Usage: </strong>
978
  </td>
979
  <td>
980
- <?php echo number_format( $profile->averages['memory'] / 1024 / 1024, 2 ); ?> MB <em class="p3-em">avg.</em>
981
  </td>
982
  </tr>
983
  <tr>
@@ -986,7 +986,7 @@ $component_runtime_chart_id = substr( md5( uniqid() ), -8 );
986
  <strong>MySQL Queries: </strong>
987
  </td>
988
  <td>
989
- <?php echo round( $profile->averages['queries'] ); ?> queries <em class="p3-em">avg.</em>
990
  </td>
991
  </tr>
992
  </tbody>
@@ -1036,27 +1036,27 @@ to share the results with you. Please take a look at the information below:</te
1036
  <textarea disabled="disabled" id="p3-email-results-results" style="width: 95%; height: 120px;"><?php
1037
  echo "WordPress Plugin Profile Report\n";
1038
  echo "===========================================\n";
1039
- echo 'Report date: ' . date( 'D M j, Y', $profile->report_date ) . "\n";
1040
- echo 'Theme name: ' . $profile->theme_name . "\n";
1041
- echo 'Pages browsed: ' . $profile->visits . "\n";
1042
- echo 'Avg. load time: ' . sprintf( '%.4f', $profile->averages['site'] ) . " sec\n";
1043
- echo 'Number of plugins: ' . count( $profile->detected_plugins ) . " \n";
1044
- echo 'Plugin impact: ' . sprintf( '%.2f%%', $profile->averages['plugin_impact'] ) . " % of load time\n";
1045
- echo 'Avg. plugin time: ' . sprintf( '%.4f', $profile->averages['plugins'] ) . " sec\n";
1046
- echo 'Avg. core time: ' . sprintf( '%.4f', $profile->averages['core'] ) . " sec\n";
1047
- echo 'Avg. theme time: ' . sprintf( '%.4f', $profile->averages['theme'] ) . " sec\n";
1048
- echo 'Avg. mem usage: ' . number_format( $profile->averages['memory'] / 1024 / 1024, 2 ) . " MB\n";
1049
- echo 'Avg. plugin calls: ' . number_format( $profile->averages['plugin_calls'] ) . "\n";
1050
- echo 'Avg. db queries : ' . sprintf( '%.2f', $profile->averages['queries'] ) . "\n";
1051
- echo 'Margin of error : ' . sprintf( '%.4f', $profile->averages['drift'] ) . " sec\n";
1052
  echo "\nPlugin list:\n";
1053
  echo "===========================================\n";
1054
- foreach ( $profile->plugin_times as $k => $v) {
1055
- echo esc_html( $k ) . ' - ' . sprintf('%.4f sec', $v) . ' - ' . sprintf( '%.2f%%', $v * 100 / array_sum( $profile->plugin_times ) ) . "\n";
1056
  }
1057
  ?></textarea>
1058
  </div>
1059
- <input type="hidden" id="p3-email-results-scan" value="<?php echo basename( $scan ); ?>" />
1060
  </div>
1061
 
1062
  <!-- Email sending dialog -->
3
  die( 'Forbidden ');
4
  $url_stats = array();
5
  $domain = '';
6
+ if ( !empty( $this->profile ) ) {
7
+ $url_stats = $this->profile->get_stats_by_url();
8
+ $domain = @parse_url( $this->profile->report_url, PHP_URL_HOST );
9
  }
10
  $pie_chart_id = substr( md5( uniqid() ), -8 );
11
  $runtime_chart_id = substr( md5( uniqid() ), -8 );
21
 
22
  // Raw json data ( used in the charts for tooltip data
23
  var _data = [];
24
+ <?php if ( !empty( $this->scan ) && file_exists( $this->scan ) ) { ?>
25
+ <?php foreach ( file( $this->scan, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) as $line ) { ?>
26
  _data.push(<?php echo $line; ?>);
27
  <?php } ?>
28
  <?php } ?>
165
  /** Plugin pie chart **/
166
  /**************************************************************/
167
  var data_<?php echo $pie_chart_id; ?> = [
168
+ <?php if ( !empty( $this->profile ) ){ ?>
169
+ <?php foreach ( $this->profile->plugin_times as $k => $v ) { ?>
170
  {
171
+ label: "<?php echo $k; ?>",
172
  data: <?php echo $v; ?>
173
  },
174
  <?php } ?>
327
  {
328
  label: "# of Queries",
329
  data: [
330
+ <?php if ( !empty( $this->profile ) ){ ?>
331
  <?php foreach ( array_values( $url_stats ) as $k => $v ) { ?>
332
  [
333
  <?php echo $k + 1; ?>,
406
 
407
 
408
  /**************************************************************/
409
+ /** Compnent bar chart data **/
410
  /**************************************************************/
411
  var chart_<?php echo $component_breakdown_chart_id; ?> = null;
412
  var data_<?php echo $component_breakdown_chart_id; ?> = [
420
  <?php for ( $i = -999 ; $i < 999 + 2; $i++ ) { ?>
421
  [
422
  <?php echo $i; ?>,
423
+ <?php echo $this->profile->averages['site']; ?>
424
  ],
425
  <?php } ?>
426
  ]
427
  },
428
  {
429
  label: 'WP Core Time',
430
+ data: [[0, <?php echo $this->profile->averages['core']; ?>]]
431
  },
432
  {
433
  label: 'Theme',
434
+ data: [[1, <?php echo $this->profile->averages['theme']; ?>]]
435
  },
436
  <?php $i = 2; $other = 0; ?>
437
+ <?php foreach ( $this->profile->plugin_times as $k => $v ) { ?>
438
  {
439
+ label: '<?php echo $k; ?>',
440
  data: [[
441
  <?php echo $i++; ?>,
442
  <?php echo $v; ?>
473
  [1, 'WP Core Time'],
474
  [2, 'Theme'],
475
  <?php $i = 3; ?>
476
+ <?php foreach ( $this->profile->plugin_times as $k => $v ) { ?>
477
  [
478
  <?php echo $i++ ?>,
479
+ '<?php echo $k; ?>'
480
  ],
481
  <?php } ?>
482
  ],
526
  {
527
  label: "WP Core Time",
528
  data: [
529
+ <?php if ( !empty( $this->profile ) ){ ?>
530
  <?php foreach ( array_values( $url_stats ) as $k => $v ) { ?>
531
  [
532
  <?php echo $k + 1; ?>,
539
  {
540
  label: "Theme",
541
  data: [
542
+ <?php if ( !empty( $this->profile ) ){ ?>
543
  <?php foreach ( array_values( $url_stats ) as $k => $v ) { ?>
544
  [
545
  <?php echo $k + 1; ?>,
549
  <?php } ?>
550
  ]
551
  },
552
+ <?php if ( !empty( $this->profile ) && !empty( $this->profile->detected_plugins ) ) { ?>
553
+ <?php foreach ( $this->profile->detected_plugins as $plugin ) { ?>
554
  {
555
+ label: "<?php echo $plugin; ?>",
556
  data: [
557
  <?php foreach ( array_values( $url_stats ) as $k => $v ) { ?>
558
  <?php if ( array_key_exists( $plugin, $v['breakdown'] ) ) { ?>
571
  var detailed_timeline_options = {};
572
 
573
  jQuery( document ).ready( function ( $ ) {
574
+ <?php if ( !empty( $this->profile ) && !empty( $this->profile->detected_plugins ) ) { ?>
575
  jQuery( "#p3-detailed-series-toggle" ).append( '<div><label><input type="checkbox" checked="checked" class="p3-detailed-series-toggle" data-key="WP Core Time" />WP Core Time</label></div>' );
576
  jQuery( "#p3-detailed-series-toggle" ).append( '<div><label><input type="checkbox" checked="checked" class="p3-detailed-series-toggle" data-key="Theme" />Theme</label></div>' );
577
+ <?php foreach ( $this->profile->detected_plugins as $plugin ) { ?>
578
+ jQuery( "#p3-detailed-series-toggle" ).append( '<div><label><input type="checkbox" checked="checked" class="p3-detailed-series-toggle" data-key="<?php echo $plugin; ?>" /><?php echo $plugin ;?></label></div>' );
579
  <?php } ?>
580
  <?php } ?>
581
  jQuery( "input.p3-detailed-series-toggle" ).click( function() {
879
  <strong>Total Load Time: </strong>
880
  </td>
881
  <td>
882
+ <?php printf( '%.4f', $this->profile->averages['total'] ); ?> seconds <em class="p3-em">avg.</em>
883
  </td>
884
  </tr>
885
  <tr>
888
  <strong>Site Load Time</small></em></strong>
889
  </td>
890
  <td>
891
+ <?php printf( '%.4f', $this->profile->averages['site'] ); ?> seconds <em class="p3-em">avg.</em>
892
  </td>
893
  </tr>
894
  <tr class="advanced">
898
  <strong>Profile Overhead: </strong>
899
  </td>
900
  <td>
901
+ <?php printf( '%.4f', $this->profile->averages['profile'] ); ?> seconds <em class="p3-em">avg.</em>
902
  </td>
903
  </tr>
904
  <tr>
908
  <strong>Plugin Load Time: </strong>
909
  </td>
910
  <td>
911
+ <?php printf( '%.4f', $this->profile->averages['plugins'] ); ?> seconds <em class="p3-em">avg.</em>
912
  </td>
913
  </tr>
914
  <tr>
918
  <strong>Theme Load Time: </strong>
919
  </td>
920
  <td>
921
+ <?php printf( '%.4f', $this->profile->averages['theme'] ); ?> seconds <em class="p3-em">avg.</em>
922
  </td>
923
  </tr>
924
  <tr>
928
  <strong>Core Load Time: </strong>
929
  </td>
930
  <td>
931
+ <?php printf( '%.4f', $this->profile->averages['core'] ); ?> seconds <em class="p3-em">avg.</em>
932
  </td>
933
  </tr>
934
  <tr class="advanced">
942
  <strong>Margin of Error: </strong>
943
  </td>
944
  <td>
945
+ <?php printf( '%.4f', $this->profile->averages['drift'] ); ?> seconds <em class="p3-em">avg.</em>
946
  <br />
947
  <em class="p3-em">
948
  (<span class="qtip-tip" title="How long the site took to load. This is an observed measurement (start timing
949
  when the page was requested, stop timing when the page was delivered to the browser, calculate the
950
+ difference)."><?php printf( '%.4f', $this->profile->averages['observed'] ); ?> observed<span>,
951
  <span class="qtip-tip" title="The expected site load time calculated by adding plugin load time, core
952
  load time, theme load time, and profiler overhead.">
953
+ <?php printf( '%.4f', $this->profile->averages['expected'] ); ?> expected</span>)
954
  </em>
955
  </td>
956
  </tr>
960
  <strong>Visits: </strong>
961
  </td>
962
  <td>
963
+ <?php echo number_format( $this->profile->visits ); ?>
964
  </td>
965
  </tr>
966
  <tr class="advanced">
968
  <strong>Number of Plugin Function Calls: </strong>
969
  </td>
970
  <td>
971
+ <?php echo number_format( $this->profile->averages['plugin_calls'] ); ?> calls <em class="p3-em">avg.</em>
972
  </td>
973
  </tr>
974
  <tr>
977
  <strong>Memory Usage: </strong>
978
  </td>
979
  <td>
980
+ <?php echo number_format( $this->profile->averages['memory'] / 1024 / 1024, 2 ); ?> MB <em class="p3-em">avg.</em>
981
  </td>
982
  </tr>
983
  <tr>
986
  <strong>MySQL Queries: </strong>
987
  </td>
988
  <td>
989
+ <?php echo round( $this->profile->averages['queries'] ); ?> queries <em class="p3-em">avg.</em>
990
  </td>
991
  </tr>
992
  </tbody>
1036
  <textarea disabled="disabled" id="p3-email-results-results" style="width: 95%; height: 120px;"><?php
1037
  echo "WordPress Plugin Profile Report\n";
1038
  echo "===========================================\n";
1039
+ echo 'Report date: ' . date( 'D M j, Y', $this->profile->report_date ) . "\n";
1040
+ echo 'Theme name: ' . $this->profile->theme_name . "\n";
1041
+ echo 'Pages browsed: ' . $this->profile->visits . "\n";
1042
+ echo 'Avg. load time: ' . sprintf( '%.4f', $this->profile->averages['site'] ) . " sec\n";
1043
+ echo 'Number of plugins: ' . count( $this->profile->detected_plugins ) . " \n";
1044
+ echo 'Plugin impact: ' . sprintf( '%.2f%%', $this->profile->averages['plugin_impact'] ) . " % of load time\n";
1045
+ echo 'Avg. plugin time: ' . sprintf( '%.4f', $this->profile->averages['plugins'] ) . " sec\n";
1046
+ echo 'Avg. core time: ' . sprintf( '%.4f', $this->profile->averages['core'] ) . " sec\n";
1047
+ echo 'Avg. theme time: ' . sprintf( '%.4f', $this->profile->averages['theme'] ) . " sec\n";
1048
+ echo 'Avg. mem usage: ' . number_format( $this->profile->averages['memory'] / 1024 / 1024, 2 ) . " MB\n";
1049
+ echo 'Avg. plugin calls: ' . number_format( $this->profile->averages['plugin_calls'] ) . "\n";
1050
+ echo 'Avg. db queries : ' . sprintf( '%.2f', $this->profile->averages['queries'] ) . "\n";
1051
+ echo 'Margin of error : ' . sprintf( '%.4f', $this->profile->averages['drift'] ) . " sec\n";
1052
  echo "\nPlugin list:\n";
1053
  echo "===========================================\n";
1054
+ foreach ( $this->profile->plugin_times as $k => $v) {
1055
+ echo $k . ' - ' . sprintf('%.4f sec', $v) . ' - ' . sprintf( '%.2f%%', $v * 100 / array_sum( $this->profile->plugin_times ) ) . "\n";
1056
  }
1057
  ?></textarea>
1058
  </div>
1059
+ <input type="hidden" id="p3-email-results-scan" value="<?php echo basename( $this->scan ); ?>" />
1060
  </div>
1061
 
1062
  <!-- Email sending dialog -->