wp_enqueue_block_support_styles() WordPress Function

The wp_enqueue_block_support_styles() function is used to enqueue styles for blocks. This function should be called inside the block editor initialization function.

wp_enqueue_block_support_styles( string $style ) #

This function takes care of adding inline styles in the proper place, depending on the theme in use.


Parameters

$style

(string)(Required)String containing the CSS styles to be added.


Top ↑

Source

File: wp-includes/script-loader.php

function wp_enqueue_block_support_styles( $style ) {
	$action_hook_name = 'wp_footer';
	if ( wp_is_block_theme() ) {
		$action_hook_name = 'wp_head';
	}
	add_action(
		$action_hook_name,
		static function () use ( $style ) {
			echo "<style>$style</style>\n";
		}
	);
}


Top ↑

Changelog

Changelog
VersionDescription
5.9.1Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More