Last active
August 29, 2015 14:11
-
-
Save guillorrr/fe11e11c3dfa832c7c4a to your computer and use it in GitHub Desktop.
Remover acentos y caracteres no convencionales de nombres de archivos // Remove accents and special unaccepted characters [WORDPRESS]
This file contains hidden or 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
// Wordpress function for remove special unaccepted characters, converts name to lowercase, and remove accents. | |
function sanitize_file_uploads( $file ){ | |
$file['name'] = sanitize_file_name($file['name']); | |
$file['name'] = preg_replace("/[^a-zA-Z0-9\_\-\.]/", "", $file['name']); | |
$file['name'] = strtolower($file['name']); | |
add_filter('sanitize_file_name', 'remove_accents'); | |
return $file; | |
} | |
add_filter('wp_handle_upload_prefilter', 'sanitize_file_uploads'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment