Integrates the COT admin list table and COT-based search. (#34421)

* Integrates the COT admin list table and COT-based search.

* A search should be regarded as a form of filtering.
This commit is contained in:
Barry Hughes 2022-08-23 11:28:11 -07:00 committed by GitHub
parent 1e3bf7aa66
commit 852dc0ca61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Integrates (COT) order search with the admin list table for orders.

View File

@ -180,6 +180,7 @@ class ListTable extends WP_List_Table {
$this->set_order_args(); $this->set_order_args();
$this->set_date_args(); $this->set_date_args();
$this->set_customer_args(); $this->set_customer_args();
$this->set_search_args();
/** /**
* Provides an opportunity to modify the query arguments used in the (Custom Order Table-powered) order list * Provides an opportunity to modify the query arguments used in the (Custom Order Table-powered) order list
@ -273,6 +274,18 @@ class ListTable extends WP_List_Table {
$this->order_query_args['status'] = $query_statuses; $this->order_query_args['status'] = $query_statuses;
} }
/**
* Implements order search.
*/
private function set_search_args(): void {
$search_term = trim( sanitize_text_field( wp_unslash( $_REQUEST['s'] ?? '' ) ) );
if ( ! empty( $search_term ) ) {
$this->order_query_args['s'] = $search_term;
$this->has_filter = true;
}
}
/** /**
* Get the list of views for this table (all orders, completed orders, etc, each with a count of the number of * Get the list of views for this table (all orders, completed orders, etc, each with a count of the number of
* corresponding orders). * corresponding orders).