WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/23/2016 08:32:48 PM (3 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/edit-tags.php

    r38629 r38647  
    196196        $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $location );
    197197    break;
     198default:
     199    if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) {
     200        break;
     201    }
     202    check_admin_referer( 'bulk-tags' );
     203    $tags = (array) $_REQUEST['delete_tags'];
     204    /**
     205     * Fires when a custom bulk action should be handled.
     206     *
     207     * The sendback link should be modified with success or failure feedback
     208     * from the action to be used to display feedback to the user.
     209     *
     210     * @since 4.7.0
     211     *
     212     * @param string $location The redirect URL.
     213     * @param string $action   The action being taken.
     214     * @param array  $tags     The tag IDs to take the action on.
     215     */
     216    $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags );
     217    break;
    198218}
    199219
     
    211231     *
    212232     * @since 4.6.0
    213      * 
     233     *
    214234     * @param string $location The destination URL.
    215235     * @param object $tax      The taxonomy object.
Note: See TracChangeset for help on using the changeset viewer.