Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableQuery::sanitize_order()privateWC 1.0

Makes sure the order in an ORDER BY statement is either 'ASC' o 'DESC'.

Method of the class: OrdersTableQuery{}

No Hooks.

Return

String. The sanitized order.

Usage

// private - for code of main (parent) class only
$result = $this->sanitize_order( $order ): string;
$order(string) (required)
The unsanitized order.

OrdersTableQuery::sanitize_order() code WC 9.3.3

private function sanitize_order( string $order ): string {
	$order = strtoupper( $order );

	return in_array( $order, array( 'ASC', 'DESC' ), true ) ? $order : 'DESC';
}