Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: query-pagination-next.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/query-pagination-next` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/query-pagination-next` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 5.8.0
[10] Fix | Delete
*
[11] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[12] Fix | Delete
*
[13] Fix | Delete
* @param array $attributes Block attributes.
[14] Fix | Delete
* @param string $content Block default content.
[15] Fix | Delete
* @param WP_Block $block Block instance.
[16] Fix | Delete
*
[17] Fix | Delete
* @return string Returns the next posts link for the query pagination.
[18] Fix | Delete
*/
[19] Fix | Delete
function render_block_core_query_pagination_next( $attributes, $content, $block ) {
[20] Fix | Delete
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
[21] Fix | Delete
$enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination'];
[22] Fix | Delete
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
[23] Fix | Delete
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
[24] Fix | Delete
[25] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes();
[26] Fix | Delete
$show_label = isset( $block->context['showLabel'] ) ? (bool) $block->context['showLabel'] : true;
[27] Fix | Delete
$default_label = __( 'Next Page' );
[28] Fix | Delete
$label_text = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? esc_html( $attributes['label'] ) : $default_label;
[29] Fix | Delete
$label = $show_label ? $label_text : '';
[30] Fix | Delete
$pagination_arrow = get_query_pagination_arrow( $block, true );
[31] Fix | Delete
[32] Fix | Delete
if ( ! $label ) {
[33] Fix | Delete
$wrapper_attributes .= ' aria-label="' . $label_text . '"';
[34] Fix | Delete
}
[35] Fix | Delete
if ( $pagination_arrow ) {
[36] Fix | Delete
$label .= $pagination_arrow;
[37] Fix | Delete
}
[38] Fix | Delete
$content = '';
[39] Fix | Delete
[40] Fix | Delete
// Check if the pagination is for Query that inherits the global context.
[41] Fix | Delete
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
[42] Fix | Delete
$filter_link_attributes = static function () use ( $wrapper_attributes ) {
[43] Fix | Delete
return $wrapper_attributes;
[44] Fix | Delete
};
[45] Fix | Delete
add_filter( 'next_posts_link_attributes', $filter_link_attributes );
[46] Fix | Delete
// Take into account if we have set a bigger `max page`
[47] Fix | Delete
// than what the query has.
[48] Fix | Delete
global $wp_query;
[49] Fix | Delete
if ( $max_page > $wp_query->max_num_pages ) {
[50] Fix | Delete
$max_page = $wp_query->max_num_pages;
[51] Fix | Delete
}
[52] Fix | Delete
$content = get_next_posts_link( $label, $max_page );
[53] Fix | Delete
remove_filter( 'next_posts_link_attributes', $filter_link_attributes );
[54] Fix | Delete
} elseif ( ! $max_page || $max_page > $page ) {
[55] Fix | Delete
$custom_query = new WP_Query( build_query_vars_from_query_block( $block, $page ) );
[56] Fix | Delete
$custom_query_max_pages = (int) $custom_query->max_num_pages;
[57] Fix | Delete
if ( $custom_query_max_pages && $custom_query_max_pages !== $page ) {
[58] Fix | Delete
$content = sprintf(
[59] Fix | Delete
'<a href="%1$s" %2$s>%3$s</a>',
[60] Fix | Delete
esc_url( add_query_arg( $page_key, $page + 1 ) ),
[61] Fix | Delete
$wrapper_attributes,
[62] Fix | Delete
$label
[63] Fix | Delete
);
[64] Fix | Delete
}
[65] Fix | Delete
wp_reset_postdata(); // Restore original Post Data.
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
if ( $enhanced_pagination && isset( $content ) ) {
[69] Fix | Delete
$p = new WP_HTML_Tag_Processor( $content );
[70] Fix | Delete
if ( $p->next_tag(
[71] Fix | Delete
array(
[72] Fix | Delete
'tag_name' => 'a',
[73] Fix | Delete
'class_name' => 'wp-block-query-pagination-next',
[74] Fix | Delete
)
[75] Fix | Delete
) ) {
[76] Fix | Delete
$p->set_attribute( 'data-wp-key', 'query-pagination-next' );
[77] Fix | Delete
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
[78] Fix | Delete
$p->set_attribute( 'data-wp-on-async--mouseenter', 'core/query::actions.prefetch' );
[79] Fix | Delete
$p->set_attribute( 'data-wp-watch', 'core/query::callbacks.prefetch' );
[80] Fix | Delete
$content = $p->get_updated_html();
[81] Fix | Delete
}
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
return $content;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Registers the `core/query-pagination-next` block on the server.
[89] Fix | Delete
*
[90] Fix | Delete
* @since 5.8.0
[91] Fix | Delete
*/
[92] Fix | Delete
function register_block_core_query_pagination_next() {
[93] Fix | Delete
register_block_type_from_metadata(
[94] Fix | Delete
__DIR__ . '/query-pagination-next',
[95] Fix | Delete
array(
[96] Fix | Delete
'render_callback' => 'render_block_core_query_pagination_next',
[97] Fix | Delete
)
[98] Fix | Delete
);
[99] Fix | Delete
}
[100] Fix | Delete
add_action( 'init', 'register_block_core_query_pagination_next' );
[101] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function