Trash status update, see #4529
git-svn-id: http://svn.automattic.com/wordpress/trunk@11750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
39e4f05a15
commit
dc37cd4ce4
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue