wp_enqueue_block_support_styles()WP 5.9.1

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

For block themes, it's loaded in the head. For classic ones, it's loaded in the body because the wp_head action happens before the render_block.

Хуков нет.

Возвращает

null. Ничего.

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

wp_enqueue_block_support_styles( $style );
$style(строка) (обязательный)
String containing the CSS styles to be added.

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

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

Код wp_enqueue_block_support_styles() WP 6.0

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";
		}
	);
}