wp_enqueue_block_support_styles

函数
wp_enqueue_block_support_styles ( $style, $priority = 10 )
参数
  • (string) $style String containing the CSS styles to be added.
    Required:
  • (int) $priority To set the priority for the add_action.
    Required:
    Default: 10
定义位置
相关方法
wp_enqueue_block_stylewp_enqueue_stored_styleswp_enqueue_global_styleswp_render_elements_support_styleswp_enqueue_registered_block_scripts_and_styles
引入
5.9.1
弃用
-

wp_enqueue_block_support_styles: 这个函数用来为WordPress块编辑器中的所有支持的块提取样式。这对于一次性定制多个块的样式很有用。

根据活动主题,将内联样式挂在适当的位置。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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
);
}
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 ); }
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
	);
}

常见问题

FAQs
查看更多 >