_set_preview() – Sets up the post object for preview based on the post autosave.

You appear to be a bot. Output may be restricted

Description

Sets up the post object for preview based on the post autosave.

Usage

$WP_Post|false = _set_preview( $post );

Parameters

$post
( WP_Post ) required

Returns

WP_Post|false

Source

File name: wordpress/wp-includes/revision.php
Lines:

1 to 20 of 20
function _set_preview( $post ) {
  if ( ! is_object( $post ) ) {
    return $post;
  }

  $preview = wp_get_post_autosave( $post->ID );

  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;
  }

  add_filter( 'get_the_terms', '_wp_preview_terms_filter',  < 10, 3 );
  add_filter( 'get_post_metadata', '_wp_preview_post_thumbnail_filter',  < 10, 3 );

  return $post;
}
 

 View on GitHub View on Trac