我创建了一个类扩展WP_List_Table
并为此批量操作创建了方法:
function get_bulk_actions()
{
$actions = array(
'synchronize' => 'Synchronize',
'delete' => 'Delete from Shareino',
);
return $actions;
}
和另一种处理它们的方法:
function process_bulk_action()
{
//Detect when a bulk action is being triggered...
if ('delete' === $this->current_action()) {
wp_die('Items deleted (or they would be if we had items to delete)!');
}
}
此操作显示在dropbox
中但当我选择项目和其中一项操作并按下时,应用它并不做任何事情,因此process_bulk_action
无法正常工作;
答案 0 :(得分:0)
调用$synchronizationList->display()
关于创建表,分页,排序和批量操作的所有内容时,但是当它创建批量操作时,它只创建2个输入,其中dropbox
包含所有批量操作和提交按钮对于应用按钮,它不会创建from
标记,当提交按钮不在form
时,它什么都不做。
所以我创建了一个form
,并且每件事情都可以。
add_action('admin_menu', array("Shareino", 'ShareinoAdminMenu'));
/**
* This method adds shareino items to admin menu
*/
public static function ShareinoAdminMenu()
{
add_menu_page(__('Shareino', 'access'), __('Shareino', 'access'), 'manage_options', __('shareino', 'vibe'),
array("Shareino", "shareinoSetting"), WP_PLUGIN_URL . "/shareino/assets/images/logo.gif", 80);
add_submenu_page(
'shareino',
__('Synchronize', 'access'),
__('Synchronize'),
'manage_options',
__('Synchronize'),
array("Shareino", "shareinoSynchronize"));
}
public function shareinoSynchronize()
{
$synchronizationList = new SynchronizationList();
$synchronizationList->prepare_items();
?>
<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
<form id="movies-filter" method="get">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>"/>
<!-- Now we can render the completed list table -->
<?php $synchronizationList->display() ?>
</form>
<?php
}
答案 1 :(得分:0)
将$ action作为参数传递
function get_bulk_actions($action)
{
$actions = array(
'synchronize' => 'Synchronize',
'delete' => 'Delete from Shareino',
);
return $actions;
}