我想在构造之后删除项目。
所以我需要弹出窗口来询问确认"你确定"'是'或者'否'
* [OPTIONAL] Return array of bulk actions if has any
*
* @return array
function get_bulk_actions()
{
$actions = array(
'delete' => 'Delete'
);
return $actions;
}
关于成功删除的消息将显示在下一部分的页面
中function process_bulk_action()
{
global $wpdb;
$table_name = $wpdb->prefix . 'abc; // do not forget about tables prefix
if ('delete' === $this->current_action()) {
$ids = isset($_REQUEST['id']) ? $_REQUEST['id'] : array();
if (is_array($ids)) $ids = implode(',', $ids);
if (!empty($ids)) {
$wpdb->query("DELETE FROM $table_name WHERE id IN($ids)");
}
}
}
我们会显示有关成功删除的消息
function custom_table_example_persons_page_handler()
{
global $wpdb;
$table = new Custom_Table_Example_List_Table();
$table->prepare_items();
$message = '';
if ('delete' === $table->current_action()) {
$message = '<div class="updated below-h2" id="message"><p>' .
sprintf(__('Items deleted: %d', 'custom_table_example'), count($_REQUEST['id'])) . '</p></div>';
}
?>