function prepare_items()
    {
        $columns = $this->get_columns();
        $hidden = array();
        $sortable = $this->get_sortable_columns();
        $this->_column_headers = array($columns, $hidden, $sortable);
        usort($this->wpwb_widget_data, array(&$this, 'usort_reorder'));
        $per_page = 10;
        $current_page = $this->get_pagenum();
        $total_items = count($this->wpwb_widget_data);
        $this->found_data = array_slice($this->wpwb_widget_data, ($current_page - 1) * $per_page, $per_page);
        $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
        $this->items = $this->found_data;
    }
}
$con = new WPWB_Database();
if (!empty($_GET['action']) && $_GET['action'] == 'delete' && !empty($_GET['wpwb_id']) && $_GET['tab'] == 'manage-widget') {
    $id = (int) $_GET['wpwb_id'];
    $query = "DELETE FROM " . $this->table . " WHERE wpwb_id='{$id}'";
    $del = $con->Run_Query($query);
    if ($del == 1) {
        $response["success"] = __('Selected Record Deleted Successfully.', 'wp-widget-bundle');
    }
}
if (!empty($_POST['action']) && $_POST['action'] == 'delete' && !empty($_POST['wpwb_id']) && $_GET['tab'] == 'manage-widget') {
    foreach ($_POST['wpwb_id'] as $id) {
        $query = "DELETE FROM " . $this->table . " WHERE wpwb_id='{$id}'";
        $del = $con->Run_Query($query);
    }
    $response["success"] = __('Selected Record Deleted Successfully.', 'wp-widget-bundle');
}
Beispiel #2
0
 function Query($query)
 {
     $this->query = $query;
     $connection = WPWB_Database::Connect();
     $thisObjectName = get_class($this);
     $cursors = WPWB_Database::Reader($this->query, $connection);
     if (!empty($cursors)) {
         foreach ($cursors as $row) {
             $obj = new $thisObjectName();
             $obj->fill($row);
             $objects[] = $obj;
         }
         return $objects;
     }
 }
Beispiel #3
0
 function Delete()
 {
     $connection = WPWB_Database::Connect();
     $this->query = $connection->prepare("DELETE FROM {$this->table} WHERE {$this->unique}='%d'", $this->{$this->unique});
     return WPWB_Database::NonQuery($this->query, $connection);
 }