diff --git src/wp-includes/revision.php src/wp-includes/revision.php
index b588621..07a986c 100644
|
|
function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) { |
594 | 594 | return $value; |
595 | 595 | } |
596 | 596 | |
597 | | if ( empty( $_REQUEST['_thumbnail_id'] ) || $post->ID != $post_id || '_thumbnail_id' != $meta_key || 'revision' == $post->post_type ) { |
| 597 | if ( empty( $_REQUEST['_thumbnail_id'] ) || |
| 598 | empty( $_REQUEST['preview_id'] ) || |
| 599 | $post->ID != $post_id || |
| 600 | '_thumbnail_id' != $meta_key || |
| 601 | 'revision' == $post->post_type || |
| 602 | $post_id != $_REQUEST['preview_id'] |
| 603 | ) { |
598 | 604 | return $value; |
599 | 605 | } |
600 | 606 | |
diff --git tests/phpunit/tests/post/thumbnails.php tests/phpunit/tests/post/thumbnails.php
index 827a339..13cfbd6 100644
|
|
class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { |
242 | 242 | |
243 | 243 | $GLOBALS['post'] = self::$post; |
244 | 244 | $_REQUEST['_thumbnail_id'] = self::$attachment_id; |
| 245 | $_REQUEST['preview_id'] = self::$post->ID; |
245 | 246 | |
246 | 247 | $result = _wp_preview_post_thumbnail_filter( '', self::$post->ID, '_thumbnail_id' ); |
| 248 | |
| 249 | $GLOBALS['post'] = $old_post; |
| 250 | |
247 | 251 | $this->assertEquals( self::$attachment_id, $result ); |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * @ticket 37697 |
| 256 | */ |
| 257 | function test__wp_preview_post_thumbnail_filter_secondary_post() { |
| 258 | $old_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null; |
| 259 | |
| 260 | $secondary_post = self::factory()->post->create( array( |
| 261 | 'post_stauts' => 'publish', |
| 262 | ) |
| 263 | ); |
| 264 | |
| 265 | $GLOBALS['post'] = self::$post; |
| 266 | $_REQUEST['_thumbnail_id'] = self::$attachment_id; |
| 267 | $_REQUEST['preview_id'] = $secondary_post; |
| 268 | |
| 269 | $result = _wp_preview_post_thumbnail_filter( '', self::$post->ID, '_thumbnail_id' ); |
248 | 270 | |
249 | 271 | unset( $_REQUEST['_thumbnail_id'] ); |
250 | | if ( null === $old_post ) { |
251 | | unset( $GLOBALS['post'] ); |
252 | | } else { |
253 | | $GLOBALS['post'] = $old_post; |
254 | | } |
| 272 | $GLOBALS['post'] = $old_post; |
| 273 | |
| 274 | $this->assertEmpty( $result ); |
255 | 275 | } |
256 | 276 | |
257 | 277 | /** |