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 +179 -44 1.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,26 +22,32 @@
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
37 -$cp_options = get_option( 'code-profiler' );
47 +$cp_options = get_option('code-profiler');
38 48
39 49 ?>
40 -<h3><?php esc_html_e('General Settings', 'code-profiler') ?></h3>
41 -
42 50 <form method="post">
43 51 <?php wp_nonce_field('cp_settings', 'cp-save-settings', 0); ?>
44 52 <table class="form-table">
45 53 <?php
@@ -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>
@@ -51,20 +61,24 @@
51 61 ?>
52 62 <tr>
53 63 <th scope="row"><?php esc_html_e('Paths','code-profiler') ?></th>
54 64 <td>
55 - <p><label><input type="radio" name="cp_options[show_paths]"<?php checked( $cp_options['show_paths'], 'absolute' ) ?> value="absolute" /><?php printf( esc_html__('Show absolute paths (e.g., %s)','code-profiler'), esc_html( ABSPATH ) .'wp-admin/index.php' ) ?></label></p>
56 - <p><label><input type="radio" name="cp_options[show_paths]"<?php checked( $cp_options['show_paths'], 'relative' ) ?> value="relative" /><?php printf( esc_html__('Show relative paths (e.g., %s)','code-profiler'), 'wp-admin/index.php' ) ?></label></p>
65 + <p><label><input type="radio" name="cp_options[show_paths]"<?php checked( $cp_options['show_paths'], 'absolute') ?> value="absolute" /><?php printf( esc_html__('Show absolute paths (e.g., %s)','code-profiler'), esc_html( ABSPATH ) .'wp-admin/index.php') ?></label></p>
66 + <p><label><input type="radio" name="cp_options[show_paths]"<?php checked( $cp_options['show_paths'], 'relative') ?> value="relative" /><?php printf( esc_html__('Show relative paths (e.g., %s)','code-profiler'), 'wp-admin/index.php') ?></label></p>
57 67 </td>
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>
@@ -69,10 +83,10 @@
69 83 ?>
70 84 <tr>
71 85 <th scope="row"><?php esc_html_e('Plugins & Themes','code-profiler') ?></th>
72 86 <td>
73 - <p><label><input type="radio" name="cp_options[display_name]"<?php checked( $cp_options['display_name'], 'full' ) ?> value="full" /><?php printf( esc_html__('Show real names (e.g., %s)','code-profiler'), 'Super Plugin Pro for WordPress' ) ?></label></p>
74 - <p><label><input type="radio" name="cp_options[display_name]"<?php checked( $cp_options['display_name'], 'slug' ) ?> value="slug" /><?php printf( esc_html__('Show slugs (e.g., %s)','code-profiler'), 'super-plugin-pro' ) ?></label></p>
87 + <p><label><input type="radio" name="cp_options[display_name]"<?php checked( $cp_options['display_name'], 'full') ?> value="full" /><?php printf( esc_html__('Show real names (e.g., %s)','code-profiler'), 'Super Plugin Pro for WordPress') ?></label></p>
88 + <p><label><input type="radio" name="cp_options[display_name]"<?php checked( $cp_options['display_name'], 'slug') ?> value="slug" /><?php printf( esc_html__('Show slugs (e.g., %s)','code-profiler'), 'super-plugin-pro') ?></label></p>
75 89 <br />
76 90 <p><label><?php
77 91 printf(
78 92 esc_html__('Truncate names to %s characters', 'code-profiler'),
@@ -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'] ) ) {
@@ -101,10 +119,10 @@
101 119 ?>
102 120 <tr>
103 121 <th scope="row"><?php esc_html_e('Tables & Charts','code-profiler') ?></th>
104 122 <td>
105 - <p><label><input type="radio" name="cp_options[chart_type]"<?php checked( $cp_options['chart_type'], 'x' ) ?> value="x" /><?php printf( esc_html__('Display horizontal charts by default','code-profiler'), 'Super Plugin Pro for WordPress' ) ?></label></p>
106 - <p><label><input type="radio" name="cp_options[chart_type]"<?php checked( $cp_options['chart_type'], 'y' ) ?> value="y" /><?php printf( esc_html__('Display vertical charts by default','code-profiler'), 'super-plugin-pro' ) ?></label></p>
123 + <p><label><input type="radio" name="cp_options[chart_type]"<?php checked( $cp_options['chart_type'], 'x') ?> value="x" /><?php esc_html_e('Display horizontal charts by default','code-profiler') ?></label></p>
124 + <p><label><input type="radio" name="cp_options[chart_type]"<?php checked( $cp_options['chart_type'], 'y') ?> value="y" /><?php esc_html_e('Display vertical charts by default','code-profiler') ?></label></p>
107 125 <p class="description"><?php esc_html_e('You can switch between vertical and horizontal by clicking the corresponding button located below each chart.', 'code-profiler') ?></p>
108 126
109 127 <br />
110 128
@@ -117,9 +135,9 @@
117 135 <p class="description"><?php esc_html_e('More than 30 plugins will be difficult to read on most charts. Note that only plugins that have a negligible impact on your website\'s performance will be hidden.', 'code-profiler') ?></p>
118 136
119 137 <br />
120 138
121 - <p><label><input type="checkbox" name="cp_options[hide_empty_value]"<?php checked( $cp_options['hide_empty_value'], '1' ) ?> /><?php esc_html_e('Hide items that have an empty value.','code-profiler') ?></label></p>
139 + <p><label><input type="checkbox" name="cp_options[hide_empty_value]"<?php checked( $cp_options['hide_empty_value'], '1') ?> /><?php esc_html_e('Hide items that have an empty value.','code-profiler') ?></label></p>
122 140
123 141 <p class="description"><?php esc_html_e('This options will hide items that have an empty value on all graphs and tables.', 'code-profiler') ?></p>
124 142
125 143 </td>
@@ -140,19 +158,19 @@
140 158 }
141 159
142 160 // HTTP code to reject
143 161 if (! empty( $cp_options['http_response'] ) ) {
144 - if (! preg_match( "/{$cp_options['http_response']}/", '300' ) ) {
162 + if (! preg_match( "/{$cp_options['http_response']}/", '300') ) {
145 163 $http_response_300 = 0;
146 164 } else {
147 165 $http_response_300 = 1;
148 166 }
149 - if (! preg_match( "/{$cp_options['http_response']}/", '400' ) ) {
167 + if (! preg_match( "/{$cp_options['http_response']}/", '400') ) {
150 168 $http_response_400 = 0;
151 169 } else {
152 170 $http_response_400 = 1;
153 171 }
154 - if (! preg_match( "/{$cp_options['http_response']}/", '500' ) ) {
172 + if (! preg_match( "/{$cp_options['http_response']}/", '500') ) {
155 173 $http_response_500 = 0;
156 174 } else {
157 175 $http_response_500 = 1;
158 176 }
@@ -162,44 +180,129 @@
162 180 $http_response_500 = 0;
163 181 }
164 182 ?>
165 183 <tr>
166 - <th scope="row"><?php esc_html_e('Various', 'code-profiler') ?></th>
184 + <th scope="row"><?php esc_html_e('General Options', 'code-profiler') ?></th>
167 185 <td>
168 - <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>
169 - <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>
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>
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>
170 188
171 189 <br />
172 190
173 - <p><label><input type="checkbox" name="cp_options[disable_wpcron]"<?php checked( $cp_options['disable_wpcron'], '1' ) ?> /><?php esc_html_e('Disable WP-Cron when running the profiler.','code-profiler') ?></label></p>
191 + <p><label><input type="checkbox" name="cp_options[disable_wpcron]"<?php checked( $cp_options['disable_wpcron'], '1') ?> /><?php esc_html_e('Disable WP-Cron when running the profiler.','code-profiler') ?></label></p>
174 192
175 193 <p class="description"><?php esc_html_e('This option will prevent WP-Cron to run scheduled tasks in the background that could affect the results of the profiler.', 'code-profiler') ?></p>
176 194
177 195 <br />
178 196
179 - <p><?php esc_html_e('Stop the profiler and throw an error if the server returns any of the following HTTP status codes:', 'code-profiler' ) ?></p>
180 - <p><label><input type="checkbox" name="cp_options[http_response_300]" value="1"<?php checked( $http_response_300, '1' ) ?> /><?php esc_html_e('3xx redirection (301 Moved Permanently, 302 Found etc)','code-profiler') ?></label></p>
181 - <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>
182 - <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>
197 + <p><?php esc_html_e('Stop the profiler and throw an error if the server returns any of the following HTTP status codes:', 'code-profiler') ?></p>
198 + <p><label><input type="checkbox" name="cp_options[http_response_300]" value="1"<?php checked( $http_response_300, '1') ?> /><?php esc_html_e('3xx redirection (301 Moved Permanently, 302 Found etc)','code-profiler') ?></label></p>
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>
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>
183 201 </td>
184 202 </tr>
203 + </table>
185 204
205 + <h3><?php esc_html_e('Profiler','code-profiler') ?></h3>
206 + <table class="form-table">
207 + <?php
208 + // Accuracy
209 + if ( empty( $cp_options['accuracy'] ) ||
210 + ! preg_match('/^(?:1|5|10|15|20)$/D', $cp_options['accuracy'] ) ) {
211 +
212 + $cp_options['accuracy'] = 1;
213 + }
214 + ?>
215 + <tr>
216 + <th scope="row"><?php esc_html_e('Accuracy & Precision', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php
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');
218 + echo '<br />';
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');
220 + ?>"></span></th>
221 + <td>
222 + <p><label><?php esc_html_e('Select the accuracy and precision level of the profiler:', 'code-profiler') ?> &nbsp;<select name="cp_options[accuracy]">
223 + <?php
224 + foreach( CODE_PROFILER_ACCURACY as $key => $value ) {
225 + echo '<option value="'. esc_attr( $key ) .'"'. selected( $cp_options['accuracy'], $key, false ) .'>'. esc_html( $value ) .'</option>';
226 + }
227 + ?></select></label></p>
228 + </td>
229 + </tr>
230 + <?php
231 + $recommended = code_profiler_suggested_memory();
232 + // Buffer size
233 + if ( empty( $cp_options['buffer'] ) ) {
234 + $cp_options['buffer'] = 0;
235 + } elseif (! preg_match('/^(?:[1-9]|10)$/', $cp_options['buffer'] ) ) {
236 + $cp_options['buffer'] = (int) $recommended;
237 + }
238 + ?>
239 + <tr>
240 + <th scope="row"><?php esc_html_e('Buffer size', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php
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');
242 + ?>"></span></th>
243 + <td>
244 + <p>
245 + <label>
246 + <select name="cp_options[buffer]">
247 + <?php
248 + echo '<option value="0"'. selected( $cp_options['buffer'], 0, false ) .'>'.
249 + esc_html__('Automatic', 'code-profiler') .
250 + '</option>';
251 + for ( $i = 1; $i <= 10; $i++ ) {
252 + echo '<option value="'. $i .'"'. selected( $cp_options['buffer'], $i, false ) .'>'.
253 + sprintf(
254 + /* Translators: 'MB' for MegaBytes */
255 + esc_html__('%s MB', 'code-profiler')
256 + , $i ) .
257 + '</option>';
258 + }
259 + ?>
260 + </select>
261 + </label>
262 + </p>
263 + <p class="description"><?php
264 + printf(
265 + esc_html__('Recommended value based on your system configuration: %s MB', 'code-profiler'),
266 + (int) $recommended
267 + );
268 + ?></p>
269 + </td>
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>
186 287 </table>
187 288
188 - <p><input type="submit" name="save-settings" class="button-primary" value="<?php esc_html_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>
189 290
190 291 </form>
191 292 <?php
192 293
193 -// =====================================================================
294 +// ===================================================================== 2023-06-15
194 295 // Save and validate the settings.
195 296
196 297 function code_profiler_save_settings() {
197 298
198 - $cp_options = get_option( 'code-profiler' );
299 + $cp_options = get_option('code-profiler');
199 300
200 301 // Paths
201 - if ( empty( $_POST['cp_options']['show_paths'] ) || ! in_array( $_POST['cp_options']['show_paths'], ['absolute', 'relative' ] ) ) {
302 + if ( empty( $_POST['cp_options']['show_paths'] ) ||
303 + ! in_array( $_POST['cp_options']['show_paths'], ['absolute', 'relative' ] ) ) {
304 +
202 305 $cp_options['show_paths'] = 'relative';
203 306 } else {
204 307 $cp_options['show_paths'] = sanitize_key( $_POST['cp_options']['show_paths'] );
205 308 }
@@ -204,9 +307,11 @@
204 307 $cp_options['show_paths'] = sanitize_key( $_POST['cp_options']['show_paths'] );
205 308 }
206 309
207 310 // Name vs slug
208 - if ( empty( $_POST['cp_options']['display_name'] ) || ! in_array( $_POST['cp_options']['display_name'], ['full', 'slug' ] ) ) {
311 + if ( empty( $_POST['cp_options']['display_name'] ) ||
312 + ! in_array( $_POST['cp_options']['display_name'], ['full', 'slug' ] ) ) {
313 +
209 314 $cp_options['display_name'] = 'full';
210 315 } else {
211 316 $cp_options['display_name'] = sanitize_key( $_POST['cp_options']['display_name'] );
212 317 }
@@ -211,9 +316,11 @@
211 316 $cp_options['display_name'] = sanitize_key( $_POST['cp_options']['display_name'] );
212 317 }
213 318
214 319 // Truncate names
215 - if ( empty( $_POST['cp_options']['truncate_name'] ) || ! preg_match( '/^\d+$/', ( $_POST['cp_options']['truncate_name'] ) ) ) {
320 + if ( empty( $_POST['cp_options']['truncate_name'] ) ||
321 + ! preg_match('/^\d+$/', ( $_POST['cp_options']['truncate_name'] ) ) ) {
322 +
216 323 $cp_options['truncate_name'] = 30;
217 324 } else {
218 325 $cp_options['truncate_name'] = (int) $_POST['cp_options']['truncate_name'];
219 326 }
@@ -218,9 +325,11 @@
218 325 $cp_options['truncate_name'] = (int) $_POST['cp_options']['truncate_name'];
219 326 }
220 327
221 328 // chart type
222 - if ( empty( $_POST['cp_options']['chart_type'] ) || ! in_array( $_POST['cp_options']['chart_type'], ['x', 'y' ] ) ) {
329 + if ( empty( $_POST['cp_options']['chart_type'] ) ||
330 + ! in_array( $_POST['cp_options']['chart_type'], ['x', 'y' ] ) ) {
331 +
223 332 $cp_options['chart_type'] = 'x';
224 333 } else {
225 334 $cp_options['chart_type'] = sanitize_key( $_POST['cp_options']['chart_type'] );
226 335 }
@@ -225,9 +334,11 @@
225 334 $cp_options['chart_type'] = sanitize_key( $_POST['cp_options']['chart_type'] );
226 335 }
227 336
228 337 // Max plugins to display
229 - if ( empty( $_POST['cp_options']['chart_max_plugins'] ) || ! preg_match( '/^\d+$/', ( $_POST['cp_options']['chart_max_plugins'] ) ) ) {
338 + if ( empty( $_POST['cp_options']['chart_max_plugins'] ) ||
339 + ! preg_match('/^\d+$/', ( $_POST['cp_options']['chart_max_plugins'] ) ) ) {
340 +
230 341 $cp_options['chart_max_plugins'] = 25;
231 342 } else {
232 343 $cp_options['chart_max_plugins'] = (int) $_POST['cp_options']['chart_max_plugins'];
233 344 }
@@ -238,11 +349,8 @@
238 349 } else {
239 350 $cp_options['hide_empty_value'] = 0;
240 351 }
241 352
242 - // Composer warning
243 - $cp_options['warn_composer'] = 1;
244 -
245 353 // WP-CLI integration
246 354 if (! empty( $_POST['cp_options']['enable_wpcli'] ) ) {
247 355 $cp_options['enable_wpcli'] = 1;
248 356 } else {
@@ -267,14 +375,41 @@
267 375 }
268 376 if (! empty( $_POST['cp_options']['http_response_500'] ) ) {
269 377 $code .= '5';
270 378 }
271 - $code = rtrim( $code, '|' );
379 + $code = rtrim( $code, '|');
272 380 if (! empty( $code ) ) {
273 381 $cp_options['http_response'] = "^(?:$code)\d{2}$";
274 382 }
275 383
276 - return update_option( 'code-profiler', $cp_options );
384 + // Accuracy
385 + if ( empty( $_POST['cp_options']['accuracy'] ) ||
386 + ! preg_match('/^(?:1|5|10|15|20)$/D', $_POST['cp_options']['accuracy'] ) ) {
387 +
388 + $cp_options['accuracy'] = 1;
389 + } else {
390 + $cp_options['accuracy'] = (int) $_POST['cp_options']['accuracy'];
391 + }
392 +
393 + // Buffer size
394 + if ( empty( $_POST['cp_options']['buffer'] ) ) {
395 + $cp_options['buffer'] = 0;
396 + } elseif (! preg_match('/^(?:[1-9]|10)$/D', $_POST['cp_options']['buffer'] ) ) {
397 + $cp_options['buffer'] = 10;
398 + } else {
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;
409 + }
410 +
411 + return update_option('code-profiler', $cp_options );
277 412
278 413 }
279 414
280 415 // =====================================================================