Skip to content

Commit

Permalink
Post content: Don't print empty wrapper (WordPress#30961)
Browse files Browse the repository at this point in the history
* Post content: Don't print empty wrapper
Co-authored-by: Ari Stathopoulos <aristath@gmail.com>
  • Loading branch information
carolinan authored Apr 21, 2021
1 parent 3bc89cd commit c7306de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/block-library/src/post-content/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ function render_block_core_post_content( $attributes, $content, $block ) {
the_post();
}

$content = get_the_content( null, false, $block->context['postId'] );

if ( empty( $content ) ) {
return '';
}

$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'entry-content' ) );

return (
'<div ' . $wrapper_attributes . '>' .
apply_filters( 'the_content', str_replace( ']]>', ']]&gt;', get_the_content( null, false, $block->context['postId'] ) ) ) .
apply_filters( 'the_content', str_replace( ']]>', ']]&gt;', $content ) ) .
'</div>'
);
}
Expand Down

0 comments on commit c7306de

Please sign in to comment.