PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.6
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.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 1.6.8 All 40 releases
← All changes | index.php +35 -75 trunk1.6 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 -/**
2 +/*
3 3 Plugin Name: Code Profiler
4 -Plugin URI: https://nintechnet.com/codeprofiler/
4 +Plugin URI: https://code-profiler.com/
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.9.5
8 +Version: 1.6
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.9.5');
16 -/**
15 +define('CODE_PROFILER_VERSION', '1.6');
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://nintechnet.com/codeprofiler/ |
24 + | (c) Jerome Bruandet ~ https://code-profiler.com/ |
25 25 +=====================================================================+
26 26 */
27 27
28 28 if (! defined('ABSPATH') ) {
@@ -34,11 +34,9 @@
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';
37 37 // AJAX calls
38 -require __DIR__ .'/lib/class-ajax.php';
39 -// Scheduled tasks
40 -require_once __DIR__ .'/lib/class-wp-cron.php';
38 +require __DIR__ .'/lib/ajax.php';
41 39 // =====================================================================
42 40 // Activation: make sure the blog meets the requirements.
43 41
44 42 function code_profiler_activate() {
@@ -47,13 +45,12 @@
47 45 exit( esc_html__('Your are not allowed to activate plugins.', 'code-profiler') );
48 46 }
49 47
50 48 global $wp_version;
51 - if ( version_compare( $wp_version, '5.0', '<') ) {
49 + if ( version_compare( $wp_version, '4.7.0', '<') ) {
52 50 exit( sprintf(
53 - esc_html__('Code Profiler requires WordPress %s or greater but your current version is %s.',
54 - 'code-profiler'),
55 - '5.0',
51 + esc_html__('Code Profiler requires WordPress %s or greater but your current version is %s.', 'code-profiler'),
52 + '4.7.0',
56 53 esc_html( $wp_version )
57 54 ) );
58 55 }
59 56
@@ -66,11 +63,9 @@
66 63 }
67 64
68 65 // If the pro version is active, we refuse to run and throw an error message
69 66 if ( is_plugin_active('code-profiler-pro/index.php') ) {
70 - exit( esc_html__('Code Profiler Pro is active on this site, please disable it first if you '.
71 - 'want to run the free version.', 'code-profiler')
72 - );
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') );
73 68 }
74 69
75 70 // Verify/create our storage folder
76 71 code_profiler_check_uploadsdir();
@@ -79,15 +74,8 @@
79 74 $cp_options = get_option('code-profiler');
80 75 if ( $cp_options === false ) {
81 76 code_profiler_default_options();
82 77 }
83 -
84 - /**
85 - * Install scheduled tasks on the main site only.
86 - */
87 - if ( is_main_site() ) {
88 - CodeProfiler_WPCron::install();
89 - }
90 78 }
91 79
92 80 register_activation_hook( __FILE__, 'code_profiler_activate');
93 81
@@ -103,13 +91,8 @@
103 91 // Remove the MU plugin
104 92 if ( file_exists( WPMU_PLUGIN_DIR .'/'. CODE_PROFILER_MUPLUGIN ) ) {
105 93 unlink( WPMU_PLUGIN_DIR .'/'. CODE_PROFILER_MUPLUGIN );
106 94 }
107 -
108 - /**
109 - * Uninstall scheduled tasks.
110 - */
111 - CodeProfiler_WPCron::uninstall();
112 95 }
113 96
114 97 register_deactivation_hook( __FILE__, 'code_profiler_deactivate');
115 98
@@ -134,9 +117,9 @@
134 117 }
135 118
136 119 add_action('admin_menu', 'code_profiler_admin_menu');
137 120
138 -// ===================================================================== 2023-08-20
121 +// =====================================================================
139 122 // Register scripts and styles.
140 123
141 124 function code_profiler_enqueue( $hook ) {
142 125
@@ -150,18 +133,18 @@
150 133 }
151 134
152 135 // We load Thickbox if we're viewing section 4 only
153 136 if ( isset( $_REQUEST['section'] ) && $_REQUEST['section'] == 4 ) {
154 - $extra_js = ['jquery', 'thickbox'];
155 - $extra_css = ['thickbox'];
137 + $extra_js = array('jquery', 'thickbox');
138 + $extra_css = array('thickbox');
156 139 } else {
157 - $extra_js = ['jquery'];
158 - $extra_css = null;
140 + $extra_js = array('jquery');
141 + $extra_css = null;
159 142 }
160 143
161 144 wp_enqueue_script(
162 145 'code_profiler_javascript',
163 - plugin_dir_url( __FILE__ ) .'static/code-profiler.js',
146 + plugin_dir_url( __FILE__ ) . 'static/code-profiler.js',
164 147 $extra_js,
165 148 CODE_PROFILER_VERSION
166 149 );
167 150
@@ -167,27 +150,25 @@
167 150
168 151 wp_enqueue_script(
169 152 'code-profiler_tiptip',
170 153 plugin_dir_url( __FILE__ ) .'static/vendor/jquery.tipTip.js',
171 - ['jquery'],
154 + array('jquery'),
172 155 CODE_PROFILER_VERSION
173 156 );
174 157
175 158 wp_enqueue_style(
176 159 'code-profiler_style',
177 - plugin_dir_url( __FILE__ ) .'static/code-profiler.css',
160 + plugin_dir_url( __FILE__ ) . 'static/code-profiler.css',
178 161 $extra_css,
179 162 CODE_PROFILER_VERSION
180 163 );
181 164
182 165 // Enqueue Chart.js if we're viewing a profile
183 - if ( isset( $_REQUEST['action'] ) &&
184 - $_REQUEST['action'] == 'view_profile') {
185 -
166 + if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'view_profile') {
186 167 wp_enqueue_script(
187 168 'code_profiler_charts',
188 - plugin_dir_url( __FILE__ ) .'static/vendor/chart.min.js',
189 - ['jquery'],
169 + plugin_dir_url( __FILE__ ) . 'static/vendor/chart.min.js',
170 + array('jquery'),
190 171 CODE_PROFILER_VERSION,
191 172 // We load it in the footer, because some plugins loads it too
192 173 // on every pages and that could mess with our pages
193 174 true
@@ -194,9 +175,9 @@
194 175 );
195 176 }
196 177
197 178 // JS i18n
198 - $code_profiler_i18n = [
179 + $code_profiler_i18n = array(
199 180 'missing_nonce' =>
200 181 esc_attr__('Security nonce is missing, try to reload the page.', 'code-profiler'),
201 182 'missing_frontbackend' =>
202 183 esc_attr__('Please select either the fontend or backend option.', 'code-profiler'),
@@ -204,20 +185,11 @@
204 185 esc_attr__('Missing profile identifier.', 'code-profiler'),
205 186 'missing_profilename' =>
206 187 esc_attr__('Please enter a name for this profile.', 'code-profiler'),
207 188 'missing_userauth' =>
208 - esc_attr__('Please select whether the profiler should run as an authenticated user or not.',
209 - 'code-profiler'),
189 + esc_attr__('Please select whether the profiler should run as an authenticated user or not.', 'code-profiler'),
210 190 'missing_username' =>
211 191 esc_attr__('Please enter the name of the user.', 'code-profiler'),
212 - 'missing_ajax' =>
213 - esc_attr__('Please enter a valid JSON-encoded payload, or change the content-type option. '.
214 - 'If you want to send an empty value, enter: {}', 'code-profiler'),
215 - 'missing_wpcron' =>
216 - esc_attr__('There are no cron events available, please select another page to profile.',
217 - 'code-profiler'),
218 - 'multiline_raw' =>
219 - esc_attr__('The raw POST payload should be on one single line only.', 'code-profiler'),
220 192 'missing_post' =>
221 193 esc_attr__('Please select a page to profile.', 'code-profiler'),
222 194 'unknown_error' =>
223 195 esc_attr__('Unknown error returned by AJAX', 'code-profiler'),
@@ -223,28 +195,21 @@
223 195 esc_attr__('Unknown error returned by AJAX', 'code-profiler'),
224 196 'http_error' =>
225 197 esc_attr__('The HTTP server returned the following error:', 'code-profiler'),
226 198 'timeout_error' =>
227 - esc_attr__('You can try to select a lower Accuracy and Precision level in the Settings page',
228 - 'code-profiler'),
199 + esc_attr__('You can try to select a lower Accuracy and Precision level in the Settings page', 'code-profiler'),
229 200 'notfound_error' =>
230 - esc_attr__('The requested page does not seem to exist. Please check the syntax of the URL '.
231 - 'you want to profile',
232 - 'code-profiler'),
201 + esc_attr__('The requested page does not seem to exist. Please check the syntax of the URL you want to profile', 'code-profiler'),
233 202 'forbidden_error' =>
234 - esc_attr__('The server rejected and blocked the requested page. Make sure you are allowed '.
235 - 'to access that page or that there is no security plugin or application blocking it',
236 - 'code-profiler'),
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'),
237 204 'internal_error' =>
238 - esc_attr__('This is an internal server error. Please check your server, PHP and Code '.
239 - 'Profiler logs as they may contain more details about the error', 'code-profiler'),
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'),
240 206 'unknown_error' =>
241 207 esc_attr__('An unknown error occurred:', 'code-profiler'),
242 208 'preparing_report' =>
243 209 esc_attr__('Preparing the report', 'code-profiler') .'...',
244 210 'empty_log' =>
245 - esc_attr__('No records were found that match the specified search criteria.',
246 - 'code-profiler'),
211 + esc_attr__('No records were found that match the specified search criteria.', 'code-profiler'),
247 212 'delete_log' =>
248 213 esc_attr__('Delete log?', 'code-profiler'),
249 214 'delete_profile' =>
250 215 esc_attr__('Delete this profile?', 'code-profiler'),
@@ -268,27 +233,22 @@
268 233 esc_attr__('Total Disk I/O read and write, in bytes', 'code-profiler'),
269 234 'text_copied' =>
270 235 esc_attr__('The text was successfully copied to the clipboard.', 'code-profiler')
271 236
272 - ];
273 - wp_localize_script(
274 - 'code_profiler_javascript',
275 - 'cpi18n',
276 - $code_profiler_i18n
277 237 );
238 + wp_localize_script('code_profiler_javascript', 'cpi18n', $code_profiler_i18n );
278 239 }
279 240
280 241 add_action('admin_enqueue_scripts', 'code_profiler_enqueue');
281 242
282 -// ===================================================================== 2023-08-20
243 +// =====================================================================
283 244 // Display the settings link in the "Plugins" page.
284 245
285 246 function code_profiler_settings_link( $links ) {
286 247
287 - $links[] = '<a href="'. get_admin_url( null, 'admin.php?page=code-profiler') .'">'.
288 - esc_html__('Start Profiling', 'code-profiler'). '</a>';
289 - $links[] = '<a style="font-weight:700;color:#006393;" href="https://nintechnet.com/codeprofiler/" '.
290 - 'target="_blank" rel="noopener noreferrer">'.
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">'.
291 251 esc_html__('Go Pro', 'code-profiler'). '</a>';
292 252 return $links;
293 253 }
294 254
@@ -293,9 +253,9 @@
293 253 }
294 254
295 255 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'code_profiler_settings_link');
296 256
297 -// ===================================================================== 2023-08-20
257 +// =====================================================================
298 258 // WP CLI commands.
299 259
300 260 if ( defined('WP_CLI') && WP_CLI ) {
301 261 require_once __DIR__ . '/lib/class-cli.php';