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 NUMBER INPUT // function azurelo_sanitize_number_absint( $number, $setting ) { // Ensure $number is an absolute integer (whole number, zero or greater). $number = absint( $number ); // If the input is an absolute integer, return it; otherwise, return the default return ( $number ? $number : $setting->default ); } // SANITIZE IMAGE // function azurelo_sanitize_image( $input, $setting ) { return esc_url_raw( azurelo_validate_image( $input, $setting->default ) ); } function azurelo_validate_image( $input, $default = '' ) { // Array of valid image file types // The array includes image mime types // that are included in wp_get_mime_types() $mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', 'tif|tiff' => 'image/tiff', 'ico' => 'image/x-icon' ); // Return an array with file extension // and mime_type $file = wp_check_filetype( $input, $mimes ); // If $input has a valid mime_type, // return it; otherwise, return // the default. return ( $file['ext'] ? $input : $default ); } // SANITIZE TEXT // function azurelo_sanitize_text( $input ) { global $allowedtags; return wp_kses( $input , $allowedtags ); } // SANITIZE TEXT // function azurelo_sanitize_url( $input ) { return esc_url( $input ); } // SANITIZE CSS // function azurelo_sanitize_css( $css ) { return wp_strip_all_tags( $css ); } // SANITIZE CATEGORY // function azurelo_sanitize_category ( $input, $setting ) { // Ensure input is a slug $input = sanitize_key( $input ); // If the input is a valid category, return it; // otherwise, return the default return is_string( get_the_category_by_ID( $input ) ) ? $input : $setting->default; } ?>