mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Note: This is enforced by WPCS 3.0.0. Reference: [https://github.com/WordPress/WordPress-Coding-Standards/pull/2328 WPCS: PR #2328 Core: properly check formatting of function declaration statements]. Props jrf. See #59161, #58831. git-svn-id: https://develop.svn.wordpress.org/trunk@56559 602fd350-edb4-49c9-b593-d223f7449a82
46 lines
1020 B
PHP
46 lines
1020 B
PHP
<?php
|
|
|
|
add_filter(
|
|
'template_include',
|
|
static function ( $template ) {
|
|
|
|
global $timestart;
|
|
|
|
$server_timing_values = array();
|
|
$template_start = microtime( true );
|
|
|
|
$server_timing_values['before-template'] = $template_start - $timestart;
|
|
|
|
ob_start();
|
|
|
|
add_action(
|
|
'shutdown',
|
|
static function () use ( $server_timing_values, $template_start ) {
|
|
|
|
global $timestart;
|
|
|
|
$output = ob_get_clean();
|
|
|
|
$server_timing_values['template'] = microtime( true ) - $template_start;
|
|
|
|
$server_timing_values['total'] = $server_timing_values['before-template'] + $server_timing_values['template'];
|
|
|
|
$header_values = array();
|
|
foreach ( $server_timing_values as $slug => $value ) {
|
|
if ( is_float( $value ) ) {
|
|
$value = round( $value * 1000.0, 2 );
|
|
}
|
|
$header_values[] = sprintf( 'wp-%1$s;dur=%2$s', $slug, $value );
|
|
}
|
|
header( 'Server-Timing: ' . implode( ', ', $header_values ) );
|
|
|
|
echo $output;
|
|
},
|
|
PHP_INT_MIN
|
|
);
|
|
|
|
return $template;
|
|
},
|
|
PHP_INT_MAX
|
|
);
|