WC_REST_Setting_Options_V2_Controller::cast_image_width()publicWC 3.0.0

For image_width, Crop can return "0" instead of false -- so we want to make sure we return these consistently the same we accept them.

Method of the class: WC_REST_Setting_Options_V2_Controller{}

No Hooks.

Return

Array.

Usage

$WC_REST_Setting_Options_V2_Controller = new WC_REST_Setting_Options_V2_Controller();
$WC_REST_Setting_Options_V2_Controller->cast_image_width( $setting );
$setting(array) (required)
Settings.

Changelog

Since 3.0.0 Introduced.

WC_REST_Setting_Options_V2_Controller::cast_image_width() code WC 8.7.0

public function cast_image_width( $setting ) {
	foreach ( array( 'default', 'value' ) as $key ) {
		if ( isset( $setting[ $key ] ) ) {
			$setting[ $key ]['width']  = intval( $setting[ $key ]['width'] );
			$setting[ $key ]['height'] = intval( $setting[ $key ]['height'] );
			$setting[ $key ]['crop']   = (bool) $setting[ $key ]['crop'];
		}
	}
	return $setting;
}