I have a custom wp_list_table
to create my own table. Almost everything works perfect, but the bulk action button seems to be not working. It’s proper displayed,but on click nothing happens. I think somehow there is a form-wrapper missing or just some javascript? I added the button described on wp-engineeers: http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/#bulk
My Bulk-action functions:
function get_bulk_actions() {
$actions = array(
'activate' => __('Show'),
'deactivate' => __('Hide')
);
//Add delete function for admins
if(current_user_can( 'delete_published_posts' )){
$actions['delete'] = __('Delete');
}
return $actions;
}
function process_bulk_action() {
$action = $this->current_action();
if( 'activate'===$action ) {
foreach($_GET['wp_list_event'] as $event) {
echo($event['title']);
}
}
if( 'deactivate'===$action ) {
wp_die('Items deactivated (or they would be if we had items to deactivate)!');
}
//Detect when a bulk action is being triggered...
if( 'delete'===$action ) {
wp_die('Items deleted (or they would be if we had items to delete)!');
}
}
The rendered HTML (not wrapped by any form
tag)
<div class="alignleft actions">
<select name='action'>
<option value='-1' selected='selected'>Aktion wählen</option>
<option value='activate'>Anzeigen</option>
<option value='deactivate'>Verstecken</option>
</select>
<input type="submit" name="" id="doaction" class="button action" value="Ãbernehmen" />
</div>
You need to wrap your table into
form
tag, otherwise your bulk action button won’t work.this lines from Custom List Table Example Plugin the solved the issue: