为救援过滤回调
您仍然可以使用
\'upload_dir\'
-滤器它采用一个具有以下数据的参数:
array(
\'path\' => $dir,
\'url\' => $url,
\'subdir\' => $subdir,
\'basedir\' => $basedir,
\'baseurl\' => $baseurl,
\'error\' => false,
)
只需向其添加回调:
add_filter( \'upload_dir\', \'wpse87234_custom_upload_dir\' );
function wpse87234_custom_upload_dir( $data )
{
// Change everything you need.
return array_merge( $data, array(
\'path\' => $data[\'dir\'],
\'url\' => $data[\'url\'],
\'subdir\' => $data[\'subdir\'],
\'basedir\' => $data[\'basedir\'],
\'baseurl\' => $data[\'baseurl\'],
\'error\' => false,
) );
}