From 972ca00d2d2fc596eeab31925e071e7275c26f5f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 3 Dec 2019 13:56:25 +0000 Subject: [PATCH] Docs: Move the canonical DocBlock for `handle_bulk_actions-{$screen}` action to `wp-admin/edit.php`. * Document accepted values for the `$items` parameter. * Use interpolated syntax for the filter name. Props dilipbheda, johnbillion, SergeyBiryukov. Fixes #48857. git-svn-id: https://develop.svn.wordpress.org/trunk@46811 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-comments.php | 15 +-------------- src/wp-admin/edit-tags.php | 9 ++++++--- src/wp-admin/edit.php | 20 ++++++++++++++++++-- src/wp-admin/link-manager.php | 6 ++++-- src/wp-admin/plugins.php | 10 ++++++---- src/wp-admin/upload.php | 6 ++++-- src/wp-admin/users.php | 7 ++++--- 7 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index 0bd3b7a09d..b159c0a179 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -92,20 +92,7 @@ if ( $doaction ) { if ( ! in_array( $doaction, array( 'approve', 'unapprove', 'spam', 'unspam', 'trash', 'delete' ), true ) ) { $screen = get_current_screen()->id; - /** - * Fires when a custom bulk action should be handled. - * - * The redirect link should be modified with success or failure feedback - * from the action to be used to display feedback to the user. - * - * The dynamic portion of the hook name, `$screen`, refers to the current screen ID. - * - * @since 4.7.0 - * - * @param string $redirect_url The redirect URL. - * @param string $doaction The action being taken. - * @param array $items The items to take the action on. - */ + /** This action is documented in wp-admin/edit.php */ $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $comment_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } diff --git a/src/wp-admin/edit-tags.php b/src/wp-admin/edit-tags.php index 93d5b73258..fb05b6aa62 100644 --- a/src/wp-admin/edit-tags.php +++ b/src/wp-admin/edit-tags.php @@ -199,9 +199,12 @@ switch ( $wp_list_table->current_action() ) { break; } check_admin_referer( 'bulk-tags' ); - $tags = (array) $_REQUEST['delete_tags']; - /** This action is documented in wp-admin/edit-comments.php */ - $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + + $screen = get_current_screen()->id; + $tags = (array) $_REQUEST['delete_tags']; + + /** This action is documented in wp-admin/edit.php */ + $location = apply_filters( "handle_bulk_actions-{$screen}", $location, $wp_list_table->current_action(), $tags ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores break; } diff --git a/src/wp-admin/edit.php b/src/wp-admin/edit.php index a8c2265d20..5c818f4e4c 100644 --- a/src/wp-admin/edit.php +++ b/src/wp-admin/edit.php @@ -182,8 +182,24 @@ if ( $doaction ) { } break; default: - /** This action is documented in wp-admin/edit-comments.php */ - $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $post_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + $screen = get_current_screen()->id; + + /** + * Fires when a custom bulk action should be handled. + * + * The redirect link should be modified with success or failure feedback + * from the action to be used to display feedback to the user. + * + * The dynamic portion of the hook name, `$screen`, refers to the current screen ID. + * + * @since 4.7.0 + * + * @param string $sendback The redirect URL. + * @param string $doaction The action being taken. + * @param array $items The items to take the action on. Accepts an array of IDs of posts, + * comments, terms, links, plugins, attachments, or users. + */ + $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $doaction, $post_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores break; } diff --git a/src/wp-admin/link-manager.php b/src/wp-admin/link-manager.php index e8418ea0ec..1ca9bf64b3 100644 --- a/src/wp-admin/link-manager.php +++ b/src/wp-admin/link-manager.php @@ -32,8 +32,10 @@ if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) { $redirect_to = add_query_arg( 'deleted', count( $bulklinks ), $redirect_to ); } else { - /** This action is documented in wp-admin/edit-comments.php */ - $redirect_to = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $bulklinks ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + $screen = get_current_screen()->id; + + /** This action is documented in wp-admin/edit.php */ + $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $bulklinks ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } wp_redirect( $redirect_to ); exit; diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index eb80edcd4b..acebd8e452 100644 --- a/src/wp-admin/plugins.php +++ b/src/wp-admin/plugins.php @@ -414,11 +414,13 @@ if ( $action ) { default: if ( isset( $_POST['checked'] ) ) { check_admin_referer( 'bulk-plugins' ); - $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); - $sendback = wp_get_referer(); - /** This action is documented in wp-admin/edit-comments.php */ - $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $action, $plugins ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + $screen = get_current_screen()->id; + $sendback = wp_get_referer(); + $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); + + /** This action is documented in wp-admin/edit.php */ + $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $action, $plugins ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores wp_safe_redirect( $sendback ); exit; } diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php index f399eaf446..a5a5d21612 100644 --- a/src/wp-admin/upload.php +++ b/src/wp-admin/upload.php @@ -198,8 +198,10 @@ if ( $doaction ) { $location = add_query_arg( 'deleted', count( $post_ids ), $location ); break; default: - /** This action is documented in wp-admin/edit-comments.php */ - $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $doaction, $post_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + $screen = get_current_screen()->id; + + /** This action is documented in wp-admin/edit.php */ + $location = apply_filters( "handle_bulk_actions-{$screen}", $location, $doaction, $post_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } wp_redirect( $location ); diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php index 884b143a15..48e169d69c 100644 --- a/src/wp-admin/users.php +++ b/src/wp-admin/users.php @@ -456,11 +456,12 @@ switch ( $wp_list_table->current_action() ) { } if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) { - $userids = $_REQUEST['users']; + $screen = get_current_screen()->id; $sendback = wp_get_referer(); + $userids = $_REQUEST['users']; - /** This action is documented in wp-admin/edit-comments.php */ - $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $wp_list_table->current_action(), $userids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + /** This action is documented in wp-admin/edit.php */ + $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $wp_list_table->current_action(), $userids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores wp_safe_redirect( $sendback ); exit;