diff -r 34716fd837a4 -r be944660c56a wp/wp-includes/blocks/latest-posts.php --- a/wp/wp-includes/blocks/latest-posts.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-includes/blocks/latest-posts.php Wed Sep 21 18:19:35 2022 +0200 @@ -11,6 +11,7 @@ * * @var int */ +global $block_core_latest_posts_excerpt_length; $block_core_latest_posts_excerpt_length = 0; /** @@ -58,6 +59,7 @@ $list_items_markup = ''; foreach ( $recent_posts as $post ) { + $post_link = esc_url( get_permalink( $post ) ); $list_items_markup .= '
  • '; @@ -75,16 +77,24 @@ $image_classes .= ' align' . $attributes['featuredImageAlign']; } + $featured_image = get_the_post_thumbnail( + $post, + $attributes['featuredImageSizeSlug'], + array( + 'style' => $image_style, + ) + ); + if ( $attributes['addLinkToFeaturedImage'] ) { + $featured_image = sprintf( + '%2$s', + $post_link, + $featured_image + ); + } $list_items_markup .= sprintf( '
    %2$s
    ', $image_classes, - get_the_post_thumbnail( - $post, - $attributes['featuredImageSizeSlug'], - array( - 'style' => $image_style, - ) - ) + $featured_image ); } @@ -94,7 +104,7 @@ } $list_items_markup .= sprintf( '%2$s', - esc_url( get_permalink( $post ) ), + $post_link, $title ); @@ -125,6 +135,10 @@ $trimmed_excerpt = get_the_excerpt( $post ); + if ( post_password_required( $post ) ) { + $trimmed_excerpt = __( 'This content is password protected.' ); + } + $list_items_markup .= sprintf( '
    %1$s
    ', $trimmed_excerpt @@ -133,9 +147,16 @@ 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 ); } @@ -144,10 +165,7 @@ remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 ); - $class = 'wp-block-latest-posts wp-block-latest-posts__list'; - if ( isset( $attributes['align'] ) ) { - $class .= ' align' . $attributes['align']; - } + $class = 'wp-block-latest-posts__list'; if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) { $class .= ' is-grid'; @@ -165,13 +183,11 @@ $class .= ' has-author'; } - if ( isset( $attributes['className'] ) ) { - $class .= ' ' . $attributes['className']; - } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) ); return sprintf( - '', - esc_attr( $class ), + '', + $wrapper_attributes, $list_items_markup ); }