WordPress at a glance
function is not described

WC_REST_Controller::validate_setting_multiselect_field() public WC 3.0.0

Validate multiselect based settings.

{} It's a method of the class: WC_REST_Controller{}

No Hooks.

Return

Array|WP_Error.

Usage

$WC_REST_Controller = new WC_REST_Controller();
$WC_REST_Controller->validate_setting_multiselect_field( $values, $setting );
$values(array) (required)
Values.
$setting(array) (required)
Setting.

Changelog

Since 3.0.0 Introduced.

Code of WC_REST_Controller::validate_setting_multiselect_field() WC 5.0.0

<?php
public function validate_setting_multiselect_field( $values, $setting ) {
	if ( empty( $values ) ) {
		return array();
	}

	if ( ! is_array( $values ) ) {
		return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
	}

	$final_values = array();
	foreach ( $values as $value ) {
		if ( array_key_exists( $value, $setting['options'] ) ) {
			$final_values[] = $value;
		}
	}

	return $final_values;
}