Astra_Customizer_Sanitizes::sanitize_multi_choices( string $input, object $setting )

Sanitize Select choices


Description


Parameters

$input

(string) (Required) setting input.

$setting

(object) (Required) setting object.


Return

(mixed) setting input value.


Source

File: inc/customizer/class-astra-customizer-sanitizes.php

		public static function sanitize_multi_choices( $input, $setting ) {

			// Get list of choices from the control
			// associated with the setting.
			$choices    = $setting->manager->get_control( $setting->id )->choices;
			$input_keys = $input;

			foreach ( $input_keys as $key => $value ) {
				if ( ! array_key_exists( $value, $choices ) ) {
					unset( $input[ $key ] );
				}
			}

			// If the input is a valid key, return it;
			// otherwise, return the default.
			return ( is_array( $input ) ? $input : $setting->default );
		}

User Contributed Notes

You must log in before being able to contribute a note or feedback.