Make WordPress Core


Ignore:
Timestamp:
09/23/2016 08:32:48 PM (8 years ago)
Author:
ericlewis
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/site-users.php

    r38320 r38647  
    165165            }
    166166            break;
     167        default:
     168            if ( ! isset( $_REQUEST['users'] ) ) {
     169                break;
     170            }
     171            check_admin_referer( 'bulk-users' );
     172            $userids = $_REQUEST['users'];
     173            /**
     174             * Fires when a custom bulk action should be handled.
     175             *
     176             * The redirect link should be modified with success or failure feedback
     177             * from the action to be used to display feedback to the user.
     178             *
     179             * @since 4.7.0
     180             *
     181             * @param string $referer The redirect URL.
     182             * @param string $action  The action being taken.
     183             * @param array  $userids The users to take the action on.
     184             * @param int    $id      The id of the current site
     185             */
     186            $referer = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $referer, $action, $userids, $id );
     187            $update = $action;
     188            break;
    167189    }
    168190
Note: See TracChangeset for help on using the changeset viewer.