wpseek.com
WordPress开发者和主题制作者的搜索引擎
wp_register_block_style_variations_from_theme_json_partials is private and should not be used in themes or plugins directly.
wp_register_block_style_variations_from_theme_json_partials › WordPress Function
Since6.6.0
已弃用n/a
› wp_register_block_style_variations_from_theme_json_partials ( $variations )
访问: |
|
参数: |
|
定义在: | |
文档: |
Registers block style variations read in from theme.json partials.
源码
function wp_register_block_style_variations_from_theme_json_partials( $variations ) { if ( empty( $variations ) ) { return; } $registry = WP_Block_Styles_Registry::get_instance(); foreach ( $variations as $variation ) { if ( empty( $variation['blockTypes'] ) || empty( $variation['styles'] ) ) { continue; } $variation_name = $variation['slug'] ?? _wp_to_kebab_case( $variation['title'] ); $variation_label = $variation['title'] ?? $variation_name; foreach ( $variation['blockTypes'] as $block_type ) { $registered_styles = $registry->get_registered_styles_for_block( $block_type ); // Register block style variation if it hasn't already been registered. if ( ! array_key_exists( $variation_name, $registered_styles ) ) { register_block_style( $block_type, array( 'name' => $variation_name, 'label' => $variation_label, ) ); } } } }