Edit File by line
/home/zeestwma/redstone.../wp-inclu.../blocks
File: heading.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Appending the wp-block-heading to before rendering the stored `core/heading` block contents.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Adds a wp-block-heading class to the heading block content.
[8] Fix | Delete
*
[9] Fix | Delete
* For example, the following block content:
[10] Fix | Delete
* <h2 class="align-left">Hello World</h2>
[11] Fix | Delete
*
[12] Fix | Delete
* Would be transformed to:
[13] Fix | Delete
* <h2 class="align-left wp-block-heading">Hello World</h2>
[14] Fix | Delete
*
[15] Fix | Delete
* @since 6.2.0
[16] Fix | Delete
*
[17] Fix | Delete
* @param array $attributes Attributes of the block being rendered.
[18] Fix | Delete
* @param string $content Content of the block being rendered.
[19] Fix | Delete
*
[20] Fix | Delete
* @return string The content of the block being rendered.
[21] Fix | Delete
*/
[22] Fix | Delete
function block_core_heading_render( $attributes, $content ) {
[23] Fix | Delete
if ( ! $content ) {
[24] Fix | Delete
return $content;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
$p = new WP_HTML_Tag_Processor( $content );
[28] Fix | Delete
[29] Fix | Delete
$header_tags = array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' );
[30] Fix | Delete
while ( $p->next_tag() ) {
[31] Fix | Delete
if ( in_array( $p->get_tag(), $header_tags, true ) ) {
[32] Fix | Delete
$p->add_class( 'wp-block-heading' );
[33] Fix | Delete
break;
[34] Fix | Delete
}
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
return $p->get_updated_html();
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Registers the `core/heading` block on server.
[42] Fix | Delete
*
[43] Fix | Delete
* @since 6.2.0
[44] Fix | Delete
*/
[45] Fix | Delete
function register_block_core_heading() {
[46] Fix | Delete
register_block_type_from_metadata(
[47] Fix | Delete
__DIR__ . '/heading',
[48] Fix | Delete
array(
[49] Fix | Delete
'render_callback' => 'block_core_heading_render',
[50] Fix | Delete
)
[51] Fix | Delete
);
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
add_action( 'init', 'register_block_core_heading' );
[55] Fix | Delete
[56] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function