[wp-trac] [WordPress Trac] #23022: Always set posts to draft status when untrashing
WordPress Trac
noreply at wordpress.org
Thu Nov 2 12:06:04 UTC 2017
#23022: Always set posts to draft status when untrashing
-------------------------------------------------+-------------------------
Reporter: harrym | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future
Component: Posts, Post Types | Release
Severity: normal | Version: 2.9
Keywords: editorial-flow good-first-bug has- | Resolution:
patch | Focuses:
| administration
-------------------------------------------------+-------------------------
Comment (by pankajmohale):
Replying to [ticket:23022 harrym]:
> In some situations it is bad when trashed posts immediately go live
after being untrashed. Such as:
>
> * A published post is found to have libellous/wrong/other_bad content in
it
> * Admin trashes the post
> * Admin wants to edit the post and republish it without the bad things
> * Admin cannot do this without republishing the bad things, which they
cannot do.
>
> I appreciate that the user should have unpublished the post rather than
trashing it but people don't always think clearly in these situations, and
once you're in it, you can't get out -- your options are to republish,
permanently delete, or leave the post in limbo.
>
> I did wonder if it would be better to make trashed posts
viewable/editable in the admin but that felt like a pretty big move, and
one that would make the status of a trashed post much less clear and
rather ambiguous.
>
> So, the attached patch sets all untrashed posts to draft status, rather
than restoring their original status, which was the only other thing I
could think of.
>
> (Definitely happy to debate alternative solutions)
{{{#!php
<?php
// define the untrash_post callback
function 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( wp_slash( $post ) );
wp_untrash_post_comments($post_id);
};
// add the action
add_action( 'untrash_post', 'action_untrash_post', 10, 1 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/23022#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list