delete($wpdb->prefix . "acud_thank_names", array('id' => $_GET["pole"]));
}
}
if ((isset($_POST['action']) && $_POST['action'] == 'delete')//удаление чек боксами
|| (isset($_POST['action2']) && $_POST['action2'] == 'delete')
) {
foreach ($_POST['pole'] as $id) {
$wpdb->delete($wpdb->prefix . "acud_thank_names", array('id' => $id));
}
}
if (!class_exists('WP_List_Table')) {
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
}
?>
search_box(__('Search','AcuD_transl'), 'search_id');
echo "
". __('All available fields.','AcuD_transl')."
";
}
if ($which == "bottom") {
//Код добавляет разметку после таблицы
}
}
function get_bulk_actions()
{
$actions = array(
'delete' => __('Delete','AcuD_transl')
);
return $actions;
}
function column_cb($item)
{
return sprintf(
'', $item['id']
);
}
function get_columns()
{
$columns = array(
'cb' => '',
'nameUser' => __('Name','AcuD_transl'),
'text' =>__('Thanks','AcuD_transl') ,
'Price' =>__('Donation amount','AcuD_transl') ,
'success' => __('Is the payment successful?','AcuD_transl'),
'from_url' => __('Donate page','AcuD_transl')
);
return $columns;
}
function prepare_items()
{
global $wpdb, $_wp_column_headers;
$screen = get_current_screen();
$per_page = 20;
$current_page = $this->get_pagenum();
$total_items = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "acud_thank_names");
/* -- Регистрируем колонки -- */
$columns = $this->get_columns();
$hidden = array();
$sortable = array();
$this->_column_headers = array($columns, $hidden, $sortable);
/* -- Выборка элементов -- */
if (isset($_POST['s'])) {
$itm = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "acud_thank_names WHERE nameUser LIKE '%" . $_POST['s'] . "%' || TEXT LIKE '%" . $_POST['s'] . "%' ORDER BY id DESC", ARRAY_A);
foreach ($itm as &$suc) {
if ($suc['success'] == "1") {
$suc['success'] = __('Yes', 'AcuD_transl');
} else {
$suc['success'] = __('No', 'AcuD_transl');
}
}
$this->items = $itm;
} else {
$this->set_pagination_args([
'total_items' => $total_items, //WE have to calculate the total number of items
'per_page' => $per_page //WE have to determine how many items to show on a page
]);
$itm = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "acud_thank_names ORDER BY id DESC LIMIT " . $per_page . " OFFSET " . ($current_page - 1) * $per_page, ARRAY_A);
foreach ($itm as &$suc) {
if ($suc['success'] == "1") {
$suc['success'] = __('Yes', 'AcuD_transl');
} else {
$suc['success'] = __('No', 'AcuD_transl');
}
switch($suc['Price'] ){
case "item1": $suc['Price'] = get_option("AcuD_popUp_text_level_1"); break;
case "item2": $suc['Price'] = get_option("AcuD_popUp_text_level_2"); break;
case "item3": $suc['Price'] = get_option("AcuD_popUp_text_level_3"); break;
}
if ($suc['nameUser'] == "AcuD_unnamed"){
$suc['nameUser'] = get_option('AcuD_unnamed_text');
}
}
$this->items = $itm;
}
}
function column_default($item, $column_name)
{
return $item[$column_name];
}
function column_nameUser($item)
{
$actions = array(
'delete' => sprintf(''.__('delete', 'AcuD_transl').'')
);
return sprintf('%1$s %2$s', $item['nameUser'], $this->row_actions($actions));
}
}
$PolesTable = new Poles_Table();
$PolesTable->prepare_items();
echo '';
?>