| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if( ! class_exists( 'MywpDeveloperAbstractModule' ) ) { |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
if ( ! class_exists( 'MywpDeveloperModuleDevTimes' ) ) : |
| 12 |
|
| 13 |
final class MywpDeveloperModuleDevTimes extends MywpDeveloperAbstractModule { |
| 14 |
|
| 15 |
static protected $id = 'dev_times'; |
| 16 |
|
| 17 |
static protected $priority = 100; |
| 18 |
|
| 19 |
static private $init_process; |
| 20 |
|
| 21 |
protected static function after_init() { |
| 22 |
|
| 23 |
global $timestart; |
| 24 |
|
| 25 |
if( ! MywpDeveloper::is_debug_item( 'debug_time' ) ) { |
| 26 |
|
| 27 |
return false; |
| 28 |
|
| 29 |
} |
| 30 |
|
| 31 |
$init_process = MywpDeveloper::get_process(); |
| 32 |
|
| 33 |
$define_microtime = MywpHelper::get_define( 'MYWP_DEVELOPER_MICROTIME' ); |
| 34 |
|
| 35 |
if( ! empty( $define_microtime ) ) { |
| 36 |
|
| 37 |
$init_process['microtime'] = $define_microtime; |
| 38 |
|
| 39 |
} elseif ( ! empty( $timestart ) ) { |
| 40 |
|
| 41 |
$init_process['microtime'] = $timestart; |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
$define_memory_get_usage = MywpHelper::get_define( 'MYWP_DEVELOPER_MEMORY_GET_USAGE' ); |
| 46 |
|
| 47 |
if( ! empty( $define_memory_get_usage ) ) { |
| 48 |
|
| 49 |
$init_process['memory_get_usage'] = $define_memory_get_usage; |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
$define_load_avg = MywpHelper::get_define( 'MYWP_DEVELOPER_LOAD_AVG' ); |
| 54 |
|
| 55 |
if( ! empty( $define_load_avg ) ) { |
| 56 |
|
| 57 |
$init_process['load_avg'] = $define_load_avg; |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
self::$init_process = $init_process; |
| 62 |
|
| 63 |
self::add_actions( 'plugins_loaded' ); |
| 64 |
self::add_actions( 'setup_theme' ); |
| 65 |
self::add_actions( 'after_setup_theme' ); |
| 66 |
|
| 67 |
add_action( 'mywp_after_setup_theme' , array( __CLASS__ , 'mywp_after_setup_theme' ) , 100 ); |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
public static function mywp_after_setup_theme() { |
| 72 |
|
| 73 |
self::add_actions( 'init' ); |
| 74 |
self::add_actions( 'wp_loaded' ); |
| 75 |
|
| 76 |
$debug_times_action_items = array( |
| 77 |
'admin_bar_init', |
| 78 |
'add_admin_bar_menus', |
| 79 |
'parse_request', |
| 80 |
'send_headers', |
| 81 |
'wp', |
| 82 |
'admin_bar_menu', |
| 83 |
'wp_before_admin_bar_render', |
| 84 |
'wp_after_admin_bar_render', |
| 85 |
|
| 86 |
'admin_menu', |
| 87 |
'admin_init', |
| 88 |
'current_screen', |
| 89 |
'admin_enqueue_scripts', |
| 90 |
'admin_print_styles', |
| 91 |
'admin_print_scripts', |
| 92 |
'admin_head', |
| 93 |
'adminmenu', |
| 94 |
'in_admin_header', |
| 95 |
'admin_notices', |
| 96 |
'all_admin_notices', |
| 97 |
'in_admin_footer', |
| 98 |
'admin_footer', |
| 99 |
|
| 100 |
'template_redirect', |
| 101 |
'loop_start', |
| 102 |
'loop_end', |
| 103 |
'wp_head', |
| 104 |
'wp_enqueue_scripts', |
| 105 |
'wp_print_styles', |
| 106 |
'wp_print_scripts', |
| 107 |
'wp_footer', |
| 108 |
'wp_print_footer_scripts', |
| 109 |
); |
| 110 |
|
| 111 |
$debug_times_action_items = apply_filters( 'mywp_debug_times_action_items' , $debug_times_action_items ); |
| 112 |
|
| 113 |
if( empty( $debug_times_action_items ) ) { |
| 114 |
|
| 115 |
return false; |
| 116 |
|
| 117 |
} |
| 118 |
|
| 119 |
if( ! is_array( $debug_times_action_items ) ) { |
| 120 |
|
| 121 |
return false; |
| 122 |
|
| 123 |
} |
| 124 |
|
| 125 |
foreach( $debug_times_action_items as $debug_times_action_item ) { |
| 126 |
|
| 127 |
if( ! is_string( $debug_times_action_item ) ) { |
| 128 |
|
| 129 |
continue; |
| 130 |
|
| 131 |
} |
| 132 |
|
| 133 |
self::add_actions( $debug_times_action_item ); |
| 134 |
|
| 135 |
} |
| 136 |
|
| 137 |
} |
| 138 |
|
| 139 |
private static function add_actions( $action_hook_name = false ) { |
| 140 |
|
| 141 |
if( empty( $action_hook_name ) ) { |
| 142 |
|
| 143 |
$called_text = sprintf( '%s::%s( %s )' , __CLASS__ , '$action_hook_name' ); |
| 144 |
|
| 145 |
MywpHelper::error_not_found_message( '$action_hook_name' , $called_text ); |
| 146 |
|
| 147 |
return false; |
| 148 |
|
| 149 |
} |
| 150 |
|
| 151 |
if( $action_hook_name !== 'plugins_loaded' ) { |
| 152 |
|
| 153 |
add_action( $action_hook_name , array( __CLASS__ , 'process_set_1' ) , -10 ); |
| 154 |
add_action( $action_hook_name , array( __CLASS__ , 'process_set_10' ) , 10 ); |
| 155 |
|
| 156 |
} |
| 157 |
|
| 158 |
add_action( $action_hook_name , array( __CLASS__ , 'process_set_100' ) , 100 ); |
| 159 |
add_action( $action_hook_name , array( __CLASS__ , 'process_set_10000' ) , 10000 ); |
| 160 |
|
| 161 |
} |
| 162 |
|
| 163 |
private static function set_process( $priority ) { |
| 164 |
|
| 165 |
if( ! MywpDeveloper::is_debug() ) { |
| 166 |
|
| 167 |
return false; |
| 168 |
|
| 169 |
} |
| 170 |
|
| 171 |
if( ! MywpDeveloper::is_debug_item( 'debug_time' ) ) { |
| 172 |
|
| 173 |
return false; |
| 174 |
|
| 175 |
} |
| 176 |
|
| 177 |
$current_filter = MywpDeveloper::get_current_filter(); |
| 178 |
|
| 179 |
if( empty( $current_filter ) ) { |
| 180 |
|
| 181 |
return false; |
| 182 |
|
| 183 |
} |
| 184 |
|
| 185 |
$processes = self::get_processes(); |
| 186 |
|
| 187 |
$processes[ $current_filter ][ $priority ] = MywpDeveloper::get_process(); |
| 188 |
|
| 189 |
$mywp_cache = new MywpCache( 'mywp_times' ); |
| 190 |
|
| 191 |
$mywp_cache->update_cache( $processes ); |
| 192 |
|
| 193 |
} |
| 194 |
|
| 195 |
private static function get_processes() { |
| 196 |
|
| 197 |
$mywp_cache = new MywpCache( 'mywp_times' ); |
| 198 |
|
| 199 |
$procecces = $mywp_cache->get_cache(); |
| 200 |
|
| 201 |
if( empty( $procecces ) ) { |
| 202 |
|
| 203 |
$procecces = array(); |
| 204 |
|
| 205 |
} |
| 206 |
|
| 207 |
return $procecces; |
| 208 |
|
| 209 |
} |
| 210 |
|
| 211 |
private static function get_process( $filter_name = false ) { |
| 212 |
|
| 213 |
if( empty( $filter_name ) ) { |
| 214 |
|
| 215 |
return false; |
| 216 |
|
| 217 |
} |
| 218 |
|
| 219 |
$processes = self::get_processes(); |
| 220 |
|
| 221 |
if( empty( $processes[ $filter_name ] ) ) { |
| 222 |
|
| 223 |
return false; |
| 224 |
|
| 225 |
} |
| 226 |
|
| 227 |
return $processes[ $filter_name ]; |
| 228 |
|
| 229 |
} |
| 230 |
|
| 231 |
public static function process_set_1() { |
| 232 |
|
| 233 |
self::set_process( -1 ); |
| 234 |
|
| 235 |
} |
| 236 |
|
| 237 |
public static function process_set_10() { |
| 238 |
|
| 239 |
self::set_process( 10 ); |
| 240 |
|
| 241 |
} |
| 242 |
|
| 243 |
public static function process_set_100() { |
| 244 |
|
| 245 |
self::set_process( 100 ); |
| 246 |
|
| 247 |
} |
| 248 |
|
| 249 |
public static function process_set_10000() { |
| 250 |
|
| 251 |
self::set_process( 10000 ); |
| 252 |
|
| 253 |
} |
| 254 |
|
| 255 |
public static function mywp_debug_renders( $debug_renders ) { |
| 256 |
|
| 257 |
$debug_renders[ self::$id ] = array( |
| 258 |
'debug_type' => 'dev', |
| 259 |
'title' => __( 'Action Times' , 'my-wp' ), |
| 260 |
); |
| 261 |
|
| 262 |
return $debug_renders; |
| 263 |
|
| 264 |
} |
| 265 |
|
| 266 |
protected static function mywp_developer_debug() { |
| 267 |
|
| 268 |
if( ! MywpDeveloper::is_debug_item( 'debug_time' ) ) { |
| 269 |
|
| 270 |
echo esc_html( __( 'Not activated.' , 'my-wp' ) ); |
| 271 |
|
| 272 |
return false; |
| 273 |
|
| 274 |
} |
| 275 |
|
| 276 |
$processes = self::get_processes(); |
| 277 |
|
| 278 |
if( empty( $processes ) ) { |
| 279 |
|
| 280 |
return false; |
| 281 |
|
| 282 |
} |
| 283 |
|
| 284 |
$first_process = self::get_first_process(); |
| 285 |
|
| 286 |
if( empty( $first_process ) ) { |
| 287 |
|
| 288 |
return false; |
| 289 |
|
| 290 |
} |
| 291 |
|
| 292 |
echo esc_html( sprintf( '%s = ' , __( 'All' ) ) ); |
| 293 |
|
| 294 |
echo esc_html( self::print_format( $first_process ) ); |
| 295 |
|
| 296 |
echo esc_html( sprintf( 'Memory peak: %s' , MywpHelper::get_byte( memory_get_peak_usage() ) ) ); |
| 297 |
|
| 298 |
$before_screen_process = self::get_before_screen_process(); |
| 299 |
|
| 300 |
if( empty( $before_screen_process ) ) { |
| 301 |
|
| 302 |
return false; |
| 303 |
|
| 304 |
} |
| 305 |
|
| 306 |
echo esc_html( sprintf( '%s = ' , __( 'Before Screen' , 'my-wp' ) ) ); |
| 307 |
|
| 308 |
echo esc_html( self::print_format( $before_screen_process ) ); |
| 309 |
|
| 310 |
$screen_process = self::get_screen_process(); |
| 311 |
|
| 312 |
if( empty( $screen_process ) ) { |
| 313 |
|
| 314 |
return false; |
| 315 |
|
| 316 |
} |
| 317 |
|
| 318 |
echo esc_html( sprintf( '%s = ' , __( 'Screen' , 'my-wp' ) ) ); |
| 319 |
|
| 320 |
echo esc_html( self::print_format( $screen_process ) ); |
| 321 |
|
| 322 |
foreach( $processes as $action_hook_name => $priority_processes ) { |
| 323 |
|
| 324 |
echo esc_html( $action_hook_name ) . "\n"; |
| 325 |
|
| 326 |
$last_priority_process = end( $priority_processes ); |
| 327 |
$first_priority_process = reset( $priority_processes ); |
| 328 |
|
| 329 |
$total_screen_process = self::format_process( $first_priority_process , $last_priority_process ); |
| 330 |
|
| 331 |
echo esc_html( sprintf( '%s = ' , __( 'Total' , 'my-wp' ) ) ); |
| 332 |
|
| 333 |
echo esc_html( self::print_format( $total_screen_process ) ); |
| 334 |
|
| 335 |
$priority_processes_count = count( $priority_processes ); |
| 336 |
$priority_processes_keys = array_keys( $priority_processes ); |
| 337 |
|
| 338 |
for( $i = 0; $i < ( $priority_processes_count -1 ); ++$i ) { |
| 339 |
|
| 340 |
$current_priority = $priority_processes_keys[ $i ]; |
| 341 |
|
| 342 |
$next_priority = $priority_processes_keys[ ( $i + 1 ) ]; |
| 343 |
|
| 344 |
$current_process = $priority_processes[ $current_priority ]; |
| 345 |
|
| 346 |
$next_process = $priority_processes[ $next_priority ]; |
| 347 |
|
| 348 |
$diff_process = self::format_process( $current_process , $next_process ); |
| 349 |
|
| 350 |
echo esc_html( sprintf( '[%s] - [%s] = ' , $current_priority , $next_priority ) ); |
| 351 |
|
| 352 |
echo esc_html( self::print_format( $diff_process ) ); |
| 353 |
|
| 354 |
echo self::print_filters( $action_hook_name , $current_priority , $next_priority ); |
| 355 |
|
| 356 |
} |
| 357 |
|
| 358 |
} |
| 359 |
|
| 360 |
} |
| 361 |
|
| 362 |
protected static function mywp_debug_render() { |
| 363 |
|
| 364 |
if( ! MywpDeveloper::is_debug_item( 'debug_time' ) ) { |
| 365 |
|
| 366 |
echo esc_html( __( 'Not activated.' , 'my-wp' ) ); |
| 367 |
|
| 368 |
return false; |
| 369 |
|
| 370 |
} |
| 371 |
|
| 372 |
$processes = self::get_processes(); |
| 373 |
|
| 374 |
if( empty( $processes ) ) { |
| 375 |
|
| 376 |
return false; |
| 377 |
|
| 378 |
} |
| 379 |
|
| 380 |
echo '<table class="debug-table">'; |
| 381 |
|
| 382 |
$first_process = self::get_first_process(); |
| 383 |
|
| 384 |
if( empty( $first_process ) ) { |
| 385 |
|
| 386 |
return false; |
| 387 |
|
| 388 |
} |
| 389 |
|
| 390 |
echo '<tr>'; |
| 391 |
|
| 392 |
printf( '<th>%s</th>' , __( 'All' ) ); |
| 393 |
|
| 394 |
printf( '<td>%s' , esc_html( self::print_format( $first_process ) ) ); |
| 395 |
|
| 396 |
echo esc_html( sprintf( ' - Memory peak: %s</td>' , MywpHelper::get_byte( memory_get_peak_usage() ) ) ); |
| 397 |
|
| 398 |
echo '</tr>'; |
| 399 |
|
| 400 |
echo '</table>'; |
| 401 |
|
| 402 |
echo '<table class="debug-table">'; |
| 403 |
|
| 404 |
$before_screen_process = self::get_before_screen_process(); |
| 405 |
|
| 406 |
if( empty( $before_screen_process ) ) { |
| 407 |
|
| 408 |
return false; |
| 409 |
|
| 410 |
} |
| 411 |
|
| 412 |
echo '<tr>'; |
| 413 |
|
| 414 |
printf( '<th>%s</th>' , __( 'Before Screen' , 'my-wp' ) ); |
| 415 |
|
| 416 |
printf( '<td>%s</td>' , esc_html( self::print_format( $before_screen_process ) ) ); |
| 417 |
|
| 418 |
echo '</tr>'; |
| 419 |
|
| 420 |
$screen_process = self::get_screen_process(); |
| 421 |
|
| 422 |
if( empty( $screen_process ) ) { |
| 423 |
|
| 424 |
return false; |
| 425 |
|
| 426 |
} |
| 427 |
|
| 428 |
echo '<tr>'; |
| 429 |
|
| 430 |
printf( '<th>%s</th>' , __( 'Screen' , 'my-wp' ) ); |
| 431 |
|
| 432 |
printf( '<td>%s</td>' , esc_html( self::print_format( $screen_process ) ) ); |
| 433 |
|
| 434 |
echo '</tr>'; |
| 435 |
|
| 436 |
echo '</table>'; |
| 437 |
|
| 438 |
foreach( $processes as $action_hook_name => $priority_processes ) { |
| 439 |
|
| 440 |
printf( '<p>%s</p>' , esc_html( $action_hook_name ) ); |
| 441 |
|
| 442 |
echo '<table class="debug-table">'; |
| 443 |
|
| 444 |
$last_priority_process = end( $priority_processes ); |
| 445 |
$first_priority_process = reset( $priority_processes ); |
| 446 |
|
| 447 |
$total_screen_process = self::format_process( $first_priority_process , $last_priority_process ); |
| 448 |
|
| 449 |
echo '<tr>'; |
| 450 |
|
| 451 |
printf( '<th>%s</th>' , __( 'Total' , 'my-wp' ) ); |
| 452 |
|
| 453 |
printf( '<td>%s</td>' , esc_html( self::print_format( $total_screen_process ) ) ); |
| 454 |
|
| 455 |
echo '</tr>'; |
| 456 |
|
| 457 |
$priority_processes_count = count( $priority_processes ); |
| 458 |
$priority_processes_keys = array_keys( $priority_processes ); |
| 459 |
|
| 460 |
for( $i = 0; $i < ( $priority_processes_count -1 ); ++$i ) { |
| 461 |
|
| 462 |
$current_priority = $priority_processes_keys[ $i ]; |
| 463 |
|
| 464 |
$next_priority = $priority_processes_keys[ ( $i + 1 ) ]; |
| 465 |
|
| 466 |
$current_process = $priority_processes[ $current_priority ]; |
| 467 |
|
| 468 |
$next_process = $priority_processes[ $next_priority ]; |
| 469 |
|
| 470 |
$diff_process = self::format_process( $current_process , $next_process ); |
| 471 |
|
| 472 |
echo '<tr>'; |
| 473 |
|
| 474 |
printf( '<th>%s</th>' , esc_html( sprintf( '[%s] - [%s]' , $current_priority , $next_priority ) ) ); |
| 475 |
|
| 476 |
printf( '<td>%s' , esc_html( self::print_format( $diff_process ) ) ); |
| 477 |
|
| 478 |
echo self::print_filters( $action_hook_name , $current_priority , $next_priority , true ); |
| 479 |
|
| 480 |
echo '</td>'; |
| 481 |
|
| 482 |
echo '</tr>'; |
| 483 |
|
| 484 |
} |
| 485 |
|
| 486 |
echo '</table>'; |
| 487 |
|
| 488 |
} |
| 489 |
|
| 490 |
//printf( '<pre>%s</pre>' , print_r( $processes , true ) ); |
| 491 |
|
| 492 |
} |
| 493 |
|
| 494 |
private static function get_first_process() { |
| 495 |
|
| 496 |
$processes = self::get_processes(); |
| 497 |
|
| 498 |
if( empty( $processes ) ) { |
| 499 |
|
| 500 |
return false; |
| 501 |
|
| 502 |
} |
| 503 |
|
| 504 |
$init_process = self::$init_process; |
| 505 |
|
| 506 |
$last_process_priorities = end( $processes ); |
| 507 |
|
| 508 |
$last_process = end( $last_process_priorities ); |
| 509 |
|
| 510 |
return self::format_process( $init_process , $last_process ); |
| 511 |
|
| 512 |
} |
| 513 |
|
| 514 |
private static function get_before_screen_process() { |
| 515 |
|
| 516 |
$processes = self::get_processes(); |
| 517 |
|
| 518 |
if( empty( $processes ) ) { |
| 519 |
|
| 520 |
return false; |
| 521 |
|
| 522 |
} |
| 523 |
|
| 524 |
$init_process = self::$init_process; |
| 525 |
|
| 526 |
$before_screen_process = false; |
| 527 |
|
| 528 |
if( ! empty( $processes['admin_head'][-1] ) ) { |
| 529 |
|
| 530 |
$before_screen_process = $processes['admin_head'][-1]; |
| 531 |
|
| 532 |
} elseif( ! empty( $processes['wp_head'][-1] ) ) { |
| 533 |
|
| 534 |
$before_screen_process = $processes['wp_head'][-1]; |
| 535 |
|
| 536 |
} |
| 537 |
|
| 538 |
return self::format_process( $init_process , $before_screen_process ); |
| 539 |
|
| 540 |
} |
| 541 |
|
| 542 |
private static function get_screen_process() { |
| 543 |
|
| 544 |
$processes = self::get_processes(); |
| 545 |
|
| 546 |
if( empty( $processes ) ) { |
| 547 |
|
| 548 |
return false; |
| 549 |
|
| 550 |
} |
| 551 |
|
| 552 |
$before_screen_process = false; |
| 553 |
|
| 554 |
if( ! empty( $processes['admin_head'][-1] ) ) { |
| 555 |
|
| 556 |
$before_screen_process = $processes['admin_head'][-1]; |
| 557 |
|
| 558 |
} elseif( ! empty( $processes['wp_head'][-1] ) ) { |
| 559 |
|
| 560 |
$before_screen_process = $processes['wp_head'][-1]; |
| 561 |
|
| 562 |
} |
| 563 |
|
| 564 |
$last_process_priorities = end( $processes ); |
| 565 |
|
| 566 |
$last_process = end( $last_process_priorities ); |
| 567 |
|
| 568 |
return self::format_process( $before_screen_process , $last_process ); |
| 569 |
|
| 570 |
} |
| 571 |
|
| 572 |
private static function format_process( $start_process = false , $end_process = false ) { |
| 573 |
|
| 574 |
if( empty( $start_process ) or empty( $end_process ) ) { |
| 575 |
|
| 576 |
return false; |
| 577 |
|
| 578 |
} |
| 579 |
|
| 580 |
$format_process = array( |
| 581 |
'start' => $start_process, |
| 582 |
'end' => $end_process, |
| 583 |
'second' => ( $end_process['microtime'] - $start_process['microtime'] ), |
| 584 |
'memory' => ( $end_process['memory_get_usage'] - $start_process['memory_get_usage'] ), |
| 585 |
'load_avg' => $start_process['load_avg'], |
| 586 |
); |
| 587 |
|
| 588 |
return $format_process; |
| 589 |
|
| 590 |
} |
| 591 |
|
| 592 |
private static function print_format( $process ) { |
| 593 |
|
| 594 |
if( ! isset( $process['second'] ) or ! isset( $process['memory'] ) ) { |
| 595 |
|
| 596 |
return false; |
| 597 |
|
| 598 |
} |
| 599 |
|
| 600 |
if( function_exists( 'sys_getloadavg' ) ) { |
| 601 |
|
| 602 |
$print_format = sprintf( 'Time: %s - Memory: %s - LoadAvg: %s' , self::get_second( $process['second'] ) , MywpHelper::get_byte( $process['memory'] ) , strip_tags( $process['load_avg'] ) ); |
| 603 |
|
| 604 |
} else { |
| 605 |
|
| 606 |
$print_format = sprintf( 'Time: %s - Memory: %s' , self::get_second( $process['second'] ) , MywpHelper::get_byte( $process['memory'] ) ); |
| 607 |
|
| 608 |
} |
| 609 |
|
| 610 |
$print_format .= "\n"; |
| 611 |
|
| 612 |
return $print_format; |
| 613 |
|
| 614 |
} |
| 615 |
|
| 616 |
private static function print_filters( $action_hook_name , $from_priority , $to_priority , $is_list = false ) { |
| 617 |
|
| 618 |
if( empty( $action_hook_name ) ) { |
| 619 |
|
| 620 |
return false; |
| 621 |
|
| 622 |
} |
| 623 |
|
| 624 |
$filter_to_func = MywpDeveloper::get_filter_to_func( $action_hook_name ); |
| 625 |
|
| 626 |
if( empty( $filter_to_func ) ) { |
| 627 |
|
| 628 |
return false; |
| 629 |
|
| 630 |
} |
| 631 |
|
| 632 |
$print_filters = false; |
| 633 |
|
| 634 |
if( $is_list ) { |
| 635 |
|
| 636 |
$print_filters = '<textarea readonly="readonly" style="height: 30px;">'; |
| 637 |
|
| 638 |
} |
| 639 |
|
| 640 |
foreach( $filter_to_func as $func ) { |
| 641 |
|
| 642 |
if( $func['priority'] >= $from_priority && $func['priority'] <= $to_priority ) { |
| 643 |
|
| 644 |
$print_filters .= sprintf( '(%s) %s' , esc_html( $func['priority'] ) , esc_html( $func['print_format'] ) ); |
| 645 |
|
| 646 |
$print_filters .= "\n"; |
| 647 |
|
| 648 |
} |
| 649 |
|
| 650 |
} |
| 651 |
|
| 652 |
if( $is_list ) { |
| 653 |
|
| 654 |
$print_filters .= '</textarea>'; |
| 655 |
|
| 656 |
} else { |
| 657 |
|
| 658 |
$print_filters .= "\n"; |
| 659 |
|
| 660 |
} |
| 661 |
|
| 662 |
return $print_filters; |
| 663 |
|
| 664 |
} |
| 665 |
|
| 666 |
private static function get_second( $second = false ) { |
| 667 |
|
| 668 |
if( $second === false ) { |
| 669 |
|
| 670 |
return false; |
| 671 |
|
| 672 |
} |
| 673 |
|
| 674 |
$decimals = 3; |
| 675 |
|
| 676 |
$number = false; |
| 677 |
|
| 678 |
if( function_exists( 'number_format_i18n' ) ) { |
| 679 |
|
| 680 |
$number = number_format_i18n( $second , $decimals ); |
| 681 |
|
| 682 |
} else { |
| 683 |
|
| 684 |
$number = number_format( $second , $decimals ); |
| 685 |
|
| 686 |
} |
| 687 |
|
| 688 |
return "{$number} seconds"; |
| 689 |
|
| 690 |
} |
| 691 |
|
| 692 |
} |
| 693 |
|
| 694 |
MywpDeveloperModuleDevTimes::init(); |
| 695 |
|
| 696 |
endif; |
| 697 |
|