Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save helisoncruz/5623dc9aed6a179bd70926b3510c6f70 to your computer and use it in GitHub Desktop.
Save helisoncruz/5623dc9aed6a179bd70926b3510c6f70 to your computer and use it in GitHub Desktop.
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