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块编辑器中的所有支持的块提取样式。这对于一次性定制多个块的样式很有用。

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

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
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 15:32:55

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: