Skip to content

Instantly share code, notes, and snippets.

@theamnesic
Forked from sunny/sunnytize.php
Created July 12, 2011 13:12
Show Gist options
  • Save theamnesic/1077948 to your computer and use it in GitHub Desktop.
Save theamnesic/1077948 to your computer and use it in GitHub Desktop.
WordPress plugin that removes evil characters in file names
<?php
/*
Plugin Name: Sunnytize
Plugin URI:
Description: A better file name sanitizer
Version: 1.0
Author: Sunny Ripert
Author URI: http://sunfox.org
*/
function sunnytize_file_name_chars($special_chars, $filename_raw = '') {
return array_merge($special_chars, str_split('éè’ààäçéèêöôùûü£€%@+«»°'));
}
add_filter('sanitize_file_name_chars', 'sunnytize_file_name_chars');
function sunnytize_file_name($filename, $filename_raw = '') {
return strtolower($filename);
}
add_filter('sanitize_file_name', 'sunnytize_file_name');
@theamnesic
Copy link
Author

Just add lowercase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment