PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.7.4
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.7.4
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_settings.php +171 -42 1.41.7.4 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>
@@ -125,8 +143,14 @@
125 143 </td>
126 144 </tr>
127 145
128 146 <?php
147 + // Composer warning
148 + if (! empty( $cp_options['warn_composer'] ) ) {
149 + $cp_options['warn_composer'] = 1;
150 + } else {
151 + $cp_options['warn_composer'] = 0;
152 + }
129 153 // WP-CLI integration
130 154 if (! empty( $cp_options['enable_wpcli'] ) ) {
131 155 $cp_options['enable_wpcli'] = 1;
132 156 } else {
@@ -140,19 +164,19 @@
140 164 }
141 165
142 166 // HTTP code to reject
143 167 if (! empty( $cp_options['http_response'] ) ) {
144 - if (! preg_match( "/{$cp_options['http_response']}/", '300' ) ) {
168 + if (! preg_match( "/{$cp_options['http_response']}/", '300') ) {
145 169 $http_response_300 = 0;
146 170 } else {
147 171 $http_response_300 = 1;
148 172 }
149 - if (! preg_match( "/{$cp_options['http_response']}/", '400' ) ) {
173 + if (! preg_match( "/{$cp_options['http_response']}/", '400') ) {
150 174 $http_response_400 = 0;
151 175 } else {
152 176 $http_response_400 = 1;
153 177 }
154 - if (! preg_match( "/{$cp_options['http_response']}/", '500' ) ) {
178 + if (! preg_match( "/{$cp_options['http_response']}/", '500') ) {
155 179 $http_response_500 = 0;
156 180 } else {
157 181 $http_response_500 = 1;
158 182 }
@@ -162,44 +186,119 @@
162 186 $http_response_500 = 0;
163 187 }
164 188 ?>
165 189 <tr>
166 - <th scope="row"><?php esc_html_e('Various', 'code-profiler') ?></th>
190 + <th scope="row"><?php esc_html_e('General Options', 'code-profiler') ?></th>
167 191 <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>
192 + <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>
170 193
194 + <p class="description"><?php esc_html_e('Consult the FAQ tab for more details about this option.', 'code-profiler') ?></p>
195 +
171 196 <br />
172 197
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>
198 + <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>
199 + <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>
174 200
201 + <br />
202 +
203 + <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>
204 +
175 205 <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 206
177 207 <br />
178 208
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>
209 + <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>
210 + <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>
211 + <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>
212 + <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 213 </td>
184 214 </tr>
215 + </table>
185 216
217 + <h3><?php esc_html_e('Profiler','code-profiler') ?></h3>
218 + <table class="form-table">
219 + <?php
220 + // Accuracy
221 + if ( empty( $cp_options['accuracy'] ) ||
222 + ! preg_match('/^(?:1|5|10|15|20)$/D', $cp_options['accuracy'] ) ) {
223 +
224 + $cp_options['accuracy'] = 1;
225 + }
226 + ?>
227 + <tr>
228 + <th scope="row"><?php esc_html_e('Accuracy & Precision', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php
229 + 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');
230 + echo '<br />';
231 + 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');
232 + ?>"></span></th>
233 + <td>
234 + <p><label><?php esc_html_e('Select the accuracy and precision level of the profiler:', 'code-profiler') ?> &nbsp;<select name="cp_options[accuracy]">
235 + <?php
236 + foreach( CODE_PROFILER_ACCURACY as $key => $value ) {
237 + echo '<option value="'. esc_attr( $key ) .'"'. selected( $cp_options['accuracy'], $key, false ) .'>'. esc_html( $value ) .'</option>';
238 + }
239 + ?></select></label></p>
240 + </td>
241 + </tr>
242 + <?php
243 + $recommended = code_profiler_suggested_memory();
244 + // Buffer size
245 + if ( empty( $cp_options['buffer'] ) ) {
246 + $cp_options['buffer'] = 0;
247 + } elseif (! preg_match('/^(?:[1-9]|10)$/', $cp_options['buffer'] ) ) {
248 + $cp_options['buffer'] = (int) $recommended;
249 + }
250 + ?>
251 + <tr>
252 + <th scope="row"><?php esc_html_e('Buffer size', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php
253 + 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');
254 + ?>"></span></th>
255 + <td>
256 + <p>
257 + <label>
258 + <select name="cp_options[buffer]">
259 + <?php
260 + echo '<option value="0"'. selected( $cp_options['buffer'], 0, false ) .'>'.
261 + esc_html__('Automatic', 'code-profiler') .
262 + '</option>';
263 + for ( $i = 1; $i <= 10; $i++ ) {
264 + echo '<option value="'. $i .'"'. selected( $cp_options['buffer'], $i, false ) .'>'.
265 + sprintf(
266 + /* Translators: 'MB' for MegaBytes */
267 + esc_html__('%s MB', 'code-profiler')
268 + , $i ) .
269 + '</option>';
270 + }
271 + ?>
272 + </select>
273 + </label>
274 + </p>
275 + <p class="description"><?php
276 + printf(
277 + esc_html__('Recommended value based on your system configuration: %s MB', 'code-profiler'),
278 + (int) $recommended
279 + );
280 + ?></p>
281 + </td>
282 + </tr>
186 283 </table>
187 284
188 - <p><input type="submit" name="save-settings" class="button-primary" value="<?php esc_html_e('Save Settings', 'code-profiler') ?>" /></p>
285 + <p><input type="submit" name="save-settings" class="button button-primary" value="<?php esc_attr_e('Save Settings', 'code-profiler') ?>" /></p>
189 286
190 287 </form>
191 288 <?php
192 289
193 -// =====================================================================
290 +// ===================================================================== 2023-06-15
194 291 // Save and validate the settings.
195 292
196 293 function code_profiler_save_settings() {
197 294
198 - $cp_options = get_option( 'code-profiler' );
295 + $cp_options = get_option('code-profiler');
199 296
200 297 // Paths
201 - if ( empty( $_POST['cp_options']['show_paths'] ) || ! in_array( $_POST['cp_options']['show_paths'], ['absolute', 'relative' ] ) ) {
298 + if ( empty( $_POST['cp_options']['show_paths'] ) ||
299 + ! in_array( $_POST['cp_options']['show_paths'], ['absolute', 'relative' ] ) ) {
300 +
202 301 $cp_options['show_paths'] = 'relative';
203 302 } else {
204 303 $cp_options['show_paths'] = sanitize_key( $_POST['cp_options']['show_paths'] );
205 304 }
@@ -204,9 +303,11 @@
204 303 $cp_options['show_paths'] = sanitize_key( $_POST['cp_options']['show_paths'] );
205 304 }
206 305
207 306 // Name vs slug
208 - if ( empty( $_POST['cp_options']['display_name'] ) || ! in_array( $_POST['cp_options']['display_name'], ['full', 'slug' ] ) ) {
307 + if ( empty( $_POST['cp_options']['display_name'] ) ||
308 + ! in_array( $_POST['cp_options']['display_name'], ['full', 'slug' ] ) ) {
309 +
209 310 $cp_options['display_name'] = 'full';
210 311 } else {
211 312 $cp_options['display_name'] = sanitize_key( $_POST['cp_options']['display_name'] );
212 313 }
@@ -211,9 +312,11 @@
211 312 $cp_options['display_name'] = sanitize_key( $_POST['cp_options']['display_name'] );
212 313 }
213 314
214 315 // Truncate names
215 - if ( empty( $_POST['cp_options']['truncate_name'] ) || ! preg_match( '/^\d+$/', ( $_POST['cp_options']['truncate_name'] ) ) ) {
316 + if ( empty( $_POST['cp_options']['truncate_name'] ) ||
317 + ! preg_match('/^\d+$/', ( $_POST['cp_options']['truncate_name'] ) ) ) {
318 +
216 319 $cp_options['truncate_name'] = 30;
217 320 } else {
218 321 $cp_options['truncate_name'] = (int) $_POST['cp_options']['truncate_name'];
219 322 }
@@ -218,9 +321,11 @@
218 321 $cp_options['truncate_name'] = (int) $_POST['cp_options']['truncate_name'];
219 322 }
220 323
221 324 // chart type
222 - if ( empty( $_POST['cp_options']['chart_type'] ) || ! in_array( $_POST['cp_options']['chart_type'], ['x', 'y' ] ) ) {
325 + if ( empty( $_POST['cp_options']['chart_type'] ) ||
326 + ! in_array( $_POST['cp_options']['chart_type'], ['x', 'y' ] ) ) {
327 +
223 328 $cp_options['chart_type'] = 'x';
224 329 } else {
225 330 $cp_options['chart_type'] = sanitize_key( $_POST['cp_options']['chart_type'] );
226 331 }
@@ -225,9 +330,11 @@
225 330 $cp_options['chart_type'] = sanitize_key( $_POST['cp_options']['chart_type'] );
226 331 }
227 332
228 333 // Max plugins to display
229 - if ( empty( $_POST['cp_options']['chart_max_plugins'] ) || ! preg_match( '/^\d+$/', ( $_POST['cp_options']['chart_max_plugins'] ) ) ) {
334 + if ( empty( $_POST['cp_options']['chart_max_plugins'] ) ||
335 + ! preg_match('/^\d+$/', ( $_POST['cp_options']['chart_max_plugins'] ) ) ) {
336 +
230 337 $cp_options['chart_max_plugins'] = 25;
231 338 } else {
232 339 $cp_options['chart_max_plugins'] = (int) $_POST['cp_options']['chart_max_plugins'];
233 340 }
@@ -239,9 +346,13 @@
239 346 $cp_options['hide_empty_value'] = 0;
240 347 }
241 348
242 349 // Composer warning
243 - $cp_options['warn_composer'] = 1;
350 + if (! empty( $_POST['cp_options']['warn_composer'] ) ) {
351 + $cp_options['warn_composer'] = 1;
352 + } else {
353 + $cp_options['warn_composer'] = 0;
354 + }
244 355
245 356 // WP-CLI integration
246 357 if (! empty( $_POST['cp_options']['enable_wpcli'] ) ) {
247 358 $cp_options['enable_wpcli'] = 1;
@@ -267,14 +378,32 @@
267 378 }
268 379 if (! empty( $_POST['cp_options']['http_response_500'] ) ) {
269 380 $code .= '5';
270 381 }
271 - $code = rtrim( $code, '|' );
382 + $code = rtrim( $code, '|');
272 383 if (! empty( $code ) ) {
273 384 $cp_options['http_response'] = "^(?:$code)\d{2}$";
274 385 }
275 386
276 - return update_option( 'code-profiler', $cp_options );
387 + // Accuracy
388 + if ( empty( $_POST['cp_options']['accuracy'] ) ||
389 + ! preg_match('/^(?:1|5|10|15|20)$/D', $_POST['cp_options']['accuracy'] ) ) {
390 +
391 + $cp_options['accuracy'] = 1;
392 + } else {
393 + $cp_options['accuracy'] = (int) $_POST['cp_options']['accuracy'];
394 + }
395 +
396 + // Buffer size
397 + if ( empty( $_POST['cp_options']['buffer'] ) ) {
398 + $cp_options['buffer'] = 0;
399 + } elseif (! preg_match('/^(?:[1-9]|10)$/D', $_POST['cp_options']['buffer'] ) ) {
400 + $cp_options['buffer'] = 10;
401 + } else {
402 + $cp_options['buffer'] = (int) $_POST['cp_options']['buffer'];
403 + }
404 +
405 + return update_option('code-profiler', $cp_options );
277 406
278 407 }
279 408
280 409 // =====================================================================