-
-
Save LanF3usT/1400817 to your computer and use it in GitHub Desktop.
WordPress plugin that removes evil characters in file names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
function sunnytize_slug($slug) { | |
return preg_replace('/[^a-z0-9-_]/', '', $slug); | |
} | |
add_filter('editable_slug', 'sunnytize_slug'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment