CARVIEW |
Select Language
HTTP/2 200
server: nginx
date: Tue, 07 Oct 2025 09:22:32 GMT
content-type: text/html;charset=utf-8
vary: Accept-Encoding
etag: W/"anonymous/Fri, 23 Sep 2016 20:32:48 GMT/047cf52280db9b82d6379e6cf389dcca"
cache-control: must-revalidate
alt-svc: h3=":443"; ma=86400
x-nc: MISS
content-encoding: gzip
Changeset 38647 – WordPress Trac
Changeset 38647
- Timestamp:
- 09/23/2016 08:32:48 PM (9 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 introducedhandle_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 81 81 break; 82 82 } 83 } 84 85 if ( ! in_array( $doaction, array( 'approve', 'unapprove', 'spam', 'unspam', 'trash', 'delete' ), true ) ) { 86 /** 87 * Fires when a custom bulk action should be handled. 88 * 89 * The redirect link should be modified with success or failure feedback 90 * from the action to be used to display feedback to the user. 91 * 92 * @since 4.7.0 93 * 94 * @param string $redirect_to The redirect URL. 95 * @param string $doaction The action being taken. 96 * @param array $comment_ids The comments to take the action on. 97 */ 98 $redirect_to = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $comment_ids ); 83 99 } 84 100 -
trunk/src/wp-admin/edit-tags.php
r38629 r38647 196 196 $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $location ); 197 197 break; 198 default: 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; 198 218 } 199 219 … … 211 231 * 212 232 * @since 4.6.0 213 * 233 * 214 234 * @param string $location The destination URL. 215 235 * @param object $tax The taxonomy object. -
trunk/src/wp-admin/edit.php
r38076 r38647 162 162 } 163 163 } 164 break; 165 default: 166 /** 167 * Fires when a custom bulk action should be handled. 168 * 169 * The sendback link should be modified with success or failure feedback 170 * from the action to be used to display feedback to the user. 171 * 172 * @since 4.7.0 173 * 174 * @param string $sendback The redirect URL. 175 * @param string $doaction The action being taken. 176 * @param array $post_ids The post IDs to take the action on. 177 */ 178 $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $post_ids ); 164 179 break; 165 180 } -
trunk/src/wp-admin/includes/class-wp-list-table.php
r38334 r38647 437 437 protected function bulk_actions( $which = '' ) { 438 438 if ( is_null( $this->_actions ) ) { 439 $ no_new_actions = $this->_actions = $this->get_bulk_actions();439 $this->_actions = $this->get_bulk_actions(); 440 440 /** 441 441 * Filters the list table Bulk Actions drop-down. … … 451 451 */ 452 452 $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); 453 $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );454 453 $two = ''; 455 454 } else { -
trunk/src/wp-admin/link-manager.php
r37914 r38647 20 20 check_admin_referer( 'bulk-bookmarks' ); 21 21 22 $redirect_to = admin_url( 'link-manager.php' ); 23 $bulklinks = (array) $_REQUEST['linkcheck']; 24 22 25 if ( 'delete' == $doaction ) { 23 $bulklinks = (array) $_REQUEST['linkcheck'];24 26 foreach ( $bulklinks as $link_id ) { 25 27 $link_id = (int) $link_id; … … 28 30 } 29 31 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 ); 32 47 } 48 wp_redirect( $redirect_to ); 49 exit; 33 50 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { 34 51 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 123 123 } 124 124 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 } 125 148 } 126 149 -
trunk/src/wp-admin/network/site-users.php
r38320 r38647 165 165 } 166 166 break; 167 default: 168 if ( ! isset( $_REQUEST['users'] ) ) { 169 break; 170 } 171 check_admin_referer( 'bulk-users' ); 172 $userids = $_REQUEST['users']; 173 /** 174 * Fires when a custom bulk action should be handled. 175 * 176 * The redirect link should be modified with success or failure feedback 177 * from the action to be used to display feedback to the user. 178 * 179 * @since 4.7.0 180 * 181 * @param string $referer The redirect URL. 182 * @param string $action The action being taken. 183 * @param array $userids The users to take the action on. 184 * @param int $id The id of the current site 185 */ 186 $referer = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $referer, $action, $userids, $id ); 187 $update = $action; 188 break; 167 189 } 168 190 -
trunk/src/wp-admin/network/sites.php
r38305 r38647 161 161 } 162 162 } 163 if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) { 164 $redirect_to = wp_get_referer(); 165 $blogs = (array) $_POST['allblogs']; 166 /** 167 * Fires when a custom bulk action should be handled. 168 * 169 * The redirect link should be modified with success or failure feedback 170 * from the action to be used to display feedback to the user. 171 * 172 * @since 4.7.0 173 * 174 * @param string $redirect_to The redirect URL. 175 * @param string $doaction The action being taken. 176 * @param array $blogs The blogs to take the action on. 177 * @param int $site_id The current site id. 178 */ 179 $redirect_to = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $blogs, $id ); 180 wp_safe_redirect( $redirect_to ); 181 exit(); 182 } 163 183 } else { 164 184 $location = network_admin_url( 'sites.php' ); -
trunk/src/wp-admin/network/themes.php
r37914 r38647 196 196 ), network_admin_url( 'themes.php' ) ) ); 197 197 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; 198 222 } 223 199 224 } 200 225 -
trunk/src/wp-admin/network/users.php
r37914 r38647 94 94 } 95 95 96 if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) { 97 $sendback = wp_get_referer(); 98 99 $user_ids = (array) $_POST['allusers']; 100 /** 101 * Fires when a custom bulk action should be handled. 102 * 103 * The sendback link should be modified with success or failure feedback 104 * from the action to be used to display feedback to the user. 105 * 106 * @since 4.7.0 107 * 108 * @param string $sendback The redirect URL. 109 * @param string $doaction The action being taken. 110 * @param array $user_ids The users to take the action on. 111 */ 112 $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $user_ids ); 113 114 wp_safe_redirect( $sendback ); 115 exit(); 116 } 117 96 118 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) ); 97 119 } else { -
trunk/src/wp-admin/plugins.php
r38325 r38647 357 357 } 358 358 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; 359 384 } 385 360 386 } 361 387 -
trunk/src/wp-admin/upload.php
r37958 r38647 164 164 $location = add_query_arg( 'deleted', count( $post_ids ), $location ); 165 165 break; 166 default: 167 /** 168 * Fires when a custom bulk action should be handled. 169 * 170 * The redirect link should be modified with success or failure feedback 171 * from the action to be used to display feedback to the user. 172 * 173 * @since 4.7.0 174 * 175 * @param string $location The redirect URL. 176 * @param string $doaction The action being taken. 177 * @param array $post_ids The posts to take the action on. 178 */ 179 $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $doaction, $post_ids ); 166 180 } 167 181 -
trunk/src/wp-admin/users.php
r37914 r38647 411 411 } 412 412 413 if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) { 414 $userids = $_REQUEST['users']; 415 $sendback = wp_get_referer(); 416 417 /** 418 * Fires when a custom bulk action should be handled. 419 * 420 * The sendback link should be modified with success or failure feedback 421 * from the action to be used to display feedback to the user. 422 * 423 * @since 4.7.0 424 * 425 * @param string $sendback The redirect URL. 426 * @param string $action The action being taken. 427 * @param array $userids The users to take the action on. 428 */ 429 $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $wp_list_table->current_action(), $userids ); 430 431 wp_safe_redirect( $sendback ); 432 exit; 433 } 434 413 435 $wp_list_table->prepare_items(); 414 436 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
Note: See TracChangeset
for help on using the changeset viewer.