Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableMetaQuery::sanitize_meta_query()
Sanitizes the meta_query argument.
Метод класса: OrdersTableMetaQuery{}
Хуков нет.
Возвращает
Массив
. A sanitized meta query array.
Использование
// private - только в коде основоного (родительского) класса $result = $this->sanitize_meta_query( $q ): array;
- $q(массив) (обязательный)
- A meta_query array.
Код OrdersTableMetaQuery::sanitize_meta_query() OrdersTableMetaQuery::sanitize meta query WC 9.3.3
private function sanitize_meta_query( array $q ): array { $sanitized = array(); foreach ( $q as $key => $arg ) { if ( 'relation' === $key ) { $relation = $arg; } elseif ( ! is_array( $arg ) ) { continue; } elseif ( $this->is_atomic( $arg ) ) { if ( isset( $arg['value'] ) && array() === $arg['value'] ) { unset( $arg['value'] ); } $arg['compare'] = isset( $arg['compare'] ) ? strtoupper( $arg['compare'] ) : ( isset( $arg['value'] ) && is_array( $arg['value'] ) ? 'IN' : '=' ); $arg['compare_key'] = isset( $arg['compare_key'] ) ? strtoupper( $arg['compare_key'] ) : ( isset( $arg['key'] ) && is_array( $arg['key'] ) ? 'IN' : '=' ); if ( ! in_array( $arg['compare'], self::NON_NUMERIC_OPERATORS, true ) && ! in_array( $arg['compare'], self::NUMERIC_OPERATORS, true ) ) { $arg['compare'] = '='; } if ( ! in_array( $arg['compare_key'], self::NON_NUMERIC_OPERATORS, true ) ) { $arg['compare_key'] = '='; } $sanitized[ $key ] = $arg; $sanitized[ $key ]['index'] = $key; } else { $sanitized_arg = $this->sanitize_meta_query( $arg ); if ( $sanitized_arg ) { $sanitized[ $key ] = $sanitized_arg; } } } if ( $sanitized ) { $sanitized['relation'] = 1 === count( $sanitized ) ? 'OR' : $this->sanitize_relation( $relation ?? 'AND' ); } return $sanitized; }