Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu.../blocks
File: comment-reply-link.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/comment-reply-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/comment-reply-link` 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 reply link.
[15] Fix | Delete
*/
[16] Fix | Delete
function render_block_core_comment_reply_link( $attributes, $content, $block ) {
[17] Fix | Delete
if ( ! isset( $block->context['commentId'] ) ) {
[18] Fix | Delete
return '';
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
$thread_comments = get_option( 'thread_comments' );
[22] Fix | Delete
if ( ! $thread_comments ) {
[23] Fix | Delete
return '';
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
$comment = get_comment( $block->context['commentId'] );
[27] Fix | Delete
if ( empty( $comment ) ) {
[28] Fix | Delete
return '';
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
$depth = 1;
[32] Fix | Delete
$max_depth = get_option( 'thread_comments_depth' );
[33] Fix | Delete
$parent_id = $comment->comment_parent;
[34] Fix | Delete
[35] Fix | Delete
// Compute comment's depth iterating over its ancestors.
[36] Fix | Delete
while ( ! empty( $parent_id ) ) {
[37] Fix | Delete
++$depth;
[38] Fix | Delete
$parent_id = get_comment( $parent_id )->comment_parent;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
$comment_reply_link = get_comment_reply_link(
[42] Fix | Delete
array(
[43] Fix | Delete
'depth' => $depth,
[44] Fix | Delete
'max_depth' => $max_depth,
[45] Fix | Delete
),
[46] Fix | Delete
$comment
[47] Fix | Delete
);
[48] Fix | Delete
[49] Fix | Delete
// Render nothing if the generated reply link is empty.
[50] Fix | Delete
if ( empty( $comment_reply_link ) ) {
[51] Fix | Delete
return;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
$classes = array();
[55] Fix | Delete
if ( isset( $attributes['textAlign'] ) ) {
[56] Fix | Delete
$classes[] = 'has-text-align-' . $attributes['textAlign'];
[57] Fix | Delete
}
[58] Fix | Delete
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
[59] Fix | Delete
$classes[] = 'has-link-color';
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
[63] Fix | Delete
[64] Fix | Delete
return sprintf(
[65] Fix | Delete
'<div %1$s>%2$s</div>',
[66] Fix | Delete
$wrapper_attributes,
[67] Fix | Delete
$comment_reply_link
[68] Fix | Delete
);
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Registers the `core/comment-reply-link` block on the server.
[73] Fix | Delete
*
[74] Fix | Delete
* @since 6.0.0
[75] Fix | Delete
*/
[76] Fix | Delete
function register_block_core_comment_reply_link() {
[77] Fix | Delete
register_block_type_from_metadata(
[78] Fix | Delete
__DIR__ . '/comment-reply-link',
[79] Fix | Delete
array(
[80] Fix | Delete
'render_callback' => 'render_block_core_comment_reply_link',
[81] Fix | Delete
)
[82] Fix | Delete
);
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
add_action( 'init', 'register_block_core_comment_reply_link' );
[86] Fix | Delete
[87] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function