Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress: remove acentos e espaços de nomes de arquivos. Mais em http://felipeelia.com.br/wordpress-remover-acentos-e-espacos-de-nomes-de-arquivos/
<?php
// Remove acentos e espaços dos arquivos no upload
function custom_sanitize_file_name ( $filename ) {
$filename = remove_accents( $filename );
$filename = strtolower( $filename );
$file_parts = pathinfo( $filename );
$new_filename = sanitize_title( $file_parts['filename'] );
if ( ! empty( $file_parts['extension'] ) ) {
$new_filename = $new_filename . '.' . $file_parts['extension'];
}
return $new_filename;
}
add_filter( 'sanitize_file_name', 'custom_sanitize_file_name' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment