Last active
December 6, 2018 18:00
-
-
Save angelorocha/bec26ed2bb08b64f65adb3cf5f45650f to your computer and use it in GitHub Desktop.
Sanitize wordpress uploaded filenames
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 | |
/** | |
* Include in your theme functions | |
*/ | |
add_filter( 'sanitize_file_name', 'sanitize_uploaded_filename' ); | |
function sanitize_uploaded_filename( $filename ) { | |
$fileNewName = sanitize_title( pathinfo( $filename )['filename'] ) . '.' . pathinfo( $filename )['extension']; | |
return $fileNewName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment