File "wp-hash-filename.php"
Full Path: /www/wwwroot/shphe-en.com/wp-content/plugins/wp-hash-filename/wp-hash-filename.php
File size: 554 bytes
MIME-type: --
Charset: utf-8
<?php
/**
* Plugin Name: Hash Filename
* Plugin URI: goodao.cn
* Description: goodao.cn
* Version: 1.0
* Author: goodao.cn
* Author URI: http://www.goodao.cn/
* License: goodao.cn
* License URI: goodao.cn
*/
if ( ! defined( 'ABSPATH' ) ) exit;
function make_filename_hash($filename) {
$info = pathinfo($filename);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = basename($filename, $ext);
return substr(md5($name),6,8) . $ext;
}
add_filter('sanitize_file_name', 'make_filename_hash', 10);