| @@ -6,14 +6,14 @@ | ||
| 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') ) { | |
| 15 | - die('Forbidden'); | |
| 14 | +if (! defined('ABSPATH') ) { | |
| 15 | + die('Forbidden'); | |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // ===================================================================== |
| 19 | 19 | // Display Summary tab. |
| @@ -22,17 +22,25 @@ | ||
| 22 | 22 | |
| 23 | 23 | // Save settings? |
| 24 | 24 | if (! empty( $_POST['save-settings'] ) ) { |
| 25 | 25 | // Make sure we have security nonce |
| 26 | - 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 | + | |
| 27 | 29 | wp_nonce_ays('cp_settings'); |
| 28 | 30 | } |
| 29 | 31 | $res = code_profiler_save_settings(); |
| 30 | 32 | if ( $res === true ) { |
| 31 | - 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 | + ); | |
| 32 | 37 | } |
| 33 | 38 | else { |
| 34 | - 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 | + ); | |
| 35 | 43 | } |
| 36 | 44 | } |
| 37 | 45 | |
| 38 | 46 | // Fetch current options |
| @@ -44,9 +52,11 @@ | ||
| 44 | 52 | <table class="form-table"> |
| 45 | 53 | <?php |
| 46 | 54 | |
| 47 | 55 | // Paths |
| 48 | - 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 | + | |
| 49 | 59 | $cp_options['show_paths'] = 'relative'; |
| 50 | 60 | } |
| 51 | 61 | ?> |
| 52 | 62 | <tr> |
| @@ -58,13 +68,17 @@ | ||
| 58 | 68 | </tr> |
| 59 | 69 | |
| 60 | 70 | <?php |
| 61 | 71 | // Name vs slug |
| 62 | - 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 | + | |
| 63 | 75 | $cp_options['display_name'] = 'full'; |
| 64 | 76 | } |
| 65 | 77 | // Truncate names |
| 66 | - 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 | + | |
| 67 | 81 | $cp_options['truncate_name'] = 30; |
| 68 | 82 | } |
| 69 | 83 | ?> |
| 70 | 84 | <tr> |
| @@ -84,13 +98,17 @@ | ||
| 84 | 98 | </tr> |
| 85 | 99 | |
| 86 | 100 | <?php |
| 87 | 101 | // chart type |
| 88 | - 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 | + | |
| 89 | 105 | $cp_options['chart_type'] = 'x'; |
| 90 | 106 | } |
| 91 | 107 | // Max plugins to display |
| 92 | - 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 | + | |
| 93 | 111 | $cp_options['chart_max_plugins'] = 25; |
| 94 | 112 | } |
| 95 | 113 | // Empty values |
| 96 | 114 | if (! empty( $cp_options['hide_empty_value'] ) ) { |
| @@ -125,14 +143,8 @@ | ||
| 125 | 143 | </td> |
| 126 | 144 | </tr> |
| 127 | 145 | |
| 128 | 146 | <?php |
| 129 | - // Composer warning | |
| 130 | - if (! empty( $cp_options['warn_composer'] ) ) { | |
| 131 | - $cp_options['warn_composer'] = 1; | |
| 132 | - } else { | |
| 133 | - $cp_options['warn_composer'] = 0; | |
| 134 | - } | |
| 135 | 147 | // WP-CLI integration |
| 136 | 148 | if (! empty( $cp_options['enable_wpcli'] ) ) { |
| 137 | 149 | $cp_options['enable_wpcli'] = 1; |
| 138 | 150 | } else { |
| @@ -170,14 +182,8 @@ | ||
| 170 | 182 | ?> |
| 171 | 183 | <tr> |
| 172 | 184 | <th scope="row"><?php esc_html_e('General Options', 'code-profiler') ?></th> |
| 173 | 185 | <td> |
| 174 | - <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> | |
| 175 | - | |
| 176 | - <p class="description"><?php esc_html_e('Consult the FAQ tab for more details about this option.', 'code-profiler') ?></p> | |
| 177 | - | |
| 178 | - <br /> | |
| 179 | - | |
| 180 | 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> |
| 181 | 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> |
| 182 | 188 | |
| 183 | 189 | <br /> |
| @@ -199,9 +205,11 @@ | ||
| 199 | 205 | <h3><?php esc_html_e('Profiler','code-profiler') ?></h3> |
| 200 | 206 | <table class="form-table"> |
| 201 | 207 | <?php |
| 202 | 208 | // Accuracy |
| 203 | - 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 | + | |
| 204 | 212 | $cp_options['accuracy'] = 1; |
| 205 | 213 | } |
| 206 | 214 | ?> |
| 207 | 215 | <tr> |
| @@ -259,8 +267,24 @@ | ||
| 259 | 267 | ); |
| 260 | 268 | ?></p> |
| 261 | 269 | </td> |
| 262 | 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> | |
| 263 | 287 | </table> |
| 264 | 288 | |
| 265 | 289 | <p><input type="submit" name="save-settings" class="button button-primary" value="<?php esc_attr_e('Save Settings', 'code-profiler') ?>" /></p> |
| 266 | 290 | |
| @@ -325,15 +349,8 @@ | ||
| 325 | 349 | } else { |
| 326 | 350 | $cp_options['hide_empty_value'] = 0; |
| 327 | 351 | } |
| 328 | 352 | |
| 329 | - // Composer warning | |
| 330 | - if (! empty( $_POST['cp_options']['warn_composer'] ) ) { | |
| 331 | - $cp_options['warn_composer'] = 1; | |
| 332 | - } else { | |
| 333 | - $cp_options['warn_composer'] = 0; | |
| 334 | - } | |
| 335 | - | |
| 336 | 353 | // WP-CLI integration |
| 337 | 354 | if (! empty( $_POST['cp_options']['enable_wpcli'] ) ) { |
| 338 | 355 | $cp_options['enable_wpcli'] = 1; |
| 339 | 356 | } else { |
| @@ -379,8 +396,17 @@ | ||
| 379 | 396 | } elseif (! preg_match('/^(?:[1-9]|10)$/D', $_POST['cp_options']['buffer'] ) ) { |
| 380 | 397 | $cp_options['buffer'] = 10; |
| 381 | 398 | } else { |
| 382 | 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; | |
| 383 | 409 | } |
| 384 | 410 | |
| 385 | 411 | return update_option('code-profiler', $cp_options ); |
| 386 | 412 | |