我有个习惯wp_list_table
创建我自己的表。几乎所有功能都很完美,但批量操作按钮似乎不起作用。它是正确显示的,但单击后什么也没有发生。我想不知怎么的,有一个表单包装器丢失了,或者只是一些javascript?我添加了wp Engineers上描述的按钮:http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/#bulk
我的批量操作功能:
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)!\');
}
}
呈现的HTML(不由任何
form
标签)
<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>