wordpress附件目录改为年月日和上传文件名为时间戳

1.wordpress附件保存目录改为年月日

修改wp-includes/functions.php文件下面这几句代码:

$subdir = ";
if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
// Generate the yearly and monthly dirs
if ( !$time )
$time = current_time( 'mysql' );
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
$d = substr( $time, 8, 2 );
$subdir = "/$y/$m/$d";
}

2.wordpress上传文件重命名为时间戳

修改wp-admin/includes/file.php文件329行为:

>$new_file = $uploads['path']. "/".date("YmdHis").floor(microtime()*1000).".".$ext;

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注