Skip to content

Commit 3e03a8e

Browse files
committed
REST API: Prevent inaccessible attachments from being embedded in posts.
When an attachment is used by multiple posts, it could be included in `_embed` for a published post even if its `post_parent` is a draft. This commit avoids embedding attachments that are not viewable in this context. Props bor0. Fixes #64183. Built from https://develop.svn.wordpress.org/trunk@61996 git-svn-id: http://core.svn.wordpress.org/trunk@61278 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent a25478d commit 3e03a8e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2294,7 +2294,7 @@ protected function prepare_links( $post ) {
22942294

22952295
// If we have a featured media, add that.
22962296
$featured_media = get_post_thumbnail_id( $post->ID );
2297-
if ( $featured_media ) {
2297+
if ( $featured_media && ( 'publish' === get_post_status( $featured_media ) || current_user_can( 'read_post', $featured_media ) ) ) {
22982298
$image_url = rest_url( rest_get_route_for_post( $featured_media ) );
22992299

23002300
$links['https://api.w.org/featuredmedia'] = array(

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.0-beta5-61995';
19+
$wp_version = '7.0-beta5-61996';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)