Skip to content

Instantly share code, notes, and snippets.

@cmdmcs
Last active September 14, 2017 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cmdmcs/e17e80b9261ba96dfce22742b0a87b72 to your computer and use it in GitHub Desktop.
Save cmdmcs/e17e80b9261ba96dfce22742b0a87b72 to your computer and use it in GitHub Desktop.
add_action( 'pmxi_before_xml_import', 'wp_all_import_before_xml_import', 10, 1 );
function wp_all_import_before_xml_import( $import_id ) {
$path = false;
$import = new PMXI_Import_Record();
$import->getById( $import_id );
if ( ! $import->isEmpty() ) {
switch ($import->type) {
case 'url':
$history = new PMXI_File_List();
$history->setColumns('id', 'name', 'registered_on', 'path')->getBy(array('import_id' => $import->id), 'id DESC');
if ($history->count()) {
foreach ($history as $file){
$path = wp_all_import_get_absolute_path($file['path']);
break;
}
}
break;
default:
$path = wp_all_import_get_absolute_path( $import->path );
break;
}
}
if ($path){
$file_content = file_get_contents($path);
// modify file content
file_put_contents($path, $file_content);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment