Edit File by line
/home/zeestwma/redstone.../wp-inclu.../blocks
File: comment-date.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/comment-date` 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-date` 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 date.
[15] Fix | Delete
*/
[16] Fix | Delete
function render_block_core_comment_date( $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
if ( empty( $comment ) ) {
[23] Fix | Delete
return '';
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
$classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';
[27] Fix | Delete
[28] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
[29] Fix | Delete
if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) {
[30] Fix | Delete
// translators: %s: human-readable time difference.
[31] Fix | Delete
$formatted_date = sprintf( __( '%s ago' ), human_time_diff( get_comment_date( 'U', $comment ) ) );
[32] Fix | Delete
} else {
[33] Fix | Delete
$formatted_date = get_comment_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $comment );
[34] Fix | Delete
}
[35] Fix | Delete
$link = get_comment_link( $comment );
[36] Fix | Delete
[37] Fix | Delete
if ( ! empty( $attributes['isLink'] ) ) {
[38] Fix | Delete
$formatted_date = sprintf( '<a href="%1s">%2s</a>', esc_url( $link ), $formatted_date );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
return sprintf(
[42] Fix | Delete
'<div %1$s><time datetime="%2$s">%3$s</time></div>',
[43] Fix | Delete
$wrapper_attributes,
[44] Fix | Delete
esc_attr( get_comment_date( 'c', $comment ) ),
[45] Fix | Delete
$formatted_date
[46] Fix | Delete
);
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Registers the `core/comment-date` block on the server.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 6.0.0
[53] Fix | Delete
*/
[54] Fix | Delete
function register_block_core_comment_date() {
[55] Fix | Delete
register_block_type_from_metadata(
[56] Fix | Delete
__DIR__ . '/comment-date',
[57] Fix | Delete
array(
[58] Fix | Delete
'render_callback' => 'render_block_core_comment_date',
[59] Fix | Delete
)
[60] Fix | Delete
);
[61] Fix | Delete
}
[62] Fix | Delete
add_action( 'init', 'register_block_core_comment_date' );
[63] Fix | Delete
[64] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function