Automattic\WooCommerce\Admin\API\Reports
TimeInterval::normalize_between_params()
Normalize "_between" parameters to "_min" and "_max" for numeric values and "_after" and "*_before" for date values.
Метод класса: TimeInterval{}
Хуков нет.
Возвращает
Массив
. Normalized query values.
Использование
$result = TimeInterval::normalize_between_params( $request, $param_names, $is_date );
- $request(массив) (обязательный)
- Query params from REST API request.
- $param_names(строка|массив) (обязательный)
- One or more param names to handle. Should not include "_between" suffix.
- $is_date(true|false) (обязательный)
- Boolean if the param is date is related.
Код TimeInterval::normalize_between_params() TimeInterval::normalize between params WC 9.2.3
public static function normalize_between_params( $request, $param_names, $is_date ) { if ( ! is_array( $param_names ) ) { $param_names = array( $param_names ); } $normalized = array(); foreach ( $param_names as $param_name ) { if ( ! is_array( $request[ $param_name . '_between' ] ) ) { continue; } $range = $request[ $param_name . '_between' ]; if ( 2 !== count( $range ) ) { continue; } $min = $is_date ? '_after' : '_min'; $max = $is_date ? '_before' : '_max'; if ( $range[0] < $range[1] ) { $normalized[ $param_name . $min ] = $range[0]; $normalized[ $param_name . $max ] = $range[1]; } else { $normalized[ $param_name . $min ] = $range[1]; $normalized[ $param_name . $max ] = $range[0]; } } return $normalized; }