| @@ -6,9 +6,9 @@ | ||
| 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 | 14 | if (! defined('ABSPATH') ) { die('Forbidden'); } |
| @@ -42,8 +42,11 @@ | ||
| 42 | 42 | |
| 43 | 43 | // Clear the log if it's too big |
| 44 | 44 | code_profiler_clearlog(); |
| 45 | 45 | |
| 46 | +// Clean-up temp files left in the profiles folder | |
| 47 | +code_profiler_cleantmpfiles(); | |
| 48 | + | |
| 46 | 49 | $home = home_url('/'); // Frontend |
| 47 | 50 | $site = site_url('/'); // Backend |
| 48 | 51 | // Get user login name |
| 49 | 52 | $current_user = wp_get_current_user(); |
| @@ -76,8 +79,10 @@ | ||
| 76 | 79 | } |
| 77 | 80 | $cookies = ''; |
| 78 | 81 | $payload = ''; |
| 79 | 82 | $custom_headers = ''; |
| 83 | +$exclusions = []; | |
| 84 | + | |
| 80 | 85 | if ( isset( $cp_options['cookies'] ) ) { |
| 81 | 86 | // stripslashes is only needed for cookies |
| 82 | 87 | $cookies = trim( stripslashes( json_decode( $cp_options['cookies'] ) ) ); |
| 83 | 88 | } |
| @@ -91,8 +96,11 @@ | ||
| 91 | 96 | } |
| 92 | 97 | if ( isset( $cp_options['custom_headers'] ) ) { |
| 93 | 98 | $custom_headers = trim( json_decode( $cp_options['custom_headers'] ) ); |
| 94 | 99 | } |
| 100 | +if ( isset( $cp_options['exclusions'] ) ) { | |
| 101 | + $exclusions = json_decode( $cp_options['exclusions'] ); | |
| 102 | +} | |
| 95 | 103 | ?> |
| 96 | 104 | <table class="form-table"> |
| 97 | 105 | <tr> |
| 98 | 106 | <th scope="row"><?php esc_html_e('Page to profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Select the page you want the profiler to analyze. It can be in the frontend of the site, in the admin backend or a custom URL.', 'code-profiler') ?>"></span></th> |
| @@ -201,9 +209,9 @@ | ||
| 201 | 209 | </td> |
| 202 | 210 | </tr> |
| 203 | 211 | </table> |
| 204 | 212 | <?php |
| 205 | -if (! empty( $cookies ) || ! empty( $custom_headers ) || $cp_options['mem_method'] == 'post') { | |
| 213 | +if (! empty( $cookies ) || ! empty( $custom_headers ) || $cp_options['mem_method'] == 'post' || ! empty( $exclusions ) ) { | |
| 206 | 214 | echo '<div id="cp-advanced-settings">'; |
| 207 | 215 | $disabled_button = ' disabled'; |
| 208 | 216 | } else { |
| 209 | 217 | echo '<div id="cp-advanced-settings" style="display:none">'; |
| @@ -253,8 +261,19 @@ | ||
| 253 | 261 | <th scope="row" class="row-med"><?php esc_html_e('HTTP headers', 'code-profiler'); ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('You can use this field to add custom HTTP headers or even override existing ones (e.g., host, user-agent, accept-language etc). HTTP header names are case-insensitive and Code Profiler will automatically convert them to lowercase. HTTP header values are case-sensitive and only ASCII printable characters are allowed.', 'code-profiler') ?>"></span></th> |
| 254 | 262 | <td> |
| 255 | 263 | <textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" id="custom-headers" name="custom_headers" class="regular-text code" rows="6"><?php echo esc_textarea( $custom_headers ) ?></textarea> |
| 256 | 264 | <p class="description"><?php printf( esc_html__('Optional HTTP header in %s format, one item per line.', 'code-profiler'), '<code>name: value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/custom_headers.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?></p> |
| 265 | + </td> | |
| 266 | + </tr> | |
| 267 | + <tr> | |
| 268 | + <th scope="row" class="row-med"><?php esc_html_e('File and folder exclusions', 'code-profiler'); ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('This option lets you exclude files and folders from the profiling process. It can be a full path, a file or a folder name, or any part of them (substring). Values are case-sensitive and only ASCII printable characters are allowed.', 'code-profiler') ?>"></span></th> | |
| 269 | + <td> | |
| 270 | + <textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" id="exclusions" name="exclusions" class="regular-text code" rows="6"><?php | |
| 271 | + foreach( $exclusions as $item ) { | |
| 272 | + echo esc_textarea( $item ) ."\n"; | |
| 273 | + } | |
| 274 | + ?></textarea> | |
| 275 | + <p class="description"><?php esc_html_e('One item per line.', 'code-profiler') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/exclusions.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?></p> | |
| 257 | 276 | </td> |
| 258 | 277 | </tr> |
| 259 | 278 | </table> |
| 260 | 279 | </div> |