How to fire on bulk actions inside of an extended WP_List_Table.
I have been adding the following bulk actions to may table’s select box but on Apply won’t really happens anything
here are how I added my bulk actions
function get_bulk_actions() {
$actions = array(
'delete' => 'Delete',
'parsing' => 'Parsen'
);
return $actions;
}
and here is the check box column
function column_cb($item) {
return sprintf(
'<input type="checkbox" name="record[]" value="%d" />', $item['Round']
);
}
If you add a bulk-action, then you have to react on this action. Simply adding a function doesn’t do anything, you have to call it:
In
prepare_items()
we callprocess_bulk_action()
. So on your backend page you will have something like this:At first you create an instance of your list-table class. Then you create a formular and call
prepare_items()
. With this call, the bulk actions will be processed because we call the methodprocess_bulk_action()
insideprepare_items()
.In the example above, we use
post
as method to send the data. So we can grab the bulk action from the post array if we didn’t want to process the bulk actions inside the class (or by other reasons).You can grab the bulk action anywhere you want from the post/get array (depending on what method was used to send the data).
WP List w/ bulk actions using an “Array” DATA
https://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/ (Make it as a plugin)
https://gist.github.com/Latz/7f923479a4ed135e35b2 (for functions.php)
WP List w/ bulk actions using an “SQL” DATA
https://www.smashingmagazine.com/2011/11/native-admin-tables-wordpress/ (for functions.php)
Cheers!
this is what I have found on several websites. It still isn’t working for me, but it used to work when I still had the sample data in my custom list table.