Automattic\WooCommerce\Internal\Admin\Settings
PaymentsRestController::check_providers_order_map_arg
Validate the providers order map argument.
Метод класса: PaymentsRestController{}
Хуков нет.
Возвращает
WP_Error|true. True if the providers order map argument is valid, otherwise a WP_Error object.
Использование
// private - только в коде основоного (родительского) класса $result = $this->check_providers_order_map_arg( $value );
- $value(разное) (обязательный)
- Value of the argument.
Код PaymentsRestController::check_providers_order_map_arg() PaymentsRestController::check providers order map arg WC 10.5.2
private function check_providers_order_map_arg( $value ) {
if ( ! is_array( $value ) ) {
return new WP_Error( 'rest_invalid_param', esc_html__( 'The ordering argument must be an object.', 'woocommerce' ), array( 'status' => 400 ) );
}
foreach ( $value as $provider_id => $order ) {
if ( ! is_string( $provider_id ) || ! is_numeric( $order ) ) {
return new WP_Error( 'rest_invalid_param', esc_html__( 'The ordering argument must be an object with provider IDs as keys and numeric values as values.', 'woocommerce' ), array( 'status' => 400 ) );
}
if ( $this->sanitize_provider_id( $provider_id ) !== $provider_id ) {
return new WP_Error( 'rest_invalid_param', esc_html__( 'The provider ID must be a string with only ASCII letters, digits, underscores, and dashes.', 'woocommerce' ), array( 'status' => 400 ) );
}
if ( false === filter_var( $order, FILTER_VALIDATE_INT ) ) {
return new WP_Error( 'rest_invalid_param', esc_html__( 'The order value must be an integer.', 'woocommerce' ), array( 'status' => 400 ) );
}
}
return true;
}