The bulk_actions-{$this->screen->id} WordPress PHP filter allows you to modify the items in the bulk actions menu of a specific list table.
Usage
add_filter( 'bulk_actions-{your_screen_id}', 'customize_bulk_actions' ); function customize_bulk_actions( $actions ) { // your custom code here return $actions; }
Parameters
$actions
(array) – An array of the available bulk actions.
More information
See WordPress Developer Resources: bulk_actions-{$this->screen->id}
Examples
Add a custom bulk action to the Posts list
Add a custom bulk action called ‘Mark as Featured’ to the Posts list in the admin area.
add_filter( 'bulk_actions-edit-post', 'add_featured_bulk_action' ); function add_featured_bulk_action( $actions ) { $actions['mark_featured'] = __( 'Mark as Featured', 'textdomain' ); return $actions; }
Remove a specific bulk action from the Pages list
Remove the ‘Move to Trash’ bulk action from the Pages list.
add_filter( 'bulk_actions-edit-page', 'remove_trash_bulk_action' ); function remove_trash_bulk_action( $actions ) { unset( $actions['trash'] ); return $actions; }
Rename a bulk action in the Users list
Rename the ‘Delete’ bulk action to ‘Remove’ in the Users list.
add_filter( 'bulk_actions-users', 'rename_delete_bulk_action' ); function rename_delete_bulk_action( $actions ) { $actions['delete'] = __( 'Remove', 'textdomain' ); return $actions; }
Add a custom bulk action to the Comments list
Add a custom bulk action called ‘Approve & Reply’ to the Comments list.
add_filter( 'bulk_actions-edit-comments', 'add_approve_reply_bulk_action' ); function add_approve_reply_bulk_action( $actions ) { $actions['approve_reply'] = __( 'Approve & Reply', 'textdomain' ); return $actions; }
Reorder bulk actions in the Media list
Change the order of the bulk actions in the Media list by re-adding them in a different order.
add_filter( 'bulk_actions-upload', 'reorder_media_bulk_actions' ); function reorder_media_bulk_actions( $actions ) { $new_actions = array(); $new_actions['delete'] = $actions['delete']; $new_actions['trash'] = $actions['trash']; return $new_actions; }