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

@@ -436,7 +436,7 @@ class WP_List_Table {
*/
protected function bulk_actions( $which = '' ) {
if ( is_null( $this->_actions ) ) {
$no_new_actions = $this->_actions = $this->get_bulk_actions();
$this->_actions = $this->get_bulk_actions();
/**
* Filters the list table Bulk Actions drop-down.
*
@@ -450,7 +450,6 @@ class WP_List_Table {
* @param array $actions An array of the available bulk actions.
*/
$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
$two = '';
} else {
$two = '2';