Skip to content

Commit

Permalink
Docs: Move the canonical DocBlock for handle_bulk_actions-{$screen}
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
SergeyBiryukov committed Dec 3, 2019
1 parent 9440ad9 commit 972ca00
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 29 deletions.
15 changes: 1 addition & 14 deletions src/wp-admin/edit-comments.php
Expand Up @@ -92,20 +92,7 @@
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
}

Expand Down
9 changes: 6 additions & 3 deletions src/wp-admin/edit-tags.php
Expand Up @@ -199,9 +199,12 @@
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;
}

Expand Down
20 changes: 18 additions & 2 deletions src/wp-admin/edit.php
Expand Up @@ -182,8 +182,24 @@
}
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;
}

Expand Down
6 changes: 4 additions & 2 deletions src/wp-admin/link-manager.php
Expand Up @@ -32,8 +32,10 @@

$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;
Expand Down
8 changes: 5 additions & 3 deletions src/wp-admin/plugins.php
Expand Up @@ -414,11 +414,13 @@
default:
if ( isset( $_POST['checked'] ) ) {
check_admin_referer( 'bulk-plugins' );
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();

$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-comments.php */
$sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $action, $plugins ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
/** 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;
}
Expand Down
6 changes: 4 additions & 2 deletions src/wp-admin/upload.php
Expand Up @@ -198,8 +198,10 @@
$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 );
Expand Down
7 changes: 4 additions & 3 deletions src/wp-admin/users.php
Expand Up @@ -456,11 +456,12 @@
}

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;
Expand Down

0 comments on commit 972ca00

Please sign in to comment.