Last active
September 14, 2017 14:39
-
-
Save cmdmcs/e17e80b9261ba96dfce22742b0a87b72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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