Make WordPress Core


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

    r37914 r38647  
    196196                        ), network_admin_url( 'themes.php' ) ) );
    197197                        exit;
     198                default:
     199                        $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
     200                        if ( empty( $themes ) ) {
     201                                wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
     202                                exit;
     203                        }
     204                        check_admin_referer( 'bulk-themes' );
     205
     206                        /**
     207                         * Fires when a custom bulk action should be handled.
     208                         *
     209                         * The redirect link should be modified with success or failure feedback
     210                         * from the action to be used to display feedback to the user.
     211                         *
     212                         * @since 4.7.0
     213                         *
     214                         * @param string $referer   The redirect URL.
     215                         * @param string $action    The action being taken.
     216                         * @param array  $themes    The themes to take the action on.
     217                         */
     218                        $referer = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes );
     219
     220                        wp_safe_redirect( $referer );
     221                        exit;
    198222        }
     223
    199224}
    200225
Note: See TracChangeset for help on using the changeset viewer.