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

    r37914 r38647  
    411411    }
    412412
     413    if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) {
     414        $userids = $_REQUEST['users'];
     415        $sendback = wp_get_referer();
     416
     417        /**
     418         * Fires when a custom bulk action should be handled.
     419         *
     420         * The sendback link should be modified with success or failure feedback
     421         * from the action to be used to display feedback to the user.
     422         *
     423         * @since 4.7.0
     424         *
     425         * @param string $sendback The redirect URL.
     426         * @param string $action   The action being taken.
     427         * @param array  $userids  The users to take the action on.
     428         */
     429        $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $wp_list_table->current_action(), $userids );
     430
     431        wp_safe_redirect( $sendback );
     432        exit;
     433    }
     434
    413435    $wp_list_table->prepare_items();
    414436    $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
Note: See TracChangeset for help on using the changeset viewer.