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

    r38325 r38647  
    357357            }
    358358            break;
     359
     360        default:
     361            if ( isset( $_POST['checked'] ) ) {
     362                check_admin_referer('bulk-plugins');
     363                $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
     364                $sendback = wp_get_referer();
     365
     366                /**
     367                 * Fires when a custom bulk action should be handled.
     368                 *
     369                 * The sendback link should be modified with success or failure feedback
     370                 * from the action to be used to display feedback to the user.
     371                 *
     372                 * @since 4.7.0
     373                 *
     374                 * @param string $sendback The redirect URL.
     375                 * @param string $action   The action being taken.
     376                 * @param array  $plugins  The plugins to take the action on.
     377                 */
     378                $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $action, $plugins );
     379
     380                wp_safe_redirect( $sendback );
     381                exit;
     382            }
     383            break;
    359384    }
     385
    360386}
    361387
Note: See TracChangeset for help on using the changeset viewer.