wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_load_classic_theme_block_styles_on_demand › WordPress Function

Since6.9.0
Deprecatedn/a
wp_load_classic_theme_block_styles_on_demand ( No parameters )
Defined at:
Codex:

Adds hooks to load block styles on demand in classic themes.



Source

function wp_load_classic_theme_block_styles_on_demand() {
	if ( wp_is_block_theme() ) {
		return;
	}

	/*
	 * Make sure that wp_should_output_buffer_template_for_enhancement() returns true even if there aren't any
	 * `wp_template_enhancement_output_buffer` filters added, but do so at priority zero so that applications which
	 * wish to stream responses can more easily turn this off.
	 */
	add_filter( 'wp_should_output_buffer_template_for_enhancement', '__return_true', 0 );

	if ( ! wp_should_output_buffer_template_for_enhancement() ) {
		return;
	}

	/*
	 * Load separate block styles so that the large block-library stylesheet is not enqueued unconditionally,
	 * and so that block-specific styles will only be enqueued when they are used on the page.
	 */
	add_filter( 'should_load_separate_core_block_assets', '__return_true', 0 );

	// Also ensure that block assets are loaded on demand (although the default value is from should_load_separate_core_block_assets).
	add_filter( 'should_load_block_assets_on_demand', '__return_true', 0 );

	// Add hooks which require the presence of the output buffer. Ideally the above two filters could be added here, but they run too early.
	add_action( 'wp_template_enhancement_output_buffer_started', 'wp_hoist_late_printed_styles' );
}