Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: comment-author-name.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/comment-author-name` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/comment-author-name` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 6.0.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 Return the post comment's author.
[15] Fix | Delete
*/
[16] Fix | Delete
function render_block_core_comment_author_name( $attributes, $content, $block ) {
[17] Fix | Delete
if ( ! isset( $block->context['commentId'] ) ) {
[18] Fix | Delete
return '';
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
$comment = get_comment( $block->context['commentId'] );
[22] Fix | Delete
$commenter = wp_get_current_commenter();
[23] Fix | Delete
$show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author'];
[24] Fix | Delete
if ( empty( $comment ) ) {
[25] Fix | Delete
return '';
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
$classes = array();
[29] Fix | Delete
if ( isset( $attributes['textAlign'] ) ) {
[30] Fix | Delete
$classes[] = 'has-text-align-' . $attributes['textAlign'];
[31] Fix | Delete
}
[32] Fix | Delete
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
[33] Fix | Delete
$classes[] = 'has-link-color';
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
[37] Fix | Delete
$comment_author = get_comment_author( $comment );
[38] Fix | Delete
$link = get_comment_author_url( $comment );
[39] Fix | Delete
[40] Fix | Delete
if ( ! empty( $link ) && ! empty( $attributes['isLink'] ) && ! empty( $attributes['linkTarget'] ) ) {
[41] Fix | Delete
$comment_author = sprintf( '<a rel="external nofollow ugc" href="%1s" target="%2s" >%3s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $comment_author );
[42] Fix | Delete
}
[43] Fix | Delete
if ( '0' === $comment->comment_approved && ! $show_pending_links ) {
[44] Fix | Delete
$comment_author = wp_kses( $comment_author, array() );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
return sprintf(
[48] Fix | Delete
'<div %1$s>%2$s</div>',
[49] Fix | Delete
$wrapper_attributes,
[50] Fix | Delete
$comment_author
[51] Fix | Delete
);
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Registers the `core/comment-author-name` block on the server.
[56] Fix | Delete
*
[57] Fix | Delete
* @since 6.0.0
[58] Fix | Delete
*/
[59] Fix | Delete
function register_block_core_comment_author_name() {
[60] Fix | Delete
register_block_type_from_metadata(
[61] Fix | Delete
__DIR__ . '/comment-author-name',
[62] Fix | Delete
array(
[63] Fix | Delete
'render_callback' => 'render_block_core_comment_author_name',
[64] Fix | Delete
)
[65] Fix | Delete
);
[66] Fix | Delete
}
[67] Fix | Delete
add_action( 'init', 'register_block_core_comment_author_name' );
[68] Fix | Delete
[69] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function