Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: comments-pagination-numbers.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/comments-pagination-numbers` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/comments-pagination-numbers` 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
*
[15] Fix | Delete
* @return string Returns the pagination numbers for the comments.
[16] Fix | Delete
*/
[17] Fix | Delete
function render_block_core_comments_pagination_numbers( $attributes, $content, $block ) {
[18] Fix | Delete
// Bail out early if the post ID is not set for some reason.
[19] Fix | Delete
if ( empty( $block->context['postId'] ) ) {
[20] Fix | Delete
return '';
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
$comment_vars = build_comment_query_vars_from_block( $block );
[24] Fix | Delete
[25] Fix | Delete
$total = ( new WP_Comment_Query( $comment_vars ) )->max_num_pages;
[26] Fix | Delete
$current = ! empty( $comment_vars['paged'] ) ? $comment_vars['paged'] : null;
[27] Fix | Delete
[28] Fix | Delete
// Render links.
[29] Fix | Delete
$content = paginate_comments_links(
[30] Fix | Delete
array(
[31] Fix | Delete
'total' => $total,
[32] Fix | Delete
'current' => $current,
[33] Fix | Delete
'prev_next' => false,
[34] Fix | Delete
'echo' => false,
[35] Fix | Delete
)
[36] Fix | Delete
);
[37] Fix | Delete
[38] Fix | Delete
if ( empty( $content ) ) {
[39] Fix | Delete
return '';
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes();
[43] Fix | Delete
[44] Fix | Delete
return sprintf(
[45] Fix | Delete
'<div %1$s>%2$s</div>',
[46] Fix | Delete
$wrapper_attributes,
[47] Fix | Delete
$content
[48] Fix | Delete
);
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Registers the `core/comments-pagination-numbers` block on the server.
[53] Fix | Delete
*
[54] Fix | Delete
* @since 6.0.0
[55] Fix | Delete
*/
[56] Fix | Delete
function register_block_core_comments_pagination_numbers() {
[57] Fix | Delete
register_block_type_from_metadata(
[58] Fix | Delete
__DIR__ . '/comments-pagination-numbers',
[59] Fix | Delete
array(
[60] Fix | Delete
'render_callback' => 'render_block_core_comments_pagination_numbers',
[61] Fix | Delete
)
[62] Fix | Delete
);
[63] Fix | Delete
}
[64] Fix | Delete
add_action( 'init', 'register_block_core_comments_pagination_numbers' );
[65] Fix | Delete
[66] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function