Created
January 31, 2012 08:29
-
-
Save ecylmz/1709457 to your computer and use it in GitHub Desktop.
wordpress eklentisi #php #wordpress
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 | |
/** | |
* Plugin Name: Hash Upload Filename | |
* Plugin URI: http://stackoverflow.com/questions/3259696 | |
* Description: Rename uploaded files as the hash of their original. | |
* Version: 0.1 | |
*/ | |
/** | |
* Filter {@see sanitize_file_name()} and return an MD5 hash. | |
* | |
* @param string $filename | |
* @return string | |
*/ | |
function make_filename_hash($filename) { | |
$info = pathinfo($filename); | |
$ext = empty($info['extension']) ? '' : '.' . $info['extension']; | |
$name = basename($filename, $ext); | |
return md5($name) . $ext; | |
} | |
add_filter('sanitize_file_name', 'make_filename_hash', 10); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment