manager->get_control( $setting->id )->choices; //return input if valid or return default option return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } endif; if ( ! function_exists( 'postmag_sanitize_positive_integer' ) ) : /** * Sanitize positive integer. * * @since 1.0.0 * * @param int $input Number to sanitize. * @param WP_Customize_Setting $setting WP_Customize_Setting instance. * @return int Sanitized number; otherwise, the setting default. */ function postmag_sanitize_positive_integer( $input, $setting ) { $input = abs( $input ); if ( $input > 5 || $input < 2) { $input = 3; } // If the input is an absolute integer and between 2 to 5 then, return it. // otherwise, return the default. return ( $input ? $input : $setting->default ); } endif; if ( ! function_exists( 'postmag_sanitize_positive_integer_sitetitle' ) ) : /** * Sanitize positive integer. * * @since 1.0.0 * * @param int $input Number to sanitize. * @param WP_Customize_Setting $setting WP_Customize_Setting instance. * @return int Sanitized number; otherwise, the setting default. */ function postmag_sanitize_positive_integer_sitetitle( $input, $setting ) { $input = abs( $input ); if ( $input > 8 || $input < 4) { $input = 7; } // If the input is an absolute integer and between 4 to 8 then, return it. // otherwise, return the default. return ( $input ? $input : $setting->default ); } endif; if ( ! function_exists( 'postmag_sanitize_radio' ) ) : /** * Sanitize radio. * * @since 1.0.0 * * @param bool $checked Whether the checkbox is checked. * @return bool Whether the checkbox is checked. */ function postmag_sanitize_radio( $input, $setting ){ //input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only $input = sanitize_key($input); //get the list of possible radio box options $choices = $setting->manager->get_control( $setting->id )->choices; //return input if valid or return default option return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } endif; function postmag_sanitize_url( $url ) { return esc_url_raw( $url ); }