wp_untrash_post

Definition:
function wp_untrash_post($post_id = 0) {}

Restores a post or page from the Trash

Parameters

  • int $post_id: Post ID.

Return values

returns:False on failure

Defined actions

  • untrash_post
    do_action('untrash_post', $post_id);
  • untrashed_post
    do_action('untrashed_post', $post_id);

Source code

function wp_untrash_post($post_id = 0) {

	if ( !$post = wp_get_single_post($post_id, ARRAY_A) )

		return $post;



	if ( $post['post_status'] != 'trash' )

		return false;



	do_action('untrash_post', $post_id);



	$post_status = get_post_meta($post_id, '_wp_trash_meta_status', true);



	$post['post_status'] = $post_status;



	delete_post_meta($post_id, '_wp_trash_meta_status');

	delete_post_meta($post_id, '_wp_trash_meta_time');



	wp_insert_post($post);



	wp_untrash_post_comments($post_id);



	do_action('untrashed_post', $post_id);



	return $post;

}

4207

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: