Save draft or manually autosave for showing preview.

Signature

post_preview()

Return

(str) URL to redirect to show the preview

Source

function post_preview() {

	$post_ID = (int) $_POST['post_ID'];
	$_POST['ID'] = $post_ID;

	if ( ! $post = get_post( $post_ID ) ) {
		wp_die( __( 'You are not allowed to edit this post.' ) );
	}

	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
		wp_die( __( 'You are not allowed to edit this post.' ) );
	}

	$is_autosave = false;

	if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) {
		$saved_post_id = edit_post();
	} else {
		$is_autosave = true;

24 more lines...
WP Trac GitHub

Link here