block_core_heading_render()
Adds a wp-block-heading class to the heading block content.
For example, the following block content: <h2 class="align-left">Hello World</h2>
Would be transformed to: <h2 class="align-left wp-block-heading">Hello World</h2>
Хуков нет.
Возвращает
Строку
. The content of the block being rendered.
Использование
block_core_heading_render( $attributes, $content );
- $attributes(массив) (обязательный)
- Attributes of the block being rendered.
- $content(строка) (обязательный)
- Content of the block being rendered.
Список изменений
С версии 6.2.0 | Введена. |
Код block_core_heading_render() block core heading render WP 6.7.1
function block_core_heading_render( $attributes, $content ) { if ( ! $content ) { return $content; } $p = new WP_HTML_Tag_Processor( $content ); $header_tags = array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ); while ( $p->next_tag() ) { if ( in_array( $p->get_tag(), $header_tags, true ) ) { $p->add_class( 'wp-block-heading' ); break; } } return $p->get_updated_html(); }