- Timestamp:
- 09/26/2023 02:20:18 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/query-pagination-numbers.php
r52042 r56710 16 16 */ 17 17 function render_block_core_query_pagination_numbers( $attributes, $content, $block ) { 18 $page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page'; 19 $page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; 20 $max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0; 18 $page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page'; 19 $enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination']; 20 $page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; 21 $max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0; 21 22 22 23 $wrapper_attributes = get_block_wrapper_attributes(); 23 24 $content = ''; 24 25 global $wp_query; 26 $mid_size = isset( $block->attributes['midSize'] ) ? (int) $block->attributes['midSize'] : null; 25 27 if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) { 26 28 // Take into account if we have set a bigger `max page` … … 31 33 'total' => $total, 32 34 ); 33 $content = paginate_links( $paginate_args ); 35 if ( null !== $mid_size ) { 36 $paginate_args['mid_size'] = $mid_size; 37 } 38 $content = paginate_links( $paginate_args ); 34 39 } else { 35 40 $block_query = new WP_Query( build_query_vars_from_query_block( $block, $page ) ); … … 46 51 'prev_next' => false, 47 52 ); 53 if ( null !== $mid_size ) { 54 $paginate_args['mid_size'] = $mid_size; 55 } 48 56 if ( 1 !== $page ) { 49 57 /** … … 78 86 $wp_query = $prev_wp_query; 79 87 } 88 80 89 if ( empty( $content ) ) { 81 90 return ''; 82 91 } 92 93 if ( $enhanced_pagination ) { 94 $p = new WP_HTML_Tag_Processor( $content ); 95 while ( $p->next_tag( 96 array( 97 'tag_name' => 'a', 98 'class_name' => 'page-numbers', 99 ) 100 ) ) { 101 $p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' ); 102 } 103 $content = $p->get_updated_html(); 104 } 105 83 106 return sprintf( 84 107 '<div %1$s>%2$s</div>',
Note: See TracChangeset
for help on using the changeset viewer.