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.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/class-table-profiles.php +18 -53 1.9.4 → 1.7.4 View file →
@@ -26,12 +26,8 @@
26 26 'slugs',
27 27 'summary',
28 28 'composer'
29 29 ];
30 - private $optional_files = [
31 - 'summary',
32 - 'composer'
33 - ];
34 30 private $abspath;
35 31 private $row_count = 0;
36 32
37 33
@@ -54,8 +50,9 @@
54 50 * Empty list
55 51 */
56 52 function no_items() {
57 53 esc_html_e('No profile found.', 'code-profiler');
54 + $this->is_empty = 1;
58 55 }
59 56
60 57
61 58 /**
@@ -114,15 +111,15 @@
114 111 */
115 112 function get_columns(){
116 113 return [
117 114 'cb' => '<input type="checkbox" />',
118 - 'profile' => esc_html__('Profile', 'code-profiler'),
119 - 'date' => esc_html__('Date', 'code-profiler'),
120 - 'items' => esc_html__('Items', 'code-profiler'),
121 - 'time' => esc_html__('Time', 'code-profiler'),
122 - 'mem' => esc_html__('Memory', 'code-profiler'),
123 - 'io' => esc_html__('File I/O', 'code-profiler'),
124 - 'queries' => esc_html__('SQL', 'code-profiler')
115 + 'profile' => esc_html__( 'Profile', 'code-profiler' ),
116 + 'date' => esc_html__( 'Date', 'code-profiler' ),
117 + 'items' => esc_html__( 'Items', 'code-profiler' ),
118 + 'time' => esc_html__( 'Time', 'code-profiler' ),
119 + 'mem' => esc_html__( 'Memory', 'code-profiler' ),
120 + 'io' => esc_html__( 'File I/O', 'code-profiler' ),
121 + 'queries' => esc_html__( 'SQL', 'code-profiler' )
125 122 ];
126 123 }
127 124
128 125
@@ -160,25 +157,8 @@
160 157 // Keep sorting order for the "delete" action link
161 158 $orderby = (! empty( $_GET['orderby'] ) ) ? sanitize_key( $_GET['orderby'] ) : 'ID';
162 159 $order = (! empty( $_GET['order'] ) ) ? sanitize_key( $_GET['order'] ) : 'asc';
163 160
164 - /**
165 - * The option to re-run a profile is only available with profiles created with v1.8.
166 - */
167 - if (! empty( $item['rerun'] ) ) {
168 - $rerun = sprintf(
169 - '<a href="?page=code-profiler&cptab=profiler&action=rerun&profiles[]=%1$s" title="'.
170 - esc_attr__('Re-run the profile with the same options and parameters.', 'code-profiler') .
171 - '">%2$s</a>',
172 - esc_attr( $item['ID'] ),
173 - esc_html__('Re-run', 'code-profiler')
174 - );
175 - } else {
176 - $rerun = '<font style="cursor:not-allowed" title="'.
177 - esc_attr__('This feature is only available with profiles created with Code Profiler v1.8+',
178 - 'code-profiler') .'">'. esc_html__('Re-run', 'code-profiler') .'</font>';
179 - }
180 -
181 161 $actions = array(
182 162 'view' => sprintf(
183 163 '<a href="?page=code-profiler&cptab=profiles_list&action=%s&id=%s&section=1">%s</a>',
184 164 'view_profile',
@@ -189,12 +169,11 @@
189 169 '<a style="cursor:pointer" onClick="cpjs_toggle_name(\'%s\')">%s</a>',
190 170 esc_attr( $this->row_count ),
191 171 esc_html__('Quick Edit')
192 172 ),
193 - 'rerun' => $rerun,
194 173 'delete' => sprintf(
195 - '<a href="?page=code-profiler&cptab=profiles_list&action=%s&profiles[]=%s'.
196 - '&_wpnonce=%s&orderby=%s&order=%s" onclick="return cpjs_delete_profile();">%s</a>',
174 + '<a href="?page=code-profiler&cptab=profiles_list&action=%s&profiles[]=%s&_wpnonce=%s&orderby=%s&order=%s" '.
175 + 'onclick="return cpjs_delete_profile();">%s</a>',
197 176 'delete_profiles',
198 177 esc_attr( $item['ID'] ),
199 178 wp_create_nonce('bulk-'. $this->_args['plural'] ),
200 179 $orderby,
@@ -296,15 +275,11 @@
296 275
297 276 $error = 0; $fsize = 0;
298 277 // Make sure we have all profile files
299 278 foreach( $this->default_files as $pname ) {
300 - /**
301 - * Ignore these ones, there aren't mandatory.
302 - */
303 - if ( in_array( $pname, $this->optional_files ) ) {
304 - continue;
305 - }
306 - if ( is_file( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {
279 + // Ignore these ones, there aren't mandatory
280 + if ( in_array( $pname, [ 'composer', 'summary' ] ) ) { continue; }
281 + if ( file_exists( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {
307 282 $fsize += filesize( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" );
308 283 } else {
309 284 $error = 1;
310 285 break;
@@ -312,9 +287,9 @@
312 287 }
313 288 // Delete if incomplete
314 289 if ( $error ) {
315 290 foreach( $this->default_files as $pname ) {
316 - if ( is_file( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {
291 + if ( file_exists( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {
317 292 unlink( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" );
318 293 }
319 294 }
320 295 continue;
@@ -323,14 +298,10 @@
323 298 // Search query
324 299 $search = false;
325 300 if (! empty( $_REQUEST['s'] ) ) {
326 301 foreach( $this->default_files as $pname ) {
327 - /**
328 - * Ignore these ones, there aren't mandatory.
329 - */
330 - if ( in_array( $pname, $this->optional_files ) ) {
331 - continue;
332 - }
302 + // Ignore these ones, there aren't mandatory
303 + if ( in_array( $pname, [ 'composer', 'summary' ] ) ) { continue; }
333 304 $search = $this->search_profile_file(
334 305 CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile",
335 306 sanitize_text_field( $_REQUEST['s'] )
336 307 );
@@ -354,14 +325,8 @@
354 325 if ( empty( $summary['time'] ) ) { $summary['time'] = '-'; }
355 326 if ( empty( $summary['items'] ) ) { $summary['items'] = '-'; }
356 327 if ( empty( $summary['io'] ) ) { $summary['io'] = '-'; }
357 328
358 - /**
359 - * Check if we can re-run the profile (v1.8+).
360 - */
361 - if (! empty( $summary['rerun'] ) ) {
362 - $profiles[$count]['rerun'] = true;
363 - }
364 329 $fsize += filesize( $path );
365 330 $profiles[$count]['ID'] = $match[1];
366 331 $profiles[$count]['profile'] = esc_html( $match[2] );
367 332 $profiles[$count]['date'] = filemtime( $path );
@@ -419,10 +384,10 @@
419 384 $error = true;
420 385 continue;
421 386 }
422 387 foreach( $this->default_files as $pname ) {
423 - if ( is_file( "$profile_name.$pname.profile") ) {
424 - unlink( "$profile_name.$pname.profile");
388 + if ( file_exists( "$profile_name.$pname.profile" ) ) {
389 + unlink( "$profile_name.$pname.profile" );
425 390 }
426 391 }
427 392 }
428 393 return $error;