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 | index.php +59 -38 1.5.51.7.4 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 -/*
2 +/**
3 3 Plugin Name: Code Profiler
4 -Plugin URI: https://code-profiler.com/
4 +Plugin URI: https://nintechnet.com/codeprofiler/
5 5 Description: A profiler to measure the performance of your WordPress plugins and themes.
6 6 Author: Jerome Bruandet ~ NinTechNet Ltd.
7 7 Author URI: https://nintechnet.com/
8 -Version: 1.5.5
8 +Version: 1.7.4
9 9 Network: true
10 10 License: GPLv3 or later
11 11 Text Domain: code-profiler
12 12 Domain Path: /languages
@@ -11,10 +11,10 @@
11 11 Text Domain: code-profiler
12 12 Domain Path: /languages
13 13 */
14 14
15 -define('CODE_PROFILER_VERSION', '1.5.5');
16 -/*
15 +define('CODE_PROFILER_VERSION', '1.7.4');
16 +/**
17 17 +=====================================================================+
18 18 | ____ _ ____ __ _ _ |
19 19 | / ___|___ __| | ___ | _ \ _ __ ___ / _(_) | ___ _ __ |
20 20 | | | / _ \ / _` |/ _ \ | |_) | '__/ _ \| |_| | |/ _ \ '__| |
@@ -20,9 +20,9 @@
20 20 | | | / _ \ / _` |/ _ \ | |_) | '__/ _ \| |_| | |/ _ \ '__| |
21 21 | | |__| (_) | (_| | __/ | __/| | | (_) | _| | | __/ | |
22 22 | \____\___/ \__,_|\___| |_| |_| \___/|_| |_|_|\___|_| |
23 23 | |
24 - | (c) Jerome Bruandet ~ https://code-profiler.com/ |
24 + | (c) Jerome Bruandet ~ https://nintechnet.com/codeprofiler/ |
25 25 +=====================================================================+
26 26 */
27 27
28 28 if (! defined('ABSPATH') ) {
@@ -28,9 +28,9 @@
28 28 if (! defined('ABSPATH') ) {
29 29 die('Forbidden');
30 30 }
31 31
32 -// =====================================================================
32 +// ===================================================================== 2023-08-20
33 33 // Menu functions
34 34 require __DIR__ .'/lib/menu.php';
35 35 // Helper (can be already loaded by the MU plugin)
36 36 require_once __DIR__ .'/lib/helper.php';
@@ -35,9 +35,9 @@
35 35 // Helper (can be already loaded by the MU plugin)
36 36 require_once __DIR__ .'/lib/helper.php';
37 37 // AJAX calls
38 38 require __DIR__ .'/lib/ajax.php';
39 -// =====================================================================
39 +// ===================================================================== 2023-06-17
40 40 // Activation: make sure the blog meets the requirements.
41 41
42 42 function code_profiler_activate() {
43 43
@@ -45,12 +45,13 @@
45 45 exit( esc_html__('Your are not allowed to activate plugins.', 'code-profiler') );
46 46 }
47 47
48 48 global $wp_version;
49 - if ( version_compare( $wp_version, '4.7.0', '<') ) {
49 + if ( version_compare( $wp_version, '5.0', '<') ) {
50 50 exit( sprintf(
51 - esc_html__('Code Profiler requires WordPress %s or greater but your current version is %s.', 'code-profiler'),
52 - '4.7.0',
51 + esc_html__('Code Profiler requires WordPress %s or greater but your current version is %s.',
52 + 'code-profiler'),
53 + '5.0',
53 54 esc_html( $wp_version )
54 55 ) );
55 56 }
56 57
@@ -63,9 +64,11 @@
63 64 }
64 65
65 66 // If the pro version is active, we refuse to run and throw an error message
66 67 if ( is_plugin_active('code-profiler-pro/index.php') ) {
67 - exit( esc_html__('Code Profiler Pro is active on this site, please disable it first if you want to run the free version.', 'code-profiler') );
68 + exit( esc_html__('Code Profiler Pro is active on this site, please disable it first if you '.
69 + 'want to run the free version.', 'code-profiler')
70 + );
68 71 }
69 72
70 73 // Verify/create our storage folder
71 74 code_profiler_check_uploadsdir();
@@ -78,9 +81,9 @@
78 81 }
79 82
80 83 register_activation_hook( __FILE__, 'code_profiler_activate');
81 84
82 -// =====================================================================
85 +// ===================================================================== 2023-06-17
83 86 // Deactivation.
84 87
85 88 function code_profiler_deactivate() {
86 89
@@ -95,9 +98,9 @@
95 98 }
96 99
97 100 register_deactivation_hook( __FILE__, 'code_profiler_deactivate');
98 101
99 -// =====================================================================
102 +// ===================================================================== 2023-06-14
100 103 // Create Profiler's menu.
101 104
102 105 function code_profiler_admin_menu() {
103 106
@@ -117,9 +120,9 @@
117 120 }
118 121
119 122 add_action('admin_menu', 'code_profiler_admin_menu');
120 123
121 -// =====================================================================
124 +// ===================================================================== 2023-08-20
122 125 // Register scripts and styles.
123 126
124 127 function code_profiler_enqueue( $hook ) {
125 128
@@ -133,18 +136,18 @@
133 136 }
134 137
135 138 // We load Thickbox if we're viewing section 4 only
136 139 if ( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == 4 ) {
137 - $extra_js = array('jquery', 'thickbox');
138 - $extra_css = array('thickbox');
140 + $extra_js = ['jquery', 'thickbox'];
141 + $extra_css = ['thickbox'];
139 142 } else {
140 - $extra_js = array('jquery');
141 - $extra_css = null;
143 + $extra_js = ['jquery'];
144 + $extra_css = null;
142 145 }
143 146
144 147 wp_enqueue_script(
145 148 'code_profiler_javascript',
146 - plugin_dir_url( __FILE__ ) . 'static/code-profiler.js',
149 + plugin_dir_url( __FILE__ ) .'static/code-profiler.js',
147 150 $extra_js,
148 151 CODE_PROFILER_VERSION
149 152 );
150 153
@@ -150,25 +153,27 @@
150 153
151 154 wp_enqueue_script(
152 155 'code-profiler_tiptip',
153 156 plugin_dir_url( __FILE__ ) .'static/vendor/jquery.tipTip.js',
154 - array('jquery'),
157 + ['jquery'],
155 158 CODE_PROFILER_VERSION
156 159 );
157 160
158 161 wp_enqueue_style(
159 162 'code-profiler_style',
160 - plugin_dir_url( __FILE__ ) . 'static/code-profiler.css',
163 + plugin_dir_url( __FILE__ ) .'static/code-profiler.css',
161 164 $extra_css,
162 165 CODE_PROFILER_VERSION
163 166 );
164 167
165 168 // Enqueue Chart.js if we're viewing a profile
166 - if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'view_profile') {
169 + if ( isset( $_REQUEST['action'] ) &&
170 + $_REQUEST['action'] == 'view_profile') {
171 +
167 172 wp_enqueue_script(
168 173 'code_profiler_charts',
169 - plugin_dir_url( __FILE__ ) . 'static/vendor/chart.min.js',
170 - array('jquery'),
174 + plugin_dir_url( __FILE__ ) .'static/vendor/chart.min.js',
175 + ['jquery'],
171 176 CODE_PROFILER_VERSION,
172 177 // We load it in the footer, because some plugins loads it too
173 178 // on every pages and that could mess with our pages
174 179 true
@@ -175,9 +180,9 @@
175 180 );
176 181 }
177 182
178 183 // JS i18n
179 - $code_profiler_i18n = array(
184 + $code_profiler_i18n = [
180 185 'missing_nonce' =>
181 186 esc_attr__('Security nonce is missing, try to reload the page.', 'code-profiler'),
182 187 'missing_frontbackend' =>
183 188 esc_attr__('Please select either the fontend or backend option.', 'code-profiler'),
@@ -185,11 +190,15 @@
185 190 esc_attr__('Missing profile identifier.', 'code-profiler'),
186 191 'missing_profilename' =>
187 192 esc_attr__('Please enter a name for this profile.', 'code-profiler'),
188 193 'missing_userauth' =>
189 - esc_attr__('Please select whether the profiler should run as an authenticated user or not.', 'code-profiler'),
194 + esc_attr__('Please select whether the profiler should run as an authenticated user or not.',
195 + 'code-profiler'),
190 196 'missing_username' =>
191 197 esc_attr__('Please enter the name of the user.', 'code-profiler'),
198 + 'missing_ajax' =>
199 + esc_attr__('Please enter a valid AJAX payload, or change the content-type option. '.
200 + 'If you want to send an empty value, enter: {}', 'code-profiler'),
192 201 'missing_post' =>
193 202 esc_attr__('Please select a page to profile.', 'code-profiler'),
194 203 'unknown_error' =>
195 204 esc_attr__('Unknown error returned by AJAX', 'code-profiler'),
@@ -195,21 +204,28 @@
195 204 esc_attr__('Unknown error returned by AJAX', 'code-profiler'),
196 205 'http_error' =>
197 206 esc_attr__('The HTTP server returned the following error:', 'code-profiler'),
198 207 'timeout_error' =>
199 - esc_attr__('You can try to select a lower Accuracy and Precision level in the Settings page', 'code-profiler'),
208 + esc_attr__('You can try to select a lower Accuracy and Precision level in the Settings page',
209 + 'code-profiler'),
200 210 'notfound_error' =>
201 - esc_attr__('The requested page does not seem to exist. Please check the syntax of the URL you want to profile', 'code-profiler'),
211 + esc_attr__('The requested page does not seem to exist. Please check the syntax of the URL '.
212 + 'you want to profile',
213 + 'code-profiler'),
202 214 'forbidden_error' =>
203 - esc_attr__('The server rejected and blocked the requested page. Make sure you are allowed to access that page or that there is no security plugin or application blocking it', 'code-profiler'),
215 + esc_attr__('The server rejected and blocked the requested page. Make sure you are allowed '.
216 + 'to access that page or that there is no security plugin or application blocking it',
217 + 'code-profiler'),
204 218 'internal_error' =>
205 - esc_attr__('This is an internal server error. Please check your server, PHP and Code Profiler logs as they may contain more details about the error', 'code-profiler'),
219 + esc_attr__('This is an internal server error. Please check your server, PHP and Code '.
220 + 'Profiler logs as they may contain more details about the error', 'code-profiler'),
206 221 'unknown_error' =>
207 222 esc_attr__('An unknown error occurred:', 'code-profiler'),
208 223 'preparing_report' =>
209 224 esc_attr__('Preparing the report', 'code-profiler') .'...',
210 225 'empty_log' =>
211 - esc_attr__('No records were found that match the specified search criteria.', 'code-profiler'),
226 + esc_attr__('No records were found that match the specified search criteria.',
227 + 'code-profiler'),
212 228 'delete_log' =>
213 229 esc_attr__('Delete log?', 'code-profiler'),
214 230 'delete_profile' =>
215 231 esc_attr__('Delete this profile?', 'code-profiler'),
@@ -233,22 +249,27 @@
233 249 esc_attr__('Total Disk I/O read and write, in bytes', 'code-profiler'),
234 250 'text_copied' =>
235 251 esc_attr__('The text was successfully copied to the clipboard.', 'code-profiler')
236 252
253 + ];
254 + wp_localize_script(
255 + 'code_profiler_javascript',
256 + 'cpi18n',
257 + $code_profiler_i18n
237 258 );
238 - wp_localize_script('code_profiler_javascript', 'cpi18n', $code_profiler_i18n );
239 259 }
240 260
241 261 add_action('admin_enqueue_scripts', 'code_profiler_enqueue');
242 262
243 -// =====================================================================
263 +// ===================================================================== 2023-08-20
244 264 // Display the settings link in the "Plugins" page.
245 265
246 266 function code_profiler_settings_link( $links ) {
247 267
248 - $links[] = '<a href="'. get_admin_url( null, 'admin.php?page=code-profiler') .
249 - '">'. esc_html__('Start Profiling', 'code-profiler'). '</a>';
250 - $links[] = '<a style="font-weight:700;color:#006393;" href="https://code-profiler.com/" target="_blank" rel="noopener noreferrer">'.
268 + $links[] = '<a href="'. get_admin_url( null, 'admin.php?page=code-profiler') .'">'.
269 + esc_html__('Start Profiling', 'code-profiler'). '</a>';
270 + $links[] = '<a style="font-weight:700;color:#006393;" href="https://nintechnet.com/codeprofiler/" '.
271 + 'target="_blank" rel="noopener noreferrer">'.
251 272 esc_html__('Go Pro', 'code-profiler'). '</a>';
252 273 return $links;
253 274 }
254 275
@@ -253,9 +274,9 @@
253 274 }
254 275
255 276 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'code_profiler_settings_link');
256 277
257 -// =====================================================================
278 +// ===================================================================== 2023-08-20
258 279 // WP CLI commands.
259 280
260 281 if ( defined('WP_CLI') && WP_CLI ) {
261 282 require_once __DIR__ . '/lib/class-cli.php';