--- 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 .= '<li>';
@@ -81,30 +92,27 @@
$post,
$attributes['featuredImageSizeSlug'],
array(
- 'style' => $image_style,
+ 'style' => esc_attr( $image_style ),
)
);
if ( $attributes['addLinkToFeaturedImage'] ) {
$featured_image = sprintf(
- '<a href="%1$s">%2$s</a>',
- $post_link,
+ '<a href="%1$s" aria-label="%2$s">%3$s</a>',
+ esc_url( $post_link ),
+ esc_attr( $title ),
$featured_image
);
}
$list_items_markup .= sprintf(
'<div class="%1$s">%2$s</div>',
- $image_classes,
+ esc_attr( $image_classes ),
$featured_image
);
}
- $title = get_the_title( $post );
- if ( ! $title ) {
- $title = __( '(no title)' );
- }
$list_items_markup .= sprintf(
- '<a href="%1$s">%2$s</a>',
- $post_link,
+ '<a class="wp-block-latest-posts__post-title" href="%1$s">%2$s</a>',
+ esc_url( $post_link ),
$title
);
@@ -117,7 +125,7 @@
if ( ! empty( $author_display_name ) ) {
$list_items_markup .= sprintf(
'<div class="wp-block-latest-posts__post-author">%1$s</div>',
- esc_html( $byline )
+ $byline
);
}
}
@@ -126,7 +134,7 @@
$list_items_markup .= sprintf(
'<time datetime="%1$s" class="wp-block-latest-posts__post-date">%2$s</time>',
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(
'<div class="wp-block-latest-posts__post-full-content">%1$s</div>',
- $post_content
+ wp_kses_post( $post_content )
);
}