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

February 12, 2011 


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