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/users.php

    r37914 r38647  
    9494                }
    9595
     96                if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) {
     97                    $sendback = wp_get_referer();
     98
     99                    $user_ids = (array) $_POST['allusers'];
     100                    /**
     101                     * Fires when a custom bulk action should be handled.
     102                     *
     103                     * The sendback link should be modified with success or failure feedback
     104                     * from the action to be used to display feedback to the user.
     105                     *
     106                     * @since 4.7.0
     107                     *
     108                     * @param string $sendback The redirect URL.
     109                     * @param string $doaction The action being taken.
     110                     * @param array  $user_ids The users to take the action on.
     111                     */
     112                    $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $user_ids );
     113
     114                    wp_safe_redirect( $sendback );
     115                    exit();
     116                }
     117
    96118                wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
    97119            } else {
Note: See TracChangeset for help on using the changeset viewer.