PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.6
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.6
1.9.5 1.9.4 1.9.3 trunk 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 All 40 releases
← All changes | lib/menu_log.php +27 -14 1.51.6 View file →
@@ -10,9 +10,11 @@
10 10 | (c) Jerome Bruandet ~ https://code-profiler.com/ |
11 11 +=====================================================================+
12 12 */
13 13
14 -if (! defined( 'ABSPATH' ) ) { die( 'Forbidden' ); }
14 +if (! defined('ABSPATH') ) {
15 + die('Forbidden');
16 +}
15 17
16 18 // =====================================================================
17 19 // Display the profiler's log.
18 20
@@ -17,25 +19,25 @@
17 19 // Display the profiler's log.
18 20
19 21 // Delete the log?
20 22 if (! empty( $_POST['cp-delete-log'] ) ) {
21 - if ( empty( $_POST['cp_nonce'] ) || ! wp_verify_nonce( $_POST['cp_nonce'], 'cp_delete_log' ) ) {
23 + if ( empty( $_POST['cp_nonce'] ) || ! wp_verify_nonce( $_POST['cp_nonce'], 'cp_delete_log') ) {
22 24 printf(
23 25 CODE_PROFILER_ERROR_NOTICE,
24 - esc_html__('Security nonce is missing, try to reload the page.', 'code-profiler' )
26 + esc_html__('Security nonce is missing, try to reload the page.', 'code-profiler')
25 27 );
26 28
27 29 } else {
28 - $res = file_put_contents( CODE_PROFILER_LOG, "<?php exit; ?>\n" );
30 + $res = file_put_contents( CODE_PROFILER_LOG, "<?php exit; ?>\n");
29 31 if ( $res !== false ) {
30 32 printf(
31 33 CODE_PROFILER_UPDATE_NOTICE,
32 - esc_html__('The log was deleted.', 'code-profiler' )
34 + esc_html__('The log was deleted.', 'code-profiler')
33 35 );
34 36 } else {
35 37 printf(
36 38 CODE_PROFILER_ERROR_NOTICE,
37 - esc_html__('Cannot delete the log, make sure it is writable.', 'code-profiler' )
39 + esc_html__('Cannot delete the log, make sure it is writable.', 'code-profiler')
38 40 );
39 41 }
40 42 }
41 43 }
@@ -43,21 +45,23 @@
43 45 <script>
44 46 'use strict';
45 47 var cplog_array = new Array();
46 48 <?php
47 -$info = 0; $warn = 0; $error = 0; $logline = '';
49 +$info = 0; $warn = 0; $error = 0; $debug = 0; $logline = '';
48 50 if ( file_exists( CODE_PROFILER_LOG ) ) {
49 51
50 -
51 52 $lines = array();
52 53 $lines = file( CODE_PROFILER_LOG, FILE_SKIP_EMPTY_LINES );
53 54 $i = 0;
54 - $facility = array( 1 => 'INFO ', 2 => 'WARN ', 4 => 'ERROR' );
55 + $facility = array( 1 => 'INFO ', 2 => 'WARN ', 4 => 'ERROR', 8 => 'DEBUG');
55 56 foreach( $lines as $line ) {
56 - if ( $line[0] == '<' ) { continue; }
57 - list( $date, $level, $string ) = explode( '~~', $line, 3 );
58 - $date = date( 'd-M-y H:i:s', $date );
59 - echo 'cplog_array[' . (int)$i . '] = "' .
57 + if ( $line[0] == '<') { continue; }
58 + list( $date, $level, $string ) = explode('~~', $line, 3 );
59 + if (! isset( $facility[$level] ) ) {
60 + continue;
61 + }
62 + $date = date('d-M-y H:i:s', $date );
63 + echo 'cplog_array[' . $i . '] = "' .
60 64 rawurlencode( "$level~~$date {$facility[$level]} $string" ) ."\";\n";
61 65 ++$i;
62 66 if ( $level == 1 ) {
63 67 $info = 1;
@@ -64,8 +68,11 @@
64 68 } elseif ( $level == 2 ) {
65 69 $warn = 1;
66 70 } elseif ( $level == 4 ) {
67 71 $error = 1;
72 + } elseif ( $level == 8 ) {
73 + $debug = 1;
74 + continue;
68 75 }
69 76 $logline .= "$date {$facility[$level]} $string";
70 77 }
71 78 }
@@ -118,11 +125,17 @@
118 125 <label for="cxerror">
119 126 <input id="cxerror" type="checkbox" name="error"<?php echo $error_checked ?><?php disabled( $error, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
120 127 <span style="display: inline-block"><?php esc_html_e('Error', 'code-profiler') ?></span>&nbsp;
121 128 </label>
129 + &nbsp;&nbsp;&nbsp;&nbsp;
130 + <label for="cxdebug">
131 + <input id="cxdebug" type="checkbox" name="debug"<?php disabled( $debug, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
132 + <span style="display: inline-block"><?php esc_html_e('Debug', 'code-profiler') ?></span>&nbsp;
133 + </label>
122 134 </p>
123 - <input type="submit" onclick="return cpjs_delete_log();" name="cp-delete-log" class="button-primary" value="<?php esc_attr_e('Delete log', 'code-profiler') ?>"<?php disabled( $logline, '' ) ?> />
135 + <input type="submit" onclick="return cpjs_delete_log();" name="cp-delete-log" class="button-primary" value="<?php esc_attr_e('Delete log', 'code-profiler') ?>"<?php disabled( $logline, '') ?> />
124 136 <?php wp_nonce_field('cp_delete_log', 'cp_nonce', 0); ?>
137 + <p class="description"><?php esc_html_e('The log is deleted automatically when it reaches 100KB.', 'code-profiler') ?></p>
125 138 </td>
126 139 </tr>
127 140 </table>
128 141 </form>