PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.9.6
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.9.6
1.9.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 All 41 releases
← All changes | lib/menu_settings.php +65 -36 1.6.41.9.6 View file →
@@ -6,13 +6,15 @@
6 6 | | | / _ \ / _` |/ _ \ | |_) | '__/ _ \| |_| | |/ _ \ '__| |
7 7 | | |__| (_) | (_| | __/ | __/| | | (_) | _| | | __/ | |
8 8 | \____\___/ \__,_|\___| |_| |_| \___/|_| |_|_|\___|_| |
9 9 | |
10 - | (c) Jerome Bruandet ~ https://code-profiler.com/ |
10 + | (c) Jerome Bruandet ~ https://nintechnet.com/codeprofiler/ |
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 Summary tab.
18 20
@@ -20,17 +22,25 @@
20 22
21 23 // Save settings?
22 24 if (! empty( $_POST['save-settings'] ) ) {
23 25 // Make sure we have security nonce
24 - if ( empty( $_POST['cp-save-settings'] ) || ! wp_verify_nonce($_POST['cp-save-settings'], 'cp_settings') ) {
26 + if ( empty( $_POST['cp-save-settings'] ) ||
27 + ! wp_verify_nonce($_POST['cp-save-settings'], 'cp_settings') ) {
28 +
25 29 wp_nonce_ays('cp_settings');
26 30 }
27 31 $res = code_profiler_save_settings();
28 32 if ( $res === true ) {
29 - printf( CODE_PROFILER_UPDATE_NOTICE, esc_html__('Your changes have been saved.', 'code-profiler') );
33 + printf(
34 + CODE_PROFILER_UPDATE_NOTICE,
35 + esc_html__('Your changes have been saved.', 'code-profiler')
36 + );
30 37 }
31 38 else {
32 - printf( CODE_PROFILER_ERROR_NOTICE, esc_html__('No changes were detected.', 'code-profiler') );
39 + printf(
40 + CODE_PROFILER_ERROR_NOTICE,
41 + esc_html__('No changes were detected.', 'code-profiler')
42 + );
33 43 }
34 44 }
35 45
36 46 // Fetch current options
@@ -42,9 +52,11 @@
42 52 <table class="form-table">
43 53 <?php
44 54
45 55 // Paths
46 - if ( empty( $cp_options['show_paths'] ) || ! in_array( $cp_options['show_paths'], ['absolute', 'relative' ] ) ) {
56 + if ( empty( $cp_options['show_paths'] ) ||
57 + ! in_array( $cp_options['show_paths'], ['absolute', 'relative' ] ) ) {
58 +
47 59 $cp_options['show_paths'] = 'relative';
48 60 }
49 61 ?>
50 62 <tr>
@@ -56,13 +68,17 @@
56 68 </tr>
57 69
58 70 <?php
59 71 // Name vs slug
60 - if ( empty( $cp_options['display_name'] ) || ! in_array( $cp_options['display_name'], ['full', 'slug' ] ) ) {
72 + if ( empty( $cp_options['display_name'] ) ||
73 + ! in_array( $cp_options['display_name'], ['full', 'slug' ] ) ) {
74 +
61 75 $cp_options['display_name'] = 'full';
62 76 }
63 77 // Truncate names
64 - if ( empty( $cp_options['truncate_name'] ) || ! preg_match('/^\d+$/', ( $cp_options['truncate_name'] ) ) ) {
78 + if ( empty( $cp_options['truncate_name'] ) ||
79 + ! preg_match('/^\d+$/', ( $cp_options['truncate_name'] ) ) ) {
80 +
65 81 $cp_options['truncate_name'] = 30;
66 82 }
67 83 ?>
68 84 <tr>
@@ -82,13 +98,17 @@
82 98 </tr>
83 99
84 100 <?php
85 101 // chart type
86 - if ( empty( $cp_options['chart_type'] ) || ! in_array( $cp_options['chart_type'], ['x', 'y' ] ) ) {
102 + if ( empty( $cp_options['chart_type'] ) ||
103 + ! in_array( $cp_options['chart_type'], ['x', 'y' ] ) ) {
104 +
87 105 $cp_options['chart_type'] = 'x';
88 106 }
89 107 // Max plugins to display
90 - if ( empty( $cp_options['chart_max_plugins'] ) || ! preg_match('/^\d+$/', ( $cp_options['chart_max_plugins'] ) ) ) {
108 + if ( empty( $cp_options['chart_max_plugins'] ) ||
109 + ! preg_match('/^\d+$/', ( $cp_options['chart_max_plugins'] ) ) ) {
110 +
91 111 $cp_options['chart_max_plugins'] = 25;
92 112 }
93 113 // Empty values
94 114 if (! empty( $cp_options['hide_empty_value'] ) ) {
@@ -123,14 +143,8 @@
123 143 </td>
124 144 </tr>
125 145
126 146 <?php
127 - // Composer warning
128 - if (! empty( $cp_options['warn_composer'] ) ) {
129 - $cp_options['warn_composer'] = 1;
130 - } else {
131 - $cp_options['warn_composer'] = 0;
132 - }
133 147 // WP-CLI integration
134 148 if (! empty( $cp_options['enable_wpcli'] ) ) {
135 149 $cp_options['enable_wpcli'] = 1;
136 150 } else {
@@ -168,14 +182,8 @@
168 182 ?>
169 183 <tr>
170 184 <th scope="row"><?php esc_html_e('General Options', 'code-profiler') ?></th>
171 185 <td>
172 - <p><label><input type="checkbox" name="cp_options[warn_composer]"<?php checked( $cp_options['warn_composer'], '1') ?> /><?php esc_html_e('Show a notice when several plugins are using Composer dependency manager.','code-profiler') ?></label></p>
173 -
174 - <p class="description"><?php esc_html_e('Consult the FAQ tab for more details about this option.', 'code-profiler') ?></p>
175 -
176 - <br />
177 -
178 186 <p><label><input type="checkbox" name="cp_options[enable_wpcli]"<?php checked( $cp_options['enable_wpcli'], '1') ?> /><?php esc_html_e('Enable WP-CLI integration.','code-profiler') ?></label></p>
179 187 <p class="description"><?php printf( esc_html__('Enter %s to display the available command line options.', 'code-profiler'), '<code>wp code-profiler help</code>') ?></p>
180 188
181 189 <br />
@@ -191,20 +199,23 @@
191 199 <p><label><input type="checkbox" name="cp_options[http_response_400]" value="1"<?php checked( $http_response_400, '1') ?> /><?php esc_html_e('4xx client errors (400 Bad Request, 403 Forbidden, 404 Not Found etc)','code-profiler') ?></label></p>
192 200 <p><label><input type="checkbox" name="cp_options[http_response_500]" value="1"<?php checked( $http_response_500, '1') ?> /><?php esc_html_e('5xx server errors (500 Internal Server Error, 503 Service Unavailable etc)','code-profiler') ?></label></p>
193 201 </td>
194 202 </tr>
203 + </table>
204 +
205 + <h3><?php esc_html_e('Profiler','code-profiler') ?></h3>
206 + <table class="form-table">
195 207 <?php
196 208 // Accuracy
197 - if ( empty( $cp_options['accuracy'] ) || ! preg_match('/^(?:1|5|10|15|20)$/D', $cp_options['accuracy'] ) ) {
209 + if ( empty( $cp_options['accuracy'] ) ||
210 + ! preg_match('/^(?:1|5|10|15|20)$/D', $cp_options['accuracy'] ) ) {
211 +
198 212 $cp_options['accuracy'] = 1;
199 213 }
200 214 ?>
201 215 <tr>
202 216 <th scope="row"><?php esc_html_e('Accuracy & Precision', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php
203 - printf(
204 - esc_attr__('When accuracy is set to the highest level, Code Profiler runs as a %s Tracing profiler %s, and when accuracy is set to a lower level, it runs as a %s Sampling profiler %s.', 'code-profiler'),
205 - '<em>', '</em>','<em>', '</em>'
206 - );
217 + esc_attr_e('When accuracy is set to the highest level, Code Profiler runs as a "tracing profiler", and when accuracy is set to a lower level, it runs as a "sampling profiler".', 'code-profiler');
207 218 echo '<br />';
208 219 esc_attr_e('Selecting a high accuracy level is preferred and will work on most sites, but the profiling process will take longer to execute as opposed to choosing a lower accuracy level. If you have a slow WordPress site with a lot of plugins installed and your server or reverse proxy is timing out when Code Profiler is running (e.g., "503 Service Unavailable" or "504 Gateway Timeout" error), try to lower the accuracy level in order to speed up the profiling process and avoid the server timeout.', 'code-profiler');
209 220 ?>"></span></th>
210 221 <td>
@@ -226,9 +237,9 @@
226 237 }
227 238 ?>
228 239 <tr>
229 240 <th scope="row"><?php esc_html_e('Buffer size', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php
230 - esc_attr_e('When running, the profiler collects data and saves it to a memory buffer. When the buffer is full, the data is written to disk. If your site uses too much memory and throws a PHP memory error, you can try to lower that value.', 'code-profiler');
241 + esc_attr_e('When running, the profiler collects data and saves it to a memory buffer. When the buffer is full, the data is written to disk. If your site uses too much memory and PHP throws a memory error, you can try to lower that value.', 'code-profiler');
231 242 ?>"></span></th>
232 243 <td>
233 244 <p>
234 245 <label>
@@ -256,11 +267,27 @@
256 267 );
257 268 ?></p>
258 269 </td>
259 270 </tr>
271 + <?php
272 + if ( empty( $cp_options['php_error'] ) ) {
273 + $cp_options['php_error'] = 0;
274 + } else {
275 + $cp_options['php_error'] = 1;
276 + }
277 + ?>
278 + <tr>
279 + <th scope="row"><?php esc_html_e('PHP Error Logging', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php
280 + esc_attr_e('This option will enable PHP error logging when the profiler is running. The log will be saved by default to "/wp-content/debug.log", unless you configured PHP or WordPress to use a different path.', 'code-profiler');
281 + ?>"></span>
282 + </th>
283 + <td>
284 + <p><label><input type="checkbox" name="cp_options[php_error]"<?php checked( $cp_options['php_error'], '1') ?> /><?php esc_html_e('Enable PHP error logging.','code-profiler') ?></label></p>
285 + </td>
286 + </tr>
260 287 </table>
261 288
262 - <p><input type="submit" name="save-settings" class="button-primary" value="<?php esc_attr_e('Save Settings', 'code-profiler') ?>" /></p>
289 + <p><input type="submit" name="save-settings" class="button button-primary" value="<?php esc_attr_e('Save Settings', 'code-profiler') ?>" /></p>
263 290
264 291 </form>
265 292 <?php
266 293
@@ -322,15 +349,8 @@
322 349 } else {
323 350 $cp_options['hide_empty_value'] = 0;
324 351 }
325 352
326 - // Composer warning
327 - if (! empty( $_POST['cp_options']['warn_composer'] ) ) {
328 - $cp_options['warn_composer'] = 1;
329 - } else {
330 - $cp_options['warn_composer'] = 0;
331 - }
332 -
333 353 // WP-CLI integration
334 354 if (! empty( $_POST['cp_options']['enable_wpcli'] ) ) {
335 355 $cp_options['enable_wpcli'] = 1;
336 356 } else {
@@ -376,8 +396,17 @@
376 396 } elseif (! preg_match('/^(?:[1-9]|10)$/D', $_POST['cp_options']['buffer'] ) ) {
377 397 $cp_options['buffer'] = 10;
378 398 } else {
379 399 $cp_options['buffer'] = (int) $_POST['cp_options']['buffer'];
400 + }
401 +
402 + /**
403 + * PHP error logging.
404 + */
405 + if (! empty( $_POST['cp_options']['php_error'] ) ) {
406 + $cp_options['php_error'] = 1;
407 + } else {
408 + $cp_options['php_error'] = 0;
380 409 }
381 410
382 411 return update_option('code-profiler', $cp_options );
383 412