Skip to content

Commit a793843

Browse files
committed
gpfr-lowercase-all-filenames.php: Fixed issue with snippet where the entire path would be lowercased which could create issues down the road with deleting files.
1 parent fccdfcd commit a793843

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gp-file-renamer/gpfr-lowercase-all-filenames.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
* This snippet will automatically lowercase all filenames.
77
*/
88
add_filter( 'gpfr_filename', function( $renamed_file, $file, $entry ) {
9-
return strtolower( $renamed_file );
9+
// Important note, $renamed_file is the entire path.
10+
$lowercase_filename = strtolower( wp_basename( $renamed_file ) );
11+
12+
return str_replace( wp_basename( $renamed_file ), $lowercase_filename, $renamed_file );
1013
}, 10, 3 );

0 commit comments

Comments
 (0)