| @@ 161-174 (lines=14) @@ | ||
| 158 | $gateway->init_form_fields(); |
|
| 159 | $settings = $gateway->settings; |
|
| 160 | $errors_found = false; |
|
| 161 | foreach ( $gateway->form_fields as $key => $field ) { |
|
| 162 | if ( isset( $request['settings'][ $key ] ) ) { |
|
| 163 | if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) { |
|
| 164 | $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field ); |
|
| 165 | } else { |
|
| 166 | $value = $this->validate_setting_text_field( $request['settings'][ $key ], $field ); |
|
| 167 | } |
|
| 168 | if ( is_wp_error( $value ) ) { |
|
| 169 | $errors_found = true; |
|
| 170 | break; |
|
| 171 | } |
|
| 172 | $settings[ $key ] = $value; |
|
| 173 | } |
|
| 174 | } |
|
| 175 | ||
| 176 | if ( $errors_found ) { |
|
| 177 | return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) ); |
|
| @@ 278-291 (lines=14) @@ | ||
| 275 | $method->init_instance_settings(); |
|
| 276 | $instance_settings = $method->instance_settings; |
|
| 277 | $errors_found = false; |
|
| 278 | foreach ( $method->get_instance_form_fields() as $key => $field ) { |
|
| 279 | if ( isset( $request['settings'][ $key ] ) ) { |
|
| 280 | if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) { |
|
| 281 | $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field ); |
|
| 282 | } else { |
|
| 283 | $value = $this->validate_setting_text_field( $request['settings'][ $key ], $field ); |
|
| 284 | } |
|
| 285 | if ( is_wp_error( $value ) ) { |
|
| 286 | $errors_found = true; |
|
| 287 | break; |
|
| 288 | } |
|
| 289 | $instance_settings[ $key ] = $value; |
|
| 290 | } |
|
| 291 | } |
|
| 292 | ||
| 293 | if ( $errors_found ) { |
|
| 294 | return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) ); |
|