I am developing a WordPress plugin.
This plugin displays a list of courses. Now I want to implement the bulk actions just like in other plugins. From where I can apply the delete and edit actions to the list.
How will I do this. Is there any built-in function for implementing bulk actions in WordPress?
Any help?
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-*
oradmin_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
Stephen Harris is right that there is no built-in way of accomplishing the addition of custom actions to the bulk menu.
Since he replied, Justin Stern has published the best thing written on the subject to date: Add a WordPress Custom Bulk Action. It indeed uses Javascript (jQuery). It might be all you need… at least until the WP crew gives us a built-in way to do this.
On the remote possibility you’re looking to add bulk actions to the media page, you need to adapt Justin’s code. For that look here: https://wordpress.stackexchange.com/a/92098/23086.