How to implement bulk actions in my plugin?

Unfortunately there isn’t a way of doing this yet, see this trac report.

While it would have been possible to add actions to the bulk-actions drop-down menu, there doesn’t exist (yet) a way of handling custom actions. It seems that WordPress deliberately prevents you from adding custom actions (presumably until it’s decided how bulk actions should be handled – see Codex ).

One work-around, which isn’t particularly pretty, is to use javascript to insert extra options into the drop-down menu. However, as mentioned, there is no (supported) way of handling the action – but you could use use the load-* or admin_action_* hook. (See the core files here).

I’ve not checked, but I believe the array of post ID on which to apply the action could be obtained by $_REQUEST['post'] and the action by $_REQUEST['action']

Keep in mind that no checks have been performed, so you would have to check nonces (check_ajax_referrer()) and check the user has the capability to perform that action (current_user_can()).

You may also want to look at this question too: Custom bulk_action

Leave a Comment