Changeset 56065 for trunk/src/wp-includes/blocks/post-template.php
- Timestamp:
- 06/27/2023 02:20:18 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/blocks/post-template.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/post-template.php
r55246 r56065 73 73 } 74 74 75 // Ensure backwards compatibility by flagging the number of columns via classname when using grid layout. 76 if ( isset( $attributes['layout']['type'] ) && 'grid' === $attributes['layout']['type'] && ! empty( $attributes['layout']['columnCount'] ) ) { 77 $classnames .= ' ' . sanitize_title( 'columns-' . $attributes['layout']['columnCount'] ); 78 } 79 75 80 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classnames ) ) ); 76 81 … … 86 91 $block_instance['blockName'] = 'core/null'; 87 92 93 $post_id = get_the_ID(); 94 $post_type = get_post_type(); 95 $filter_block_context = static function( $context ) use ( $post_id, $post_type ) { 96 $context['postType'] = $post_type; 97 $context['postId'] = $post_id; 98 return $context; 99 }; 100 add_filter( 'render_block_context', $filter_block_context ); 88 101 // Render the inner blocks of the Post Template block with `dynamic` set to `false` to prevent calling 89 102 // `render_callback` and ensure that no wrapper markup is included. 90 $block_content = ( 91 new WP_Block( 92 $block_instance, 93 array( 94 'postType' => get_post_type(), 95 'postId' => get_the_ID(), 96 ) 97 ) 98 )->render( array( 'dynamic' => false ) ); 103 $block_content = ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) ); 104 remove_filter( 'render_block_context', $filter_block_context ); 99 105 100 106 // Wrap the render inner blocks in a `li` element with the appropriate post classes.
Note: See TracChangeset
for help on using the changeset viewer.