wp_template_enhancement_output_buffer хук-фильтрWP 6.9.0

Filters the template enhancement output buffer prior to sending to the client.

This filter only applies the HTML output of an included template. This filter is a progressive enhancement intended for applications such as optimizing markup to improve frontend page load performance. Sites must not depend on this filter applying since they may opt to stream the responses instead. Callbacks for this filter are highly discouraged from using regular expressions to do any kind of replacement on the output. Use the HTML API (either WP_HTML_Tag_Processor or WP_HTML_Processor), or else use {@see DOM\HtmlDocument} as of PHP 8.4 which fully supports HTML5.

Do not print any output during this filter. While filters normally don't print anything, this is especially important since this applies during an output buffer callback. Prior to PHP 8.5, the output will be silently omitted, whereas afterward a deprecation notice will be emitted.

Important: Because this filter is applied inside an output buffer callback (i.e. display handler), any callbacks added to the filter must not attempt to start their own output buffers. Otherwise, PHP will raise a fatal error: "Cannot use output buffering in output buffering display handlers."

Использование

add_filter( 'wp_template_enhancement_output_buffer', 'wp_kama_template_enhancement_output_buffer_filter', 10, 2 );

/**
 * Function for `wp_template_enhancement_output_buffer` filter-hook.
 * 
 * @param string $filtered_output HTML template enhancement output buffer.
 * @param string $output          Original HTML template output buffer.
 *
 * @return string
 */
function wp_kama_template_enhancement_output_buffer_filter( $filtered_output, $output ){

	// filter...
	return $filtered_output;
}
$filtered_output(строка)
HTML template enhancement output buffer.
$output(строка)
Original HTML template output buffer.

Список изменений

С версии 6.9.0 Введена.

Где вызывается хук

wp_finalize_template_enhancement_output_buffer()
wp_template_enhancement_output_buffer
wp-includes/template.php 1019
$filtered_output = (string) apply_filters( 'wp_template_enhancement_output_buffer', $filtered_output, $output );

Где используется хук в WordPress

Использование не найдено.