Changeset 56710 for trunk/src/wp-includes/blocks/post-template.php
- Timestamp:
- 09/26/2023 02:20:18 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/blocks/post-template.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/post-template.php
r56298 r56710 44 44 */ 45 45 function render_block_core_post_template( $attributes, $content, $block ) { 46 $page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page'; 47 $page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; 46 $page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page'; 47 $enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination']; 48 $page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; 48 49 49 50 // Use global query if needed. … … 51 52 if ( $use_global_query ) { 52 53 global $wp_query; 53 $query = clone $wp_query; 54 55 /* 56 * If already in the main query loop, duplicate the query instance to not tamper with the main instance. 57 * Since this is a nested query, it should start at the beginning, therefore rewind posts. 58 * Otherwise, the main query loop has not started yet and this block is responsible for doing so. 59 */ 60 if ( in_the_loop() ) { 61 $query = clone $wp_query; 62 $query->rewind_posts(); 63 } else { 64 $query = $wp_query; 65 } 54 66 } else { 55 67 $query_args = build_query_vars_from_query_block( $block, $page ); … … 95 107 $post_id = get_the_ID(); 96 108 $post_type = get_post_type(); 97 $filter_block_context = static function ( $context ) use ( $post_id, $post_type ) {109 $filter_block_context = static function ( $context ) use ( $post_id, $post_type ) { 98 110 $context['postType'] = $post_type; 99 111 $context['postId'] = $post_id; … … 110 122 // Wrap the render inner blocks in a `li` element with the appropriate post classes. 111 123 $post_classes = implode( ' ', get_post_class( 'wp-block-post' ) ); 112 $content .= '<li class="' . esc_attr( $post_classes ) . '">' . $block_content . '</li>'; 124 125 $inner_block_directives = $enhanced_pagination ? ' data-wp-key="post-template-item-' . $post_id . '"' : ''; 126 127 $content .= '<li' . $inner_block_directives . ' class="' . esc_attr( $post_classes ) . '">' . $block_content . '</li>'; 113 128 } 114 129
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)