wp_should_output_buffer_template_for_enhancement filter-hookWP 6.9.0

Filters whether the template should be output-buffered for enhancement.

By default, an output buffer is only started if a wp_template_enhancement_output_buffer filter has been added or if a plugin has added a wp_finalized_template_enhancement_output_buffer action. For this default to apply, either of the hooks must be added by the time the template is included at the wp_before_include_template action. This allows template responses to be streamed unless the there is code which depends on an output buffer being opened. This filter allows a site to opt in to adding such template enhancement filters later during the rendering of the template.

Usage

add_filter( 'wp_should_output_buffer_template_for_enhancement', 'wp_kama_should_output_buffer_template_for_enhancement_filter' );

/**
 * Function for `wp_should_output_buffer_template_for_enhancement` filter-hook.
 * 
 * @param bool $use_output_buffer Whether an output buffer is started.
 *
 * @return bool
 */
function wp_kama_should_output_buffer_template_for_enhancement_filter( $use_output_buffer ){

	// filter...
	return $use_output_buffer;
}
$use_output_buffer(true|false)
Whether an output buffer is started.

Changelog

Since 6.9.0 Introduced.

Where the hook is called

wp_should_output_buffer_template_for_enhancement()
wp_should_output_buffer_template_for_enhancement
wp-includes/template.php 857
return (bool) apply_filters( 'wp_should_output_buffer_template_for_enhancement', has_filter( 'wp_template_enhancement_output_buffer' ) || has_action( 'wp_finalized_template_enhancement_output_buffer' ) );

Where the hook is used in WordPress

wp-includes/script-loader.php 3695
add_filter( 'wp_should_output_buffer_template_for_enhancement', '__return_true', 0 );