diff -r be944660c56a -r 3d72ae0968f4 wp/wp-includes/blocks/latest-posts.php --- a/wp/wp-includes/blocks/latest-posts.php Wed Sep 21 18:19:35 2022 +0200 +++ b/wp/wp-includes/blocks/latest-posts.php Tue Sep 27 16:37:53 2022 +0200 @@ -37,11 +37,12 @@ global $post, $block_core_latest_posts_excerpt_length; $args = array( - 'posts_per_page' => $attributes['postsToShow'], - 'post_status' => 'publish', - 'order' => $attributes['order'], - 'orderby' => $attributes['orderBy'], - 'suppress_filters' => false, + 'posts_per_page' => $attributes['postsToShow'], + 'post_status' => 'publish', + 'order' => $attributes['order'], + 'orderby' => $attributes['orderBy'], + 'ignore_sticky_posts' => true, + 'no_found_rows' => true, ); $block_core_latest_posts_excerpt_length = $attributes['excerptLength']; @@ -54,12 +55,22 @@ $args['author'] = $attributes['selectedAuthor']; } - $recent_posts = get_posts( $args ); + $query = new WP_Query; + $recent_posts = $query->query( $args ); + + if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) { + update_post_thumbnail_cache( $query ); + } $list_items_markup = ''; foreach ( $recent_posts as $post ) { $post_link = esc_url( get_permalink( $post ) ); + $title = get_the_title( $post ); + + if ( ! $title ) { + $title = __( '(no title)' ); + } $list_items_markup .= '
  • '; @@ -81,30 +92,27 @@ $post, $attributes['featuredImageSizeSlug'], array( - 'style' => $image_style, + 'style' => esc_attr( $image_style ), ) ); if ( $attributes['addLinkToFeaturedImage'] ) { $featured_image = sprintf( - '%2$s', - $post_link, + '%3$s', + esc_url( $post_link ), + esc_attr( $title ), $featured_image ); } $list_items_markup .= sprintf( '
    %2$s
    ', - $image_classes, + esc_attr( $image_classes ), $featured_image ); } - $title = get_the_title( $post ); - if ( ! $title ) { - $title = __( '(no title)' ); - } $list_items_markup .= sprintf( - '%2$s', - $post_link, + '%2$s', + esc_url( $post_link ), $title ); @@ -117,7 +125,7 @@ if ( ! empty( $author_display_name ) ) { $list_items_markup .= sprintf( '
    %1$s
    ', - esc_html( $byline ) + $byline ); } } @@ -126,7 +134,7 @@ $list_items_markup .= sprintf( '', esc_attr( get_the_date( 'c', $post ) ), - esc_html( get_the_date( '', $post ) ) + get_the_date( '', $post ) ); } @@ -148,7 +156,7 @@ 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' ) ) ); + $post_content = html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ); if ( post_password_required( $post ) ) { $post_content = __( 'This content is password protected.' ); @@ -156,7 +164,7 @@ $list_items_markup .= sprintf( '
    %1$s
    ', - $post_content + wp_kses_post( $post_content ) ); }