本文整理汇总了PHP中SwpmUtils::sanitize_value_by_array方法的典型用法代码示例。如果您正苦于以下问题:PHP SwpmUtils::sanitize_value_by_array方法的具体用法?PHP SwpmUtils::sanitize_value_by_array怎么用?PHP SwpmUtils::sanitize_value_by_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SwpmUtils
的用法示例。
在下文中一共展示了SwpmUtils::sanitize_value_by_array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare_items
function prepare_items()
{
global $wpdb;
$this->process_bulk_action();
$query = "SELECT * FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id !=1 ";
if (isset($_POST['s'])) {
$query .= " AND alias LIKE '%" . strip_tags($_POST['s']) . "%' ";
}
$orderby = !empty($_GET["orderby"]) ? esc_sql($_GET["orderby"]) : 'id';
$order = !empty($_GET["order"]) ? esc_sql($_GET["order"]) : 'DESC';
$sortable_columns = $this->get_sortable_columns();
$orderby = SwpmUtils::sanitize_value_by_array($orderby, $sortable_columns);
$order = SwpmUtils::sanitize_value_by_array($order, array('DESC' => '1', 'ASC' => '1'));
if (!empty($orderby) && !empty($order)) {
$query .= ' ORDER BY ' . $orderby . ' ' . $order;
}
$totalitems = $wpdb->query($query);
//return the total number of affected rows
$perpage = 20;
$paged = !empty($_GET["paged"]) ? esc_sql($_GET["paged"]) : '';
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
$paged = 1;
}
$totalpages = ceil($totalitems / $perpage);
if (!empty($paged) && !empty($perpage)) {
$offset = ($paged - 1) * $perpage;
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage;
}
$this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage));
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->items = $wpdb->get_results($query, ARRAY_A);
}
示例2: prepare_items
function prepare_items()
{
global $wpdb;
$this->process_bulk_action();
$query = "SELECT * FROM " . $wpdb->prefix . "swpm_members_tbl";
$query .= " LEFT JOIN " . $wpdb->prefix . "swpm_membership_tbl";
$query .= " ON ( membership_level = id ) ";
$s = filter_input(INPUT_POST, 's');
if (!empty($s)) {
$query .= " WHERE user_name LIKE '%" . strip_tags($s) . "%' " . " OR first_name LIKE '%" . strip_tags($s) . "%' " . " OR last_name LIKE '%" . strip_tags($s) . "%' " . " OR email LIKE '%" . strip_tags($s) . "%' " . " OR address_city LIKE '%" . strip_tags($s) . "%' " . " OR address_state LIKE '%" . strip_tags($s) . "%' " . " OR country LIKE '%" . strip_tags($s) . "%' " . " OR company_name LIKE '%" . strip_tags($s) . "%' ";
}
$orderby = filter_input(INPUT_GET, 'orderby');
$orderby = empty($orderby) ? 'member_id' : $orderby;
$order = filter_input(INPUT_GET, 'order');
$order = empty($order) ? 'DESC' : $order;
$sortable_columns = $this->get_sortable_columns();
$orderby = SwpmUtils::sanitize_value_by_array($orderby, $sortable_columns);
$order = SwpmUtils::sanitize_value_by_array($order, array('DESC' => '1', 'ASC' => '1'));
$query .= ' ORDER BY ' . $orderby . ' ' . $order;
$totalitems = $wpdb->query($query);
//return the total number of affected rows
$perpage = 20;
$paged = filter_input(INPUT_GET, 'paged');
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
$paged = 1;
}
$totalpages = ceil($totalitems / $perpage);
if (!empty($paged) && !empty($perpage)) {
$offset = ($paged - 1) * $perpage;
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage;
}
$this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage));
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->items = $wpdb->get_results($query, ARRAY_A);
}
示例3: prepare_items
function prepare_items()
{
global $wpdb;
$this->process_bulk_action();
$query = "SELECT * FROM " . $wpdb->prefix . "swpm_members_tbl";
$query .= " LEFT JOIN " . $wpdb->prefix . "swpm_membership_tbl";
$query .= " ON ( membership_level = id ) ";
$s = filter_input(INPUT_POST, 's');
$status = filter_input(INPUT_GET, 'status');
$filter1 = '';
//Add the search parameter to the query
if (!empty($s)) {
$s = trim($s);
//Trim the input
$filter1 .= "( user_name LIKE '%" . strip_tags($s) . "%' " . " OR first_name LIKE '%" . strip_tags($s) . "%' " . " OR last_name LIKE '%" . strip_tags($s) . "%' " . " OR email LIKE '%" . strip_tags($s) . "%' " . " OR address_city LIKE '%" . strip_tags($s) . "%' " . " OR address_state LIKE '%" . strip_tags($s) . "%' " . " OR country LIKE '%" . strip_tags($s) . "%' " . " OR company_name LIKE '%" . strip_tags($s) . "%' )";
}
//Add account status filtering to the query
$filter2 = '';
if (!empty($status)) {
if ($status == 'incomplete') {
$filter2 .= "user_name = ''";
} else {
$filter2 .= "account_state = '" . $status . "'";
}
}
//Build the WHERE clause of the query string
if (!empty($filter1) && !empty($filter2)) {
$query .= "WHERE " . $filter1 . " AND " . $filter2;
} else {
if (!empty($filter1)) {
$query .= "WHERE " . $filter1;
} else {
if (!empty($filter2)) {
$query .= "WHERE " . $filter2;
}
}
}
//Build the orderby and order query parameters
$orderby = filter_input(INPUT_GET, 'orderby');
$orderby = empty($orderby) ? 'member_id' : $orderby;
$order = filter_input(INPUT_GET, 'order');
$order = empty($order) ? 'DESC' : $order;
$sortable_columns = $this->get_sortable_columns();
$orderby = SwpmUtils::sanitize_value_by_array($orderby, $sortable_columns);
$order = SwpmUtils::sanitize_value_by_array($order, array('DESC' => '1', 'ASC' => '1'));
$query .= ' ORDER BY ' . $orderby . ' ' . $order;
//Execute the query
$totalitems = $wpdb->query($query);
//return the total number of affected rows
//Pagination setup
$perpage = 20;
$paged = filter_input(INPUT_GET, 'paged');
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
$paged = 1;
}
$totalpages = ceil($totalitems / $perpage);
if (!empty($paged) && !empty($perpage)) {
$offset = ($paged - 1) * $perpage;
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage;
}
$this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage));
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->items = $wpdb->get_results($query, ARRAY_A);
}
示例4: prepare_items
function prepare_items()
{
global $wpdb;
$payments_table_name = $wpdb->prefix . "swpm_payments_tbl";
// Lets decide how many records per page to show
$per_page = apply_filters('swpm_transactions_menu_items_per_page', 50);
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->process_bulk_action();
//This checks for sorting input. Read and sanitize the inputs
$orderby_column = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : '';
$sort_order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : '';
if (empty($orderby_column)) {
$orderby_column = "id";
$sort_order = "DESC";
}
$orderby_column = SwpmUtils::sanitize_value_by_array($orderby_column, $sortable);
$sort_order = SwpmUtils::sanitize_value_by_array($sort_order, array('DESC' => '1', 'ASC' => '1'));
//pagination requirement
$current_page = $this->get_pagenum();
if (isset($_POST['swpm_txn_search'])) {
//Only load the searched records
$search_term = trim(sanitize_text_field($_POST['swpm_txn_search']));
$prepare_query = $wpdb->prepare("SELECT * FROM " . $payments_table_name . " WHERE `email` LIKE '%%%s%%' OR `txn_id` LIKE '%%%s%%' OR `first_name` LIKE '%%%s%%' OR `last_name` LIKE '%%%s%%'", $search_term, $search_term, $search_term, $search_term);
$data = $wpdb->get_results($prepare_query, ARRAY_A);
$total_items = count($data);
} else {
//Load all data in an optimized way (so it is only loading data for the current page)
$query = "SELECT COUNT(*) FROM {$payments_table_name}";
$total_items = $wpdb->get_var($query);
//pagination requirement
$query = "SELECT * FROM {$payments_table_name} ORDER BY {$orderby_column} {$sort_order}";
$offset = ($current_page - 1) * $per_page;
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $per_page;
$data = $wpdb->get_results($query, ARRAY_A);
}
// Now we add our *sorted* data to the items property, where it can be used by the rest of the class.
$this->items = $data;
//pagination requirement
$this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
}