This file contains hidden or 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_filter('wp_all_import_set_post_terms', 'wpai_wp_all_import_set_post_terms', 10, 4); | |
function wpai_wp_all_import_set_post_terms($assign_terms, $tx_name, $pid, $import_id) { | |
if ($tx_name == 'product_cat'){ | |
$post = get_post($pid); | |
if ($post->post_type == 'product_variation') { | |
$parentID = $post->post_parent; | |
$term_ids = wp_get_object_terms($parentID, $tx_name, array( 'fields' => 'ids' )); | |
if (!empty($assign_terms)) { | |
foreach ($assign_terms as $term_id) { | |
if (!in_array($term_id, $term_ids)) { |
This file contains hidden or 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_filter('wp_all_import_is_post_to_update', 'wpai_wp_all_import_is_post_to_update', 10, 5); | |
function wpai_wp_all_import_is_post_to_update($continueImport, $pid, $currentXmlNode, $importID, $simpleXml) { | |
$images = get_attached_media( 'image', $pid ); | |
$ids = []; | |
foreach ($images as $image) { | |
$ids[] = $image->ID; | |
} | |
update_option('_wpai_attached_images_before_import_' . $pid, $ids); | |
return $continueImport; | |
} |
This file contains hidden or 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': |