wp_render_block_style_variation_class_name()
Ensures the variation block support class name generated and added to block attributes in the render_block_data gets applied to the block's markup.
Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
Строку. Filtered block content.
Использование
wp_render_block_style_variation_class_name( $block_content, $block );
- $block_content(строка) (обязательный)
- Rendered block content.
- $block(массив) (обязательный)
- Block object.
Заметки
Список изменений
| С версии 6.6.0 | Введена. |
Код wp_render_block_style_variation_class_name() wp render block style variation class name WP 6.9
function wp_render_block_style_variation_class_name( $block_content, $block ) {
if ( ! $block_content || empty( $block['attrs']['className'] ) ) {
return $block_content;
}
/*
* Matches a class prefixed by `is-style`, followed by the
* variation slug, then `--`, and finally an instance number.
*/
preg_match( '/\bis-style-(\S+?--\d+)\b/', $block['attrs']['className'], $matches );
if ( empty( $matches ) ) {
return $block_content;
}
$tags = new WP_HTML_Tag_Processor( $block_content );
if ( $tags->next_tag() ) {
/*
* Ensure the variation instance class name set in the
* `render_block_data` filter is applied in markup.
* See `wp_render_block_style_variation_support_styles`.
*/
$tags->add_class( $matches[0] );
}
return $tags->get_updated_html();
}