Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: query-pagination-previous.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/query-pagination-previous` 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-previous` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 5.8.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 previous posts link for the query.
[16] Fix | Delete
*/
[17] Fix | Delete
function render_block_core_query_pagination_previous( $attributes, $content, $block ) {
[18] Fix | Delete
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
[19] Fix | Delete
$enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination'];
[20] Fix | Delete
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
[21] Fix | Delete
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
[22] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes();
[23] Fix | Delete
$show_label = isset( $block->context['showLabel'] ) ? (bool) $block->context['showLabel'] : true;
[24] Fix | Delete
$default_label = __( 'Previous Page' );
[25] Fix | Delete
$label_text = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? esc_html( $attributes['label'] ) : $default_label;
[26] Fix | Delete
$label = $show_label ? $label_text : '';
[27] Fix | Delete
$pagination_arrow = get_query_pagination_arrow( $block, false );
[28] Fix | Delete
if ( ! $label ) {
[29] Fix | Delete
$wrapper_attributes .= ' aria-label="' . $label_text . '"';
[30] Fix | Delete
}
[31] Fix | Delete
if ( $pagination_arrow ) {
[32] Fix | Delete
$label = $pagination_arrow . $label;
[33] Fix | Delete
}
[34] Fix | Delete
$content = '';
[35] Fix | Delete
// Check if the pagination is for Query that inherits the global context
[36] Fix | Delete
// and handle appropriately.
[37] Fix | Delete
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
[38] Fix | Delete
$filter_link_attributes = static function () use ( $wrapper_attributes ) {
[39] Fix | Delete
return $wrapper_attributes;
[40] Fix | Delete
};
[41] Fix | Delete
[42] Fix | Delete
add_filter( 'previous_posts_link_attributes', $filter_link_attributes );
[43] Fix | Delete
$content = get_previous_posts_link( $label );
[44] Fix | Delete
remove_filter( 'previous_posts_link_attributes', $filter_link_attributes );
[45] Fix | Delete
} else {
[46] Fix | Delete
$block_query = new WP_Query( build_query_vars_from_query_block( $block, $page ) );
[47] Fix | Delete
$block_max_pages = $block_query->max_num_pages;
[48] Fix | Delete
$total = ! $max_page || $max_page > $block_max_pages ? $block_max_pages : $max_page;
[49] Fix | Delete
wp_reset_postdata();
[50] Fix | Delete
[51] Fix | Delete
if ( 1 < $page && $page <= $total ) {
[52] Fix | Delete
$content = sprintf(
[53] Fix | Delete
'<a href="%1$s" %2$s>%3$s</a>',
[54] Fix | Delete
esc_url( add_query_arg( $page_key, $page - 1 ) ),
[55] Fix | Delete
$wrapper_attributes,
[56] Fix | Delete
$label
[57] Fix | Delete
);
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
if ( $enhanced_pagination && isset( $content ) ) {
[62] Fix | Delete
$p = new WP_HTML_Tag_Processor( $content );
[63] Fix | Delete
if ( $p->next_tag(
[64] Fix | Delete
array(
[65] Fix | Delete
'tag_name' => 'a',
[66] Fix | Delete
'class_name' => 'wp-block-query-pagination-previous',
[67] Fix | Delete
)
[68] Fix | Delete
) ) {
[69] Fix | Delete
$p->set_attribute( 'data-wp-key', 'query-pagination-previous' );
[70] Fix | Delete
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
[71] Fix | Delete
$p->set_attribute( 'data-wp-on-async--mouseenter', 'core/query::actions.prefetch' );
[72] Fix | Delete
$p->set_attribute( 'data-wp-watch', 'core/query::callbacks.prefetch' );
[73] Fix | Delete
$content = $p->get_updated_html();
[74] Fix | Delete
}
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
return $content;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Registers the `core/query-pagination-previous` block on the server.
[82] Fix | Delete
*
[83] Fix | Delete
* @since 5.8.0
[84] Fix | Delete
*/
[85] Fix | Delete
function register_block_core_query_pagination_previous() {
[86] Fix | Delete
register_block_type_from_metadata(
[87] Fix | Delete
__DIR__ . '/query-pagination-previous',
[88] Fix | Delete
array(
[89] Fix | Delete
'render_callback' => 'render_block_core_query_pagination_previous',
[90] Fix | Delete
)
[91] Fix | Delete
);
[92] Fix | Delete
}
[93] Fix | Delete
add_action( 'init', 'register_block_core_query_pagination_previous' );
[94] Fix | Delete
[95] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function