manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; // otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } /** * Sanitize HEX Color * * @param string $color Color code in HEX format. * @return mixed Return valid color code. */ public static function _sanitize_hex_color( $color ) { if ( '' === $color ) { return ''; } // 3 or 6 hex digits, or the empty string. if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { return $color; } return ''; } } endif;