diff --git a/wp-includes/blocks/latest-posts.php b/wp-includes/blocks/latest-posts.php index b8fc02cf80..f1b3c78b5c 100644 --- a/wp-includes/blocks/latest-posts.php +++ b/wp-includes/blocks/latest-posts.php @@ -53,11 +53,16 @@ function render_block_core_latest_posts( $attributes ) { if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] && isset( $attributes['displayPostContentRadio'] ) && 'excerpt' === $attributes['displayPostContentRadio'] ) { $post_excerpt = $post->post_excerpt; + if ( ! ( $post_excerpt ) ) { $post_excerpt = $post->post_content; } $trimmed_excerpt = esc_html( wp_trim_words( $post_excerpt, $excerpt_length, ' … ' ) ); + if ( post_password_required( $post ) ) { + $trimmed_excerpt = __( 'This content is password protected.' ); + } + $list_items_markup .= sprintf( '
%1$s', $trimmed_excerpt @@ -78,9 +83,16 @@ function render_block_core_latest_posts( $attributes ) { if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] && isset( $attributes['displayPostContentRadio'] ) && 'full_post' === $attributes['displayPostContentRadio'] ) { + + $post_content = wp_kses_post( html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ) ); + + if ( post_password_required( $post ) ) { + $post_content = __( 'This content is password protected.' ); + } + $list_items_markup .= sprintf( '
%1$s
', - wp_kses_post( html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ) ) + $post_content ); }