- Timestamp:
- 02/07/2025 03:44:07 PM (7 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/query-pagination-previous.php
r58387 r59775 20 20 $page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page'; 21 21 $enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination']; 22 $max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0; 22 23 $page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; 23 24 $wrapper_attributes = get_block_wrapper_attributes(); 25 $show_label = isset( $block->context['showLabel'] ) ? (bool) $block->context['showLabel'] : true; 26 $default_label = __( 'Previous Page' ); 27 $label_text = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? esc_html( $attributes['label'] ) : $default_label; 28 $label = $show_label ? $label_text : ''; 29 $pagination_arrow = get_query_pagination_arrow( $block, false ); 24 $wrapper_attributes = get_block_wrapper_attributes(); 25 $show_label = isset( $block->context['showLabel'] ) ? (bool) $block->context['showLabel'] : true; 26 $default_label = __( 'Previous Page' ); 27 $label_text = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? esc_html( $attributes['label'] ) : $default_label; 28 $label = $show_label ? $label_text : ''; 29 $pagination_arrow = get_query_pagination_arrow( $block, false ); 30 30 if ( ! $label ) { 31 31 $wrapper_attributes .= ' aria-label="' . $label_text . '"'; … … 45 45 $content = get_previous_posts_link( $label ); 46 46 remove_filter( 'previous_posts_link_attributes', $filter_link_attributes ); 47 } elseif ( 1 !== $page ) { 48 $content = sprintf( 49 '<a href="%1$s" %2$s>%3$s</a>', 50 esc_url( add_query_arg( $page_key, $page - 1 ) ), 51 $wrapper_attributes, 52 $label 53 ); 47 } else { 48 $block_query = new WP_Query( build_query_vars_from_query_block( $block, $page ) ); 49 $block_max_pages = $block_query->max_num_pages; 50 $total = ! $max_page || $max_page > $block_max_pages ? $block_max_pages : $max_page; 51 wp_reset_postdata(); 52 53 if ( 1 < $page && $page <= $total ) { 54 $content = sprintf( 55 '<a href="%1$s" %2$s>%3$s</a>', 56 esc_url( add_query_arg( $page_key, $page - 1 ) ), 57 $wrapper_attributes, 58 $label 59 ); 60 } 54 61 } 55 62
Note: See TracChangeset
for help on using the changeset viewer.