Created
December 15, 2016 13:53
-
-
Save SirDarcanos/06246065be487e3c7085ce5d8615beef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handles the bulk action. | |
*/ | |
function my_bulk_action_handler( $redirect_to, $action, $post_ids ) { | |
if ( $action !== 'draft_posts' ) { | |
return $redirect_to; | |
} | |
foreach ( $post_ids as $post_id ) { | |
wp_update_post( array( | |
'ID' => $post_id, | |
'post_status' => 'draft', | |
) ); | |
} | |
$redirect_to = add_query_arg( 'bulk_draft_posts', count( $post_ids ), $redirect_to ); | |
return $redirect_to; | |
} | |
add_filter( 'handle_bulk_actions-edit-post', 'my_bulk_action_handler', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment