
wp_enqueue_scripts – 如何在WordPress中实现资源队列
wp_enqueue_block_support_styles ( $style, $priority = 10 )
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 ); }