Automattic\WooCommerce\Internal\Admin\Settings
PaymentsRestController::check_providers_order_map_arg
Validate the providers order map argument.
Method of the class: PaymentsRestController{}
No Hooks.
Returns
WP_Error|true
. True if the providers order map argument is valid, otherwise a WP_Error object.
Usage
// private - for code of main (parent) class only $result = $this->check_providers_order_map_arg( $value );
- $value(mixed) (required)
- Value of the argument.
PaymentsRestController::check_providers_order_map_arg() PaymentsRestController::check providers order map arg code WC 9.9.3
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; }