Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableQuery::sanitize_status()privateWC 1.0

Sanitizes the 'status' query var.

Метод класса: OrdersTableQuery{}

No Hooks.

Return

null. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->sanitize_status(): void;

Code of OrdersTableQuery::sanitize_status() WC 7.1.0

private function sanitize_status(): void {
	// Sanitize status.
	$valid_statuses = array_keys( wc_get_order_statuses() );

	if ( empty( $this->args['status'] ) || 'any' === $this->args['status'] ) {
		$this->args['status'] = $valid_statuses;
	} elseif ( 'all' === $this->args['status'] ) {
		$this->args['status'] = array();
	} else {
		$this->args['status'] = is_array( $this->args['status'] ) ? $this->args['status'] : array( $this->args['status'] );

		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'] ) );
	}
}