您可以使用wp_handle_upload
挂钩:
http://adambrown.info/p/wp_hooks/hook/wp_handle_upload?version=3.4&file=wp-admin/includes/file.php
创建一个函数并将其添加到此挂钩,使其最后运行,它将被传递一个数组。数组包含新上载文件的位置:
add_filter(\'wp_handle_upload\',\'wpse_66775_handle_upload\',1000,1);
function wpse_66775_handle_upload($args){
$filename = $args[\'file\'];
$type = $args[\'type\'];
// test if it\'s an XML file and do some work on it
if(the file is an xml file){
super_magic_xml_file_modifier($filename);
}
return $args;
}
function super_magic_xml_file_modifier($filename){
// General PHP/XML stuff that doesn\'t belong on WPSE
}
修改XML文件等是不在此网站范围内的另一项任务。