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 ); } endif; //============================================================= // Checkbox santitization //============================================================= if ( ! function_exists( 'blog_way_sanitize_checkbox' ) ) : function blog_way_sanitize_checkbox( $checked ) { return ( ( isset( $checked ) && true === $checked ) ? true : false ); } endif; //============================================================= // Positive santitization //============================================================= if ( ! function_exists( 'blog_way_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 blog_way_sanitize_positive_integer( $input, $setting ) { $input = absint( $input ); // If the input is an absolute integer, return it. // otherwise, return the default. return ( $input ? $input : $setting->default ); } endif;