wp_enqueue_block_support_styles()WP 5.9.1

Hooks inline styles in the proper place, depending on the active theme.

For block themes, styles are loaded in the head. For classic ones, styles are loaded in the body because the wp_head action happens before render_block.

Хуков нет.

Возвращает

null. Ничего.

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

wp_enqueue_block_support_styles( $style, $priority );
$style(строка) (обязательный)
String containing the CSS styles to be added.
$priority(int)
To set the priority for the add_action.
По умолчанию: 10

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

С версии 5.9.1 Введена.
С версии 6.1.0 Added the $priority parameter.

Код wp_enqueue_block_support_styles() WP 6.1.1

function wp_enqueue_block_support_styles( $style, $priority = 10 ) {
	$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";
		},
		$priority
	);
}