Allow custom bulk actions in admin list tables.

Bulk action filtering was introduced in 3.1, but only to remove default bulk actions, not add new ones.

Bulk actions can now be registered for all admin list table dropdowns via the `bulk_actions-{get_current_screen()->id}` filter. Handling custom bulk actions can be performed in the corresponding and newly introduced `handle_bulk_actions-${get_current_screen()->id}` filter.

Props scribu, flixos90, Veraxus.
See #16031.



git-svn-id: https://develop.svn.wordpress.org/trunk@38647 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Eric Andrew Lewis
2016-09-23 20:32:48 +00:00
parent 8bc6917cc3
commit c75fb5e9ca
13 changed files with 247 additions and 6 deletions

View File

@@ -162,6 +162,21 @@ if ( $doaction ) {
}
}
break;
default:
/**
* Fires when a custom bulk action should be handled.
*
* The sendback link should be modified with success or failure feedback
* from the action to be used to display feedback to the user.
*
* @since 4.7.0
*
* @param string $sendback The redirect URL.
* @param string $doaction The action being taken.
* @param array $post_ids The post IDs to take the action on.
*/
$sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $post_ids );
break;
}
$sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );