Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: post-comments-link.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/post-comments-link` 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-comments-link` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 6.9.0
[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
* @return string Returns the rendered link.
[15] Fix | Delete
*/
[16] Fix | Delete
function render_block_core_post_comments_link( $attributes, $content, $block ) {
[17] Fix | Delete
if (
[18] Fix | Delete
! isset( $block->context['postId'] ) ||
[19] Fix | Delete
isset( $block->context['postId'] ) &&
[20] Fix | Delete
! comments_open( $block->context['postId'] )
[21] Fix | Delete
) {
[22] Fix | Delete
return '';
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
$classes = array();
[26] Fix | Delete
if ( isset( $attributes['textAlign'] ) ) {
[27] Fix | Delete
$classes[] = 'has-text-align-' . $attributes['textAlign'];
[28] Fix | Delete
}
[29] Fix | Delete
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
[30] Fix | Delete
$classes[] = 'has-link-color';
[31] Fix | Delete
}
[32] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
[33] Fix | Delete
$comments_number = (int) get_comments_number( $block->context['postId'] );
[34] Fix | Delete
$comments_link = get_comments_link( $block->context['postId'] );
[35] Fix | Delete
$post_title = get_the_title( $block->context['postId'] );
[36] Fix | Delete
$comment_html = '';
[37] Fix | Delete
[38] Fix | Delete
if ( 0 === $comments_number ) {
[39] Fix | Delete
$comment_html = sprintf(
[40] Fix | Delete
/* translators: %s post title */
[41] Fix | Delete
__( 'No comments<span class="screen-reader-text"> on %s</span>' ),
[42] Fix | Delete
$post_title
[43] Fix | Delete
);
[44] Fix | Delete
} else {
[45] Fix | Delete
$comment_html = sprintf(
[46] Fix | Delete
/* translators: 1: Number of comments, 2: post title */
[47] Fix | Delete
_n(
[48] Fix | Delete
'%1$s comment<span class="screen-reader-text"> on %2$s</span>',
[49] Fix | Delete
'%1$s comments<span class="screen-reader-text"> on %2$s</span>',
[50] Fix | Delete
$comments_number
[51] Fix | Delete
),
[52] Fix | Delete
esc_html( number_format_i18n( $comments_number ) ),
[53] Fix | Delete
$post_title
[54] Fix | Delete
);
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
return '<div ' . $wrapper_attributes . '><a href=' . esc_url( $comments_link ) . '>' . $comment_html . '</a></div>';
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Registers the `core/post-comments-link` block on the server.
[62] Fix | Delete
*
[63] Fix | Delete
* @since 6.9.0
[64] Fix | Delete
*/
[65] Fix | Delete
function register_block_core_post_comments_link() {
[66] Fix | Delete
register_block_type_from_metadata(
[67] Fix | Delete
__DIR__ . '/post-comments-link',
[68] Fix | Delete
array(
[69] Fix | Delete
'render_callback' => 'render_block_core_post_comments_link',
[70] Fix | Delete
)
[71] Fix | Delete
);
[72] Fix | Delete
}
[73] Fix | Delete
add_action( 'init', 'register_block_core_post_comments_link' );
[74] Fix | Delete
[75] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function