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_profiler.php +160 -55 1.51.7.4 View file →
@@ -6,13 +6,13 @@
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') ) { die('Forbidden'); }
15 15
16 16 // =====================================================================
17 17 // Display Summary tab.
18 18
@@ -38,15 +38,23 @@
38 38 printf( CODE_PROFILER_ERROR_NOTICE, sprintf(
39 39 esc_html__('The following folder is not writable: %s. Please change its permissions or ownership so that Code Profiler can write to it.', 'code-profiler'), CODE_PROFILER_UPLOAD_DIR )
40 40 );
41 41 }
42 -$home = home_url( '/' );
42 +
43 +// Clear the log if it's too big
44 +code_profiler_clearlog();
45 +
46 +// Clean-up temp files left in the profiles folder
47 +code_profiler_cleantmpfiles();
48 +
49 +$home = home_url('/'); // Frontend
50 +$site = site_url('/'); // Backend
43 51 // Get user login name
44 52 $current_user = wp_get_current_user();
45 53 // Profile's name
46 54 $profile = code_profiler_profile_name();
47 55
48 -$cp_options = get_option( 'code-profiler' );
56 +$cp_options = get_option('code-profiler');
49 57 // Memorized options
50 58 if ( empty( $cp_options['mem_where'] ) ) {
51 59 $cp_options['mem_where'] = 'frontend';
52 60 }
@@ -55,39 +63,58 @@
55 63 }
56 64 if ( empty( $cp_options['mem_user'] ) ) {
57 65 $cp_options['mem_user'] = 'unauthenticated';
58 66 }
59 -if ( $cp_options['mem_where'] == 'backend' ) {
67 +if ( $cp_options['mem_where'] == 'backend') {
60 68 $cp_options['mem_user'] = 'authenticated';
61 69 }
62 70 if ( empty( $cp_options['mem_method'] ) ) {
63 71 $cp_options['mem_method'] = 'get';
64 72 }
73 +$default_theme = get_option('stylesheet');
74 +if ( empty( $cp_options['mem_theme'] ) ) {
75 + $cp_options['mem_theme'] = $default_theme;
76 +}
65 77 if ( empty( $cp_options['ua'] ) ) {
66 78 $cp_options['ua'] = 'Firefox';
67 79 }
68 -$cookies = '';
69 -$payload = '';
80 +$cookies = '';
81 +$payload = '';
82 +$custom_headers = '';
83 +$exclusions = [];
84 +
70 85 if ( isset( $cp_options['cookies'] ) ) {
71 - $cookies = trim( json_decode( $cp_options['cookies'] ) );
86 + // stripslashes is only needed for cookies
87 + $cookies = trim( stripslashes( json_decode( $cp_options['cookies'] ) ) );
72 88 }
89 +if ( empty( $cp_options['mem_content_type'] ) ||
90 + ! in_array( $cp_options['mem_content_type'], [ 1, 2 ] ) ) {
91 +
92 + $cp_options['mem_content_type'] = 1;
93 +}
73 94 if ( isset( $cp_options['payload'] ) ) {
74 - $payload = trim( json_decode( $cp_options['payload'] ) );
95 + $payload = trim( json_decode( $cp_options['payload'] ) );
75 96 }
97 +if ( isset( $cp_options['custom_headers'] ) ) {
98 + $custom_headers = trim( json_decode( $cp_options['custom_headers'] ) );
99 +}
100 +if ( isset( $cp_options['exclusions'] ) ) {
101 + $exclusions = json_decode( $cp_options['exclusions'] );
102 +}
76 103 ?>
77 104 <table class="form-table">
78 105 <tr>
79 - <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>
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>
80 107 <td>
81 - <p><label><input type="radio" name="where" value="frontend" onclick="cpjs_front_or_backend(1);"<?php checked( $cp_options['mem_where'], 'frontend' ) ?> /> <?php esc_html_e('Website frontend', 'code-profiler') ?></label>
108 + <p><label><input type="radio" name="where" value="frontend" onclick="cpjs_front_or_backend(1);"<?php checked( $cp_options['mem_where'], 'frontend') ?> /> <?php esc_html_e('Website frontend', 'code-profiler') ?></label>
82 109 &nbsp;&nbsp;&nbsp;&nbsp;
83 - <label><input type="radio" name="where" value="custom" onclick="cpjs_front_or_backend(3);"<?php checked( $cp_options['mem_where'], 'custom' ) ?> /> <?php esc_html_e('Custom post/URL', 'code-profiler') ?></label>
110 + <label><input type="radio" name="where" value="custom" onclick="cpjs_front_or_backend(3);"<?php checked( $cp_options['mem_where'], 'custom') ?> /> <?php esc_html_e('Custom post/URL', 'code-profiler') ?></label>
84 111 &nbsp;&nbsp;&nbsp;&nbsp;
85 - <label><input type="radio" name="where" value="backend" onclick="cpjs_front_or_backend(2);"<?php checked( $cp_options['mem_where'], 'backend' ) ?> /> <?php esc_html_e('Admin backend', 'code-profiler') ?></label>
112 + <label><input type="radio" name="where" value="backend" onclick="cpjs_front_or_backend(2);"<?php checked( $cp_options['mem_where'], 'backend') ?> /> <?php esc_html_e('Admin backend', 'code-profiler') ?></label>
86 113 </p>
87 114 <br />
88 115 <?php
89 - if ( $cp_options['mem_where'] == 'frontend' ) {
116 + if ( $cp_options['mem_where'] == 'frontend') {
90 117 echo '<p id="p-frontend">';
91 118 } else {
92 119 echo '<p id="p-frontend" style="display:none">';
93 120 }
@@ -97,9 +124,9 @@
97 124 <?php echo code_profiler_fetch_pages( $home, $cp_options ); ?>
98 125 </select>
99 126 </p>
100 127 <?php
101 - if ( $cp_options['mem_where'] == 'custom' ) {
128 + if ( $cp_options['mem_where'] == 'custom') {
102 129 $value = $cp_options['mem_post'];
103 130 echo '<p id="p-custom">';
104 131 } else {
105 132 $value = '';
@@ -114,9 +141,9 @@
114 141 )
115 142 ) ?>" />
116 143 </p>
117 144 <?php
118 - if ( $cp_options['mem_where'] == 'backend' ) {
145 + if ( $cp_options['mem_where'] == 'backend') {
119 146 echo '<p id="p-backend">';
120 147 } else {
121 148 echo '<p id="p-backend" style="display:none">';
122 149 }
@@ -126,14 +153,14 @@
126 153 $username = $current_user->user_login;
127 154 }
128 155 ?>
129 156 <?php esc_html_e('Select a page:', 'code-profiler') ?>
130 - <select name="backend" id="id-backend"><?php echo code_profiler_fetch_admin_pages( $home, $cp_options ) ?></select>
157 + <select name="backend" id="id-backend"><?php echo code_profiler_fetch_admin_pages( $site, $cp_options ) ?></select>
131 158 </p>
132 159 </td>
133 160 </tr>
134 161 <tr>
135 - <th scope="row"><?php esc_html_e('Run profiler as', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('The profiler can access the requested page as an unauthenticated user (frontend only) or as an authenticated user (frontend and backend). You can enter the login name of any registered user, but make sure that the user has the required capability to access the page you are going to profile (e.g. an admin page in the backend), otherwise Code Profiler will return an error if the user isn\'t allowed to access it.', 'code-profiler' ) ?>"></span></th>
162 + <th scope="row"><?php esc_html_e('Run profiler as', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('The profiler can access the requested page as an unauthenticated user (frontend only) or as an authenticated user (frontend and backend). You can enter the login name of any registered user, but make sure that the user has the required capability to access the page you are going to profile, otherwise Code Profiler will return an error if the user isn\'t allowed to access it.', 'code-profiler') ?>"></span></th>
136 163 <td>
137 164 <p><label><input type="radio" onclick="cpjs_authenticated(0);" name="user" value="unauthenticated" id="user-unauthenticated"<?php checked( $cp_options['mem_user'], 'unauthenticated'); disabled( $cp_options['mem_where'], 'backend'); ?> /> <?php esc_html_e('Unauthenticated user', 'code-profiler') ?></label></p>
138 165 <p><label><input type="radio" onclick="cpjs_authenticated(1);" name="user" value="authenticated" id="user-authenticated"<?php checked( $cp_options['mem_user'], 'authenticated') ?> /> <?php esc_html_e('Authenticated user', 'code-profiler') ?></label></p>
139 166 <p><label><?php esc_html_e('User:', 'code-profiler') ?> <input type="text" name="username" id="user-name" value ="<?php esc_attr_e( $username ) ?>"<?php disabled( $cp_options['mem_user'], 'unauthenticated') ?> /></label></p>
@@ -139,16 +166,35 @@
139 166 <p><label><?php esc_html_e('User:', 'code-profiler') ?> <input type="text" name="username" id="user-name" value ="<?php esc_attr_e( $username ) ?>"<?php disabled( $cp_options['mem_user'], 'unauthenticated') ?> /></label></p>
140 167 </td>
141 168 </tr>
142 169 <tr>
143 - <th scope="row"><?php esc_html_e('User agent', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Some themes and plugins may execute different code depending on the type of device used to visit the website (e.g., a desktop computer, a mobile phone, a search engine bot etc). This option lets you change the User-Agent request header used by Code Profiler.', 'code-profiler' ) ?>"></span></th>
170 + <th scope="row"><?php esc_html_e('Theme', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('If you want to profile different themes, you can use this option so that you don\'t need to modify your WordPress settings. The change will not affect your visitors, but only the profiler when it is running.', 'code-profiler') ?>"></span></th>
144 171 <td>
172 + <select name="theme" id="id-theme">
173 + <?php
174 + $themes = code_profiler_get_themes();
175 + foreach( $themes as $slug => $name ) {
176 + if ( $slug == $default_theme ) {
177 + echo '<option value=""'. selected( $cp_options['mem_theme'], $slug, false ) .'>'.
178 + esc_html( $name['n'] ) .' '. __('(active theme)', 'code-profiler') .'</option>';
179 + } else {
180 + echo '<option value="'. esc_attr( $slug ) .'"'. selected( $cp_options['mem_theme'], $slug, false ) .'>'.
181 + esc_html( $name['n'] ) .'</option>';
182 + }
183 + }
184 + ?>
185 + </select>
186 + </td>
187 + </tr>
188 + <tr>
189 + <th scope="row"><?php esc_html_e('User agent', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Some themes and plugins may execute different code depending on the type of device used to visit the website (e.g., a desktop computer, a mobile phone, a search engine bot etc). This option lets you change the User-Agent request header used by Code Profiler.', 'code-profiler') ?>"></span></th>
190 + <td>
145 191 <select name="ua" id="ua-id">
146 192 <?php
147 193 foreach( CODE_PROFILER_UA as $types => $types_array ) {
148 194 echo '<optgroup label="'. esc_attr( $types ) .'">';
149 195 foreach( $types_array as $name => $value ) {
150 - echo '<option value="'. esc_attr( $name ) .'"'. selected( $cp_options['ua'], $name ) .'>'. esc_html( $name ) .'</option>';
196 + echo '<option value="'. esc_attr( $name ) .'"'. selected( $cp_options['ua'], $name, false ) .'>'. esc_html( $name ) .'</option>';
151 197 }
152 198 echo '</optgroup>';
153 199 }
154 200 ?>
@@ -155,9 +201,9 @@
155 201 </select>
156 202 </td>
157 203 </tr>
158 204 <tr>
159 - <th scope="row"><?php esc_html_e('Name of the profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Enter the name for this profile. It will be saved to the "Profiles List" page, with all other profiles.', 'code-profiler' ) ?>"></span></th>
205 + <th scope="row"><?php esc_html_e('Name of the profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Enter the name for this profile. It will be saved to the "Profiles List" page, with all other profiles.', 'code-profiler') ?>"></span></th>
160 206 <td>
161 207 <p><label><input type="text" class="regular-text" name="profile" maxlength="100" value="<?php echo esc_attr( $profile ) ?>" id="profile-name" /></label></p>
162 208 <p class="description"><?php esc_html_e('Max 100 characters', 'code-profiler') ?></p>
163 209 </td>
@@ -163,9 +209,9 @@
163 209 </td>
164 210 </tr>
165 211 </table>
166 212 <?php
167 -if (! empty( $cookies ) || $cp_options['mem_method'] == 'post' ) {
213 +if (! empty( $cookies ) || ! empty( $custom_headers ) || $cp_options['mem_method'] == 'post' || ! empty( $exclusions ) ) {
168 214 echo '<div id="cp-advanced-settings">';
169 215 $disabled_button = ' disabled';
170 216 } else {
171 217 echo '<div id="cp-advanced-settings" style="display:none">';
@@ -173,36 +219,76 @@
173 219 }
174 220 ?>
175 221 <table class="form-table">
176 222 <tr>
177 - <th scope="row"><?php esc_html_e('HTTP Method', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('You can select which HTTP method will be used by the profiler: GET or POST. If you select POST, you can also send an optional payload.', 'code-profiler' ) ?>"></span></th>
223 + <th scope="row"><?php esc_html_e('HTTP Method', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('You can select which HTTP method will be used by the profiler: GET or POST. If you select POST, you can also send an optional payload.', 'code-profiler') ?>"></span></th>
178 224 <td>
179 - <p><label><input onclick="cpjs_get_post(0);" type="radio" name="method" value="get" id="get-method"<?php checked( $cp_options['mem_method'], 'get' ) ?> /> <?php esc_html_e('GET (default)', 'code-profiler') ?></label></p>
180 - <p><label><input onclick="cpjs_get_post(1);" type="radio" name="method" value="post" id="post-method"<?php checked( $cp_options['mem_method'], 'post' ) ?> /> POST</label></p>
181 - <p><textarea name="post-value" id="post-value" class="regular-text code"<?php disabled( $cp_options['mem_method'], 'get' ) ?> maxlength="4000" rows="6"><?php echo esc_textarea( $payload ) ?></textarea></p>
182 - <p class="description"><?php printf( esc_html__('Optional POST payload in %s format, one item per line.', 'code-profiler'), '<code>key=value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url( '/static/help/http_method.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?> </p>
225 + <p>
226 + <label>
227 + <input onclick="cpjs_get_post(0);" type="radio" name="method" value="get" id="get-method"<?php checked( $cp_options['mem_method'], 'get') ?> /> GET(<?php esc_html_e('default', 'code-profiler') ?>)
228 + </label>
229 + </p>
230 + <p>
231 + <label>
232 + <input onclick="cpjs_get_post(1);" type="radio" name="method" value="post" id="post-method"<?php checked( $cp_options['mem_method'], 'post') ?> /> POST
233 + </label>
234 + </p>
235 + <p>
236 + <?php esc_html_e('Content-type:', 'code-profiler') ?>
237 + <select name="cp-content-type" id="id-content-type"<?php disabled( $cp_options['mem_method'], 'get') ?> onChange="cpjs_content_type(this.value);">
238 + <option value="1"<?php selected( $cp_options['mem_content_type'], 1 )?>>application/x-www-form-urlencoded (<?php esc_html_e('default', 'code-profiler') ?>)</option>
239 + <option value="2"<?php selected( $cp_options['mem_content_type'], 2 )?>>application/json</option>
240 + </select>
241 + </p>
242 + <p>
243 + <textarea name="post-value" id="post-value" class="regular-text code"<?php disabled( $cp_options['mem_method'], 'get') ?> maxlength="4000" rows="6"><?php echo esc_textarea( $payload ) ?></textarea>
244 + </p>
245 + <p class="description" id="ct-1"<?php echo code_profiler_hide( $cp_options['mem_content_type'], 2) ?>>
246 + <?php printf( esc_html__('Optional POST payload 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/http_method-1.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?>
247 + </p>
248 + <p class="description" id="ct-2"<?php echo code_profiler_hide( $cp_options['mem_content_type'], 1) ?>>
249 + <?php printf( esc_html__('Optional JSON-encoded payload.', 'code-profiler'), '<code>name=value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/http_method-2.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?>
250 + </p>
183 251 </td>
184 252 </tr>
185 253 <tr>
186 - <th scope="row"><?php esc_html_e('Cookie', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Some websites may execute different code if the user has one or more specific cookies. You can use this field for that purpose.', 'code-profiler' ) ?>"></span></th>
254 + <th scope="row"><?php esc_html_e('Cookie', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Some websites may execute different code if the user has one or more specific cookies. You can use this field for that purpose.', 'code-profiler') ?>"></span></th>
187 255 <td>
188 256 <p><textarea name="cp-cookies" id="cp-cookies" class="regular-text code" maxlength="4000" rows="6"><?php echo esc_textarea( $cookies ) ?></textarea></p>
189 - <p class="description"><?php printf( esc_html__('Optional cookie 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/cookies.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?></p>
257 + <p class="description"><?php printf( esc_html__('Optional cookie 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/cookies.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?></p>
190 258 </td>
191 259 </tr>
260 + <tr>
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>
262 + <td>
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>
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>
276 + </td>
277 + </tr>
192 278 </table>
193 279 </div>
194 280 <?php wp_nonce_field('start_profiler_nonce', 'cp_nonce', 0); ?>
195 281 <br />
196 282 <div>
197 - <input type="button" class="button-secondary" id="button-adv-settings" name="adv-settings" value="<?php esc_attr_e('Advanced Options', 'code-profiler') ?>" onclick="cpjs_show_adv_settings();"<?php echo $disabled_button ?> />
283 + <input type="button" class="button button-secondary" id="button-adv-settings" name="adv-settings" value="<?php esc_attr_e('Advanced Options', 'code-profiler') ?>" onclick="cpjs_show_adv_settings();"<?php echo $disabled_button ?> />
198 284 &nbsp;&nbsp;&nbsp;
199 - <input type="button" class="button-primary" id="start-profile" name="start-profile" onClick="cpjs_start_profiler();" value="<?php esc_attr_e('Start Profiling', 'code-profiler') ?> »" title="<?php esc_attr_e('Click to start profiling your code.', 'code-profiler') ?>" />
285 + <input type="button" class="button button-primary" id="start-profile" name="start-profile" onClick="cpjs_start_profiler();" value="<?php esc_attr_e('Start Profiling', 'code-profiler') ?> »" title="<?php esc_attr_e('Click to start profiling your code.', 'code-profiler') ?>" />
200 286 </div>
201 287 <div id="cp-progress-div" style="display:none">
202 288 <br />
203 289 <div class="cp-progress-bar"><span id="cp-span-progress" style="width:0%"></span></div>
204 - <img style="vertical-align:middle;display:none" id="progress-gif" src="<?php echo plugins_url('/static/progress.gif', dirname (__FILE__ ) ) ?>" />&nbsp;&nbsp;<font id="progress-text" style="display:none"><?php esc_html_e('Starting profiler...', 'code-profiler') ?></font>
290 + <img style="vertical-align:middle;display:none" id="progress-gif" src="<?php echo plugins_url('/static/progress.gif', dirname (__FILE__ ) ) ?>" />&nbsp;&nbsp;<font id="progress-text" style="display:none"><?php esc_html_e('Starting the profiler...', 'code-profiler') ?></font>
205 291 </div>
206 292
207 293 <?php
208 294
@@ -217,21 +303,27 @@
217 303 $cp_options['mem_post'] = $home;
218 304 }
219 305
220 306 if ( $cp_options['mem_post'] == $home ) {
221 - $pages = '<option value="'. esc_attr( $home ) .'" title="'. esc_attr( $home ) .'" selected>'.
222 - esc_html__('Homepage', 'code-profiler') .'</option>';
307 + $pages = sprintf(
308 + '<option value="%1$s" title="%1$s" selected>%2$s</option>',
309 + esc_attr( $home ),
310 + esc_html__('Homepage', 'code-profiler')
311 + );
223 312 } else {
224 - $pages = '<option value="'. esc_attr( $home ) .'" title="'. esc_attr( $home ) .'">'.
225 - esc_html__('Homepage', 'code-profiler') .'</option>';
313 + $pages = sprintf(
314 + '<option value="%1$s" title="%1$s">%2$s</option>',
315 + esc_attr( $home ),
316 + esc_html__('Homepage', 'code-profiler')
317 + );
226 318 }
227 - $args = array(
319 + $args = [
228 320 'posts_per_page' => -1,
229 - 'post_type' => array( 'page' ),
321 + 'post_type' => ['page'],
230 322 'post_status' => 'publish',
231 323 'orderby' => 'post_name',
232 324 'order' => 'ASC'
233 - );
325 + ];
234 326 $query = new WP_Query( $args );
235 327
236 328 if ( $query ) {
237 329 $items = $query->posts;
@@ -241,18 +333,24 @@
241 333 }
242 334 $permalink = get_permalink( $item->ID );
243 335
244 336 if ( $cp_options['mem_post'] == $permalink ) {
245 - $pages .= '<option value="'. esc_attr( $permalink ).'" title="'.
246 - esc_attr( $permalink ) .'" selected>'. esc_html( $item->post_title ) .'</option>';
337 + $pages .= sprintf(
338 + '<option value="%1$s" title="%1$s" selected>%2$s</option>',
339 + esc_attr( $permalink ),
340 + esc_html( $item->post_title )
341 + );
247 342 } else {
248 - $pages .= '<option value="'. esc_attr( $permalink ).'" title="'.
249 - esc_attr( $permalink ) .'">'. esc_html( $item->post_title ) .'</option>';
343 + $pages .= sprintf(
344 + '<option value="%1$s" title="%1$s">%2$s</option>',
345 + esc_attr( $permalink ),
346 + esc_html( $item->post_title )
347 + );
250 348 }
251 349 }
252 350 }
253 351
254 - return sprintf( '<optgroup label="%s">%s</optgroup>',
352 + return sprintf('<optgroup label="%s">%s</optgroup>',
255 353 esc_attr__('Pages', 'code-profiler'),
256 354 $pages
257 355 );
258 356 }
@@ -269,29 +367,36 @@
269 367 }
270 368
271 369 if (! empty( $GLOBALS[ 'menu' ] ) ) {
272 370 foreach( $GLOBALS[ 'menu' ] as $menu => $value ) {
273 - if (! empty( $value[0] ) && substr( $value[2], -4 ) == '.php' ) {
371 + if (! empty( $value[0] ) && substr( $value[2], -4 ) == '.php') {
274 372 // E.g., "Comments", "Plugins" etc
275 - $value[0] = trim( preg_replace( '/\s+<.+$/', '', $value[0] ) );
373 + $value[0] = trim( preg_replace('/\s*<.+$/', '', $value[0] ) );
276 374
277 375 if ( $cp_options['mem_post'] == "{$home}wp-admin/{$value[2]}" ) {
278 - $backend .= '<option value="'. esc_attr( "{$home}wp-admin/{$value[2]}" ) .'" title="'.
279 - esc_attr( "{$home}wp-admin/{$value[2]}" ) .'" selected>'.
280 - esc_html( $value[0] ) .'</option>';
376 + $backend .= sprintf(
377 + '<option value="%1$s" title="%1$s" selected>%2$s</option>',
378 + esc_attr("{$home}wp-admin/{$value[2]}"),
379 + esc_html( $value[0] )
380 + );
281 381 } else {
282 - $backend .= '<option value="'. esc_attr( "{$home}wp-admin/{$value[2]}" ) .'" title="'.
283 - esc_attr( "{$home}wp-admin/{$value[2]}" ) .'">'.
284 - esc_html( $value[0] ) .'</option>';
382 + $backend .= sprintf(
383 + '<option value="%1$s" title="%1$s">%2$s</option>',
384 + esc_attr("{$home}wp-admin/{$value[2]}"),
385 + esc_html( $value[0] )
386 + );
285 387 }
286 388 }
287 389 }
288 390 }
289 391 if ( empty( $backend ) ) {
290 - $backend = '<option value="'. esc_attr( $home ) .'wp-admin/" title="'. esc_attr( $home ) .'wp-admin/">'.
291 - esc_html__( 'Dashboard', 'code-profiler' ) .'</option>';
392 + $backend = sprintf(
393 + '<option value="%1$swp-admin/" title="%1$swp-admin/">%2$s</option>',
394 + esc_attr( $home ),
395 + esc_html__('Dashboard', 'code-profiler')
396 + );
397 +
292 398 }
293 -
294 399 return $backend;
295 400 }
296 401
297 402 // =====================================================================