Post Thumbnails: Prevent post thumbnail previews from spilling into other images.

After [38118], when previewing a page with a secondary loop, all post
thumbnails would be filtered to display the post thumbnail for the
page being previewed. This ensures `_wp_preview_post_thumbnail_filter()`
is only applied if the `$post_id` of the post meta being filtered is
equal to the post or page being previewed.

Merge of [38433] to the 4.6 branch.

Props swissspidy, joemcgill.
Fixes #37697.

Built from https://develop.svn.wordpress.org/branches/4.6@38476


git-svn-id: http://core.svn.wordpress.org/branches/4.6@38417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2016-08-31 18:44:29 +00:00
parent b39313803a
commit 0d0310bcd6
2 changed files with 8 additions and 2 deletions

View File

@ -594,7 +594,13 @@ function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) {
return $value;
}
if ( empty( $_REQUEST['_thumbnail_id'] ) || $post->ID != $post_id || '_thumbnail_id' != $meta_key || 'revision' == $post->post_type ) {
if ( empty( $_REQUEST['_thumbnail_id'] ) ||
empty( $_REQUEST['preview_id'] ) ||
$post->ID != $post_id ||
'_thumbnail_id' != $meta_key ||
'revision' == $post->post_type ||
$post_id != $_REQUEST['preview_id']
) {
return $value;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6.1-alpha-38475';
$wp_version = '4.6.1-alpha-38476';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.