I have multiple zip files coming to the server, these are imported by using the WP Import All plugin which creates one post per zip. Each zip includes an XML and some images. To keep track and ensure that each one is imported, I need to delete the original zip files after they've been imported to WP. I understand that I should do this by using the pmxi_after_xml_import hook, which runs after an import is done. But what code should I use to retrieve the file name and path of the original file that has just been imported?
This code is used to delete the plugins processed version of the file, but how should I change it so I can retrieve information about the original file and delete it?
function delete_import_file( $import_id ) {
// Retrieve import object.
$import = new PMXI_Import_Record();
$import->getById( $import_id );
// Confirm import object is valid.
if ( ! $import->isEmpty() ) {
// Retrieve file information.
$history_file = new PMXI_File_Record();
$history_file->getBy( 'import_id', $import_id );
// Confirm file isn't empty.
if ( !$history_file->isEmpty() ) {
// Retrieve file path.
$import_file = wp_all_import_get_absolute_path( $history_file->path );
// Mark file for deletion.
@unlink( $import_file );
}
}
}
add_action( 'pmxi_after_xml_import', 'delete_import_file', 10, 1 );
All help greatly appreciated!