WC_REST_Controller::validate_setting_image_width_field()
Validate image_width based settings.
Method of the class: WC_REST_Controller{}
No Hooks.
Return
String|WP_Error
.
Usage
$WC_REST_Controller = new WC_REST_Controller(); $WC_REST_Controller->validate_setting_image_width_field( $values, $setting );
- $values(array) (required)
- Values.
- $setting(array) (required)
- Setting.
Changelog
Since 3.0.0 | Introduced. |
WC_REST_Controller::validate_setting_image_width_field() WC REST Controller::validate setting image width field code WC 9.8.1
public function validate_setting_image_width_field( $values, $setting ) { if ( ! is_array( $values ) ) { return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) ); } $current = $setting['value']; if ( isset( $values['width'] ) ) { $current['width'] = intval( $values['width'] ); } if ( isset( $values['height'] ) ) { $current['height'] = intval( $values['height'] ); } if ( isset( $values['crop'] ) ) { $current['crop'] = (bool) $values['crop']; } return $current; }