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/network/site-themes.php

    r38320 r38647  
    123123            }
    124124            break;
     125        default:
     126            if ( isset( $_POST['checked'] ) ) {
     127                check_admin_referer( 'bulk-themes' );
     128                $themes = (array) $_POST['checked'];
     129                $n = count( $themes );
     130                /**
     131                 * Fires when a custom bulk action should be handled.
     132                 *
     133                 * The redirect link should be modified with success or failure feedback
     134                 * from the action to be used to display feedback to the user.
     135                 *
     136                 * @since 4.7.0
     137                 *
     138                 * @param string $referer The redirect URL.
     139                 * @param string $action  The action being taken.
     140                 * @param array  $themes  The themes to take the action on.
     141                 * @param int    $site_id The current site id
     142                 */
     143                $referer = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes, $id );
     144            } else {
     145                $action = 'error';
     146                $n = 'none';
     147            }
    125148    }
    126149
Note: See TracChangeset for help on using the changeset viewer.