Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: post-title.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/post-title` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/post-title` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 6.3.0 Omitting the $post argument from the `get_the_title`.
[10] Fix | Delete
*
[11] Fix | Delete
* @param array $attributes Block attributes.
[12] Fix | Delete
* @param string $content Block default content.
[13] Fix | Delete
* @param WP_Block $block Block instance.
[14] Fix | Delete
*
[15] Fix | Delete
* @return string Returns the filtered post title for the current post wrapped inside "h1" tags.
[16] Fix | Delete
*/
[17] Fix | Delete
function render_block_core_post_title( $attributes, $content, $block ) {
[18] Fix | Delete
if ( ! isset( $block->context['postId'] ) ) {
[19] Fix | Delete
return '';
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* The `$post` argument is intentionally omitted so that changes are reflected when previewing a post.
[24] Fix | Delete
* See: https://github.com/WordPress/gutenberg/pull/37622#issuecomment-1000932816.
[25] Fix | Delete
*/
[26] Fix | Delete
$title = get_the_title();
[27] Fix | Delete
[28] Fix | Delete
if ( ! $title ) {
[29] Fix | Delete
return '';
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
$tag_name = 'h2';
[33] Fix | Delete
if ( isset( $attributes['level'] ) ) {
[34] Fix | Delete
$tag_name = 0 === $attributes['level'] ? 'p' : 'h' . (int) $attributes['level'];
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
[38] Fix | Delete
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
[39] Fix | Delete
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', esc_url( get_the_permalink( $block->context['postId'] ) ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
$classes = array();
[43] Fix | Delete
if ( isset( $attributes['textAlign'] ) ) {
[44] Fix | Delete
$classes[] = 'has-text-align-' . $attributes['textAlign'];
[45] Fix | Delete
}
[46] Fix | Delete
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
[47] Fix | Delete
$classes[] = 'has-link-color';
[48] Fix | Delete
}
[49] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
[50] Fix | Delete
[51] Fix | Delete
return sprintf(
[52] Fix | Delete
'<%1$s %2$s>%3$s</%1$s>',
[53] Fix | Delete
$tag_name,
[54] Fix | Delete
$wrapper_attributes,
[55] Fix | Delete
$title
[56] Fix | Delete
);
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Registers the `core/post-title` block on the server.
[61] Fix | Delete
*
[62] Fix | Delete
* @since 5.8.0
[63] Fix | Delete
*/
[64] Fix | Delete
function register_block_core_post_title() {
[65] Fix | Delete
register_block_type_from_metadata(
[66] Fix | Delete
__DIR__ . '/post-title',
[67] Fix | Delete
array(
[68] Fix | Delete
'render_callback' => 'render_block_core_post_title',
[69] Fix | Delete
)
[70] Fix | Delete
);
[71] Fix | Delete
}
[72] Fix | Delete
add_action( 'init', 'register_block_core_post_title' );
[73] Fix | Delete
[74] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function