public function send_timing_header( $input ) {

		if ( headers_sent() ) {
			return $input;
		}

		$ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
		$rest = defined( 'REST_REQUEST' ) && REST_REQUEST;

		if ( ! $ajax && ! $rest ) {
			return $input;
		}

		// This will be false in REST API w/o nonce, even with valid cookie. Might make sense to filter to true in dev.
		if ( ! apply_filters( 'laps_can_see', current_user_can( 'manage_options' ) ) ) {
			return $input;
		}

		$header  = '';

		/** @var Record_Interface $record */
		foreach ( $this->collector->get_records() as $record ) {
			$duration = $record->get_duration() * 1000;

			if ( $duration < 1 ) {
				continue;
			}

			$header .= sprintf( '%s;dur=%.2f;desc="%s", ', $record->get_category(), $duration, $record->get_name() );
		}

		header( 'Server-Timing: ' . preg_replace( '/\R/', '', $header ) );

		return $input;
	}
public function send_timing_header( $input ) {

		if ( headers_sent() ) {
			return $input;
		}

		$ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
		$rest = defined( 'REST_REQUEST' ) && REST_REQUEST;

		if ( ! $ajax && ! $rest ) {
			return $input;
		}

		// This will be false in REST API w/o nonce, even with valid cookie. Might make sense to filter to true in dev.
		if ( ! apply_filters( 'laps_can_see', current_user_can( 'manage_options' ) ) ) {
			return $input;
		}

		$header  = '';

		/** @var Record_Interface $record */
		foreach ( $this->collector->get_records() as $record ) {
			$duration = $record->get_duration() * 1000;

			if ( $duration < 1 ) {
				continue;
			}

			$header .= sprintf( '%s;dur=%.2f;desc="%s", ', $record->get_category(), $duration, $record->get_name() );
		}

		header( 'Server-Timing: ' . preg_replace( '/\R/', '', $header ) );

		return $input;
	}
public function send_timing_header ( $ input ) { if ( headers_sent ( ) ) { return $ input ; } $ ajax = defined ( 'DOING_AJAX' ) && DOING_AJAX ; $ rest = defined ( 'REST_REQUEST' ) && REST_REQUEST ; if ( ! $ ajax && ! $ rest ) { return $ input ; } // This will be false in REST API w/o nonce, even with valid cookie. Might make sense to filter to true in dev. if ( ! apply_filters ( 'laps_can_see' , current_user_can ( 'manage_options' ) ) ) { return $ input ; } $ header = '' ; /** @var Record_Interface $record */ foreach ( $ this -> collector -> get_records ( ) as $ record ) { $ duration = $ record -> get_duration ( ) * 1000 ; if ( $ duration < 1 ) { continue ; } $ header .= sprintf ( '%s;dur=%.2f;desc="%s", ' , $ record -> get_category ( ) , $ duration , $ record -> get_name ( ) ) ; } header ( 'Server-Timing: ' . preg_replace ( '/\R/' , '' , $ header ) ) ; return $ input ; }
Sends Server Timing API header with records data.

@param mixed $input Pass-through input for attaching to a filter hook.

@return mixed
Sends Server Timing API header with records data .