WordPress at a glance
function is not described

WC_REST_Controller::validate_setting_image_width_field() public WC 3.0.0

Validate image_width based settings.

{} It's a 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.

Code of WC_REST_Controller::validate_setting_image_width_field() WC 5.0.0

<?php
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;
}