_set_preview

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

Description

(WP_Post|false) _set_preview( (WP_Post) $post ); 

Returns (WP_Post|false)

Parameters (1)

0. $post (WP_Post)
The post.

Usage

  1. if ( !function_exists( '_set_preview' ) ) { 
  2. require_once ABSPATH . WPINC . '/revision.php'; 
  3.  
  4. // The post. 
  5. $post = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _set_preview($post); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/revision.php  
  1. function _set_preview( $post ) { 
  2. if ( ! is_object( $post ) ) { 
  3. return $post; 
  4.  
  5. $preview = wp_get_post_autosave( $post->ID ); 
  6. if ( ! is_object( $preview ) ) { 
  7. return $post; 
  8.  
  9. $preview = sanitize_post( $preview ); 
  10.  
  11. $post->post_content = $preview->post_content; 
  12. $post->post_title = $preview->post_title; 
  13. $post->post_excerpt = $preview->post_excerpt; 
  14.  
  15.  
  16. return $post;