Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableQuery::sanitize_status
Sanitizes the 'status' query var.
Method of the class: OrdersTableQuery{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->sanitize_status(): void;
OrdersTableQuery::sanitize_status() OrdersTableQuery::sanitize status code WC 10.7.0
private function sanitize_status(): void {
$valid_statuses = array_keys( wc_get_order_statuses() );
if ( empty( $this->args['status'] ) ) {
$this->args['status'] = array();
}
if ( ! is_array( $this->args['status'] ) ) {
$this->args['status'] = array( $this->args['status'] );
}
if ( empty( $this->args['status'] ) || in_array( 'any', $this->args['status'], true ) ) {
// Querying for 'any' status or empty status, filter to valid statuses from wc_get_order_statuses().
$this->args['status'] = $valid_statuses;
} elseif ( in_array( 'all', $this->args['status'], true ) ) {
// Querying for 'all' status does not filter by status at all.
$this->args['status'] = array();
}
foreach ( $this->args['status'] as &$status ) {
$status = in_array( 'wc-' . $status, $valid_statuses, true ) ? 'wc-' . $status : $status;
}
$this->args['status'] = array_unique( array_filter( $this->args['status'] ) );
}