From dc37cd4ce469d50786620fb155d9ab3aaf40b518 Mon Sep 17 00:00:00 2001 From: azaozz Date: Thu, 30 Jul 2009 14:55:07 +0000 Subject: [PATCH] Trash status update, see #4529 git-svn-id: http://svn.automattic.com/wordpress/trunk@11750 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 8 ++++---- wp-includes/post.php | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 96c211f6f..3a8528ca1 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3352,18 +3352,18 @@ function wp_scheduled_delete() { $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); - foreach ( $trash_meta['comments'] as $id => $meta ) { + foreach ( (array) $trash_meta['comments'] as $id => $meta ) { if ( $meta['time'] < $delete_timestamp ) { wp_delete_comment($id); unset($trash_meta['comments'][$id]); } } - foreach ( $trash_meta['posts'] as $id => $meta ) { + foreach ( (array) $trash_meta['posts'] as $id => $meta ) { if ( $meta['time'] < $delete_timestamp ) { wp_delete_post($id); - unset($to_delete['posts'][$id]); + unset($trash_meta['posts'][$id]); } } - update_option('wp_scheduled_delete', $to_delete); + update_option('wp_trash_meta', $trash_meta); } diff --git a/wp-includes/post.php b/wp-includes/post.php index b67711559..0d87cb132 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1249,7 +1249,7 @@ function wp_trash_post($postid = 0) { } /** - * Removes a post or page from the Trash + * Restores a post or page from the Trash * * @since 2.9.0 * @uses do_action() on 'untrash_post' before undeletion @@ -1259,22 +1259,22 @@ function wp_trash_post($postid = 0) { * @return mixed False on failure */ function wp_untrash_post($postid = 0) { - if (!$post = wp_get_single_post($postid, ARRAY_A)) + if ( !$post = wp_get_single_post($postid, ARRAY_A) ) return $post; do_action('untrash_post', $postid); - + $post['post_status'] = 'draft'; - + $trash_meta = get_option('wp_trash_meta'); - if (is_array($trash_meta) && isset($trash_meta['posts'][$postid])) { + if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) { $post['post_status'] = $trash_meta['posts'][$postid]['status']; unset($trash_meta['posts'][$postid]); update_option('wp_trash_meta', $trash_meta); } - + wp_insert_post($post); - + do_action('untrashed_post', $postid); return $post; @@ -2662,7 +2662,7 @@ function wp_delete_attachment($postid) { if ( 'attachment' != $post->post_type ) return false; - + if ( 'trash' != $post->post_status ) return wp_trash_post($postid);