Make WordPress Core

Changeset 38647

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.

Location:
trunk/src/wp-admin
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-comments.php

    r37914 r38647  
    8181                break;
    8282        }
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
    8399    }
    84100
  • trunk/src/wp-admin/edit-tags.php

    r38629 r38647  
    196196        $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $location );
    197197    break;
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
    198218}
    199219
     
    211231     *
    212232     * @since 4.6.0
    213      * 
     233     *
    214234     * @param string $location The destination URL.
    215235     * @param object $tax      The taxonomy object.
  • trunk/src/wp-admin/edit.php

    r38076 r38647  
    162162                }
    163163            }
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
    164179            break;
    165180    }
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r38334 r38647  
    437437    protected function bulk_actions( $which = '' ) {
    438438        if ( is_null( $this->_actions ) ) {
    439             $no_new_actions = $this->_actions = $this->get_bulk_actions();
     439            $this->_actions = $this->get_bulk_actions();
    440440            /**
    441441             * Filters the list table Bulk Actions drop-down.
     
    451451             */
    452452            $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
    453             $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
    454453            $two = '';
    455454        } else {
  • trunk/src/wp-admin/link-manager.php

    r37914 r38647  
    2020    check_admin_referer( 'bulk-bookmarks' );
    2121
     22
     23
     24
    2225    if ( 'delete' == $doaction ) {
    23         $bulklinks = (array) $_REQUEST['linkcheck'];
    2426        foreach ( $bulklinks as $link_id ) {
    2527            $link_id = (int) $link_id;
     
    2830        }
    2931
    30         wp_redirect( add_query_arg('deleted', count( $bulklinks ), admin_url( 'link-manager.php' ) ) );
    31         exit;
     32        $redirect_to = add_query_arg( 'deleted', count( $bulklinks ), $redirect_to );
     33    } else {
     34        /**
     35         * Fires when a custom bulk action should be handled.
     36         *
     37         * The redirect link should be modified with success or failure feedback
     38         * from the action to be used to display feedback to the user.
     39         *
     40         * @since 4.7.0
     41         *
     42         * @param string $redirect_to The redirect URL.
     43         * @param string $doaction    The action being taken.
     44         * @param array  $bulklinks   The links to take the action on.
     45         */
     46        $redirect_to = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $bulklinks );
    3247    }
     48
     49
    3350} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
    3451     wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
  • trunk/src/wp-admin/network/site-themes.php

    r38320 r38647  
    123123            }
    124124            break;
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
    125148    }
    126149
  • trunk/src/wp-admin/network/site-users.php

    r38320 r38647  
    165165            }
    166166            break;
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
    167189    }
    168190
  • trunk/src/wp-admin/network/sites.php

    r38305 r38647  
    161161                    }
    162162                }
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
    163183            } else {
    164184                $location = network_admin_url( 'sites.php' );
  • trunk/src/wp-admin/network/themes.php

    r37914 r38647  
    196196            ), network_admin_url( 'themes.php' ) ) );
    197197            exit;
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
    198222    }
     223
    199224}
    200225
  • trunk/src/wp-admin/network/users.php

    r37914 r38647  
    9494                }
    9595
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
    96118                wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
    97119            } else {
  • trunk/src/wp-admin/plugins.php

    r38325 r38647  
    357357            }
    358358            break;
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
    359384    }
     385
    360386}
    361387
  • trunk/src/wp-admin/upload.php

    r37958 r38647  
    164164            $location = add_query_arg( 'deleted', count( $post_ids ), $location );
    165165            break;
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
    166180    }
    167181
  • trunk/src/wp-admin/users.php

    r37914 r38647  
    411411    }
    412412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     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.