mirror of
git://develop.git.wordpress.org/
synced 2025-03-22 04:49:49 +01:00
Revisions: Improve _set_preview
for case when autosave is missing.
This change fixes an issue where autosaves are deleted when a new autosave is sent with the same data. In the block editor, this causes the preview data to be missing on post previews. The end result of this is that if one set a preview image using a block theme on a published post and preview it, the featured image is not displayed correctly. Skipping deleting the previous autosave fixes the issue. Props adamsilverstein, walbo, audrasjb, Mamaduka, hellofromTonya. Fixes #54708. git-svn-id: https://develop.svn.wordpress.org/trunk@52433 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
12621e0228
commit
568bef0985
@ -638,16 +638,15 @@ function _set_preview( $post ) {
|
||||
}
|
||||
|
||||
$preview = wp_get_post_autosave( $post->ID );
|
||||
if ( ! is_object( $preview ) ) {
|
||||
return $post;
|
||||
|
||||
if ( is_object( $preview ) ) {
|
||||
$preview = sanitize_post( $preview );
|
||||
|
||||
$post->post_content = $preview->post_content;
|
||||
$post->post_title = $preview->post_title;
|
||||
$post->post_excerpt = $preview->post_excerpt;
|
||||
}
|
||||
|
||||
$preview = sanitize_post( $preview );
|
||||
|
||||
$post->post_content = $preview->post_content;
|
||||
$post->post_title = $preview->post_title;
|
||||
$post->post_excerpt = $preview->post_excerpt;
|
||||
|
||||
add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 );
|
||||
add_filter( 'get_post_metadata', '_wp_preview_post_thumbnail_filter', 10, 3 );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user