Skip to content

Instantly share code, notes, and snippets.

@guillorrr
Last active August 29, 2015 14:11
Show Gist options
  • Save guillorrr/fe11e11c3dfa832c7c4a to your computer and use it in GitHub Desktop.
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]
// 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