Giter Club home page Giter Club logo

wp-all-import-action-reference's People

Contributors

akshayraje avatar cmdmcs avatar joeguilmette avatar m-thomson avatar mbissett avatar programmer095 avatar trey8611 avatar zeshanshani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-all-import-action-reference's Issues

Document wp_all_import_phpexcel_object

add_filter('wp_all_import_phpexcel_object', 'wpai_wp_all_import_phpexcel_object', 10, 2);
function wpai_wp_all_import_phpexcel_object($PHPExcel, $xlsFilePath){
return $PHPExcel;
}

User hooks

I've created my own hook from a user field connecting through the functions editors. Would be nice to have user hooks though. After and before user creation.

Allow import of emojis and other non-ascii characters ( 2 filters )

Requires >= WP All Import v4.5.6-beta-5.0

add_filter('wp_all_import_is_enabled_stream_filter', 'wpai_wp_all_import_is_enabled_stream_filter', 10, 1);
function wpai_wp_all_import_is_enabled_stream_filter($enable_strem_filter) {
    return FALSE;
}

add_filter('wp_all_import_csv_to_xml_remove_non_ascii_characters', 'wpai_wp_all_import_csv_to_xml_remove_non_ascii_characters', 10, 1);
function wpai_wp_all_import_csv_to_xml_remove_non_ascii_characters($remove_non_ascii_characters) {
    return FALSE;
}

wp_all_import_variation_any_attribute

Requires WooCo Add-On 3.0.7-beta-2.8 or higher.

Allows setting all variations to 'Any' for a certain Attribute that had its values imported with the first variation in the file when using one of the 'no parents' variation grouping options.

Internal Ticket 80616

add_filter('wp_all_import_variation_any_attribute', 'wpai_wp_all_import_variation_any_attribute', 10, 2);
function wpai_wp_all_import_variation_any_attribute($is_any_attribute, $import_id){
	return true;
}

pmxe_before_export

Note: Any code that's attached to this hook must be placed in functions.php or a plugin like Code Snippets.

wp_all_import_parsed_product_attributes

WooCo Add-On 3.0.7+

This allows for the use of delimited Attribute names and values, but you must write the custom code to process those values and return them to WP All Import.

add_filter("wp_all_import_parsed_product_attributes", "wpai_wp_all_import_parsed_product_attributes", 10, 3);
/**
 * Filter product attributes.
 * @param array $attributes - Parsed product attributes
 * [
 *    'name' => string, 'value' => string, 'in_taxonomy' => bool, 'is_create_taxonomy_terms' => bool, 'is_visible' => bool, 'in_variation' => bool
 * ]
 * @param int $pid - Product ID
 * @param int $import_id
 */
function wpai_wp_all_import_parsed_product_attributes($attributes, $pid, $import_id) {  
  return $attributes;
}

wp_all_import_force_cron_processing_on_empty_feed

add_filter('wp_all_import_force_cron_processing_on_empty_feed', 'wpai_wp_all_import_force_cron_processing_on_empty_feed', 10, 2);
function wpai_wp_all_import_force_cron_processing_on_empty_feed($is_force_processing, $import_id){
return true;
}

pmxi_custom_field_to_update

add_filter( 'pmxi_custom_field_to_update', 'wpai_pmxi_custom_field_to_update', 11, 4 );

function wpai_pmxi_custom_field_to_update( $field_to_update, $post_type, $import_options, $m_key ) {
    if ( in_array( $m_key, array( 'field_1', 'field_2', 'field_3' ) ) ) {
        return true;
    }
    return false;
}

wp_all_import_is_php_allowed

Description: disables Function Editor and disables all PHP functions in import template. Must be placed in functions.php file.

Since: WP All Import Pro 4.5.6 Beta 4.2

add_filter('wp_all_import_is_php_allowed', 'wpai_wp_all_import_is_php_allowed', 10, 1);
function wpai_wp_all_import_is_php_allowed($is_php_allowed) {
    return FALSE;
}

wpallexport_custom_types

Can be used to add custom post types to the drop-down in WP All Export. Example of how to add WooCommerce Refunds:

add_filter( 'wpallexport_custom_types', 'my_add_custom_type', 10, 1 );

function my_add_custom_type( $custom_types ) {
  $custom_types['shop_order_refund'] = new stdClass();
  $custom_types['shop_order_refund']->labels = new stdClass();
  $custom_types['shop_order_refund']->labels->name = __('WooCommerce Refunds','wp_all_export_plugin');
  return $custom_types;
}

Update "wp_all_import_is_post_to_update" hook reference

We adjusted the amount of parameters that are available in this hook. I've got this so far:

/**
 * =======================================
 * Filter: wp_all_import_is_post_to_update
 * =======================================
 *
 * Return a boolean indicating if the existing record should be updated. For
 * new posts see "wp_all_import_is_post_to_create"
 *
 * @param $continue_import bool (true = create, false = skip)
 * @param $post_id         int    - Post id
 * @param $data            array  - An array holding values for the current record. If importing from
 *                                       XML, attributes can be accessed as SimpleXMLElement objects.
 * @param $import_id       int    - Import id
 *
 * @return bool (true = update, false = skip)
 */
function my_is_post_to_update($continue_import, $post_id, $data, $import_id)
{
    // your code here
    return true;
}
add_filter('wp_all_import_is_post_to_update', 'my_is_post_to_update', 10, 4);

But the example use has to be updated.

document wp_all_import_get_prices_from_first_variation filter

add_filter('wp_all_import_get_prices_from_first_variation', 'wpai_wp_all_import_get_prices_from_first_variation', 10, 2);
function wpai_wp_all_import_get_prices_from_first_variation($parent_product_id, $import_id) {
return TRUE;
}

This will get prices from the first variation instead of using the parent prices when converting to simple products using the 'Create products with no variations as simple products.' option.

Requires: WooCommerce Add-On 3.0.7-beta-1.0 or above

Your server terminated the import process

When ever i upload the products from wp import all getting error i have aws provider they told me nothing issues in my side and i'm not able to predict what is the issues can help me issues below

Your server terminated the import process
Ask your host to check your server's error log. They will be able to determine why your server is terminating the import process.

error screen shot --https://ibb.co/gRnXx0p

i not able to bulk upload on products showing error on server terminate the process kindly contact the hosting provider error message..
{"code":"internal_server_error","message":"The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.","data":{"status":500},"additional_errors":[]}

wp_all_import_get_image_from_gallery

add_filter('wp_all_import_get_image_from_gallery', 'wpai_wp_all_import_get_image_from_gallery', 10, 3);

function wpai_wp_all_import_get_image_from_gallery( $attach, $image_name, $targetDir ){
	/** 
	* do something with found attachment
	*/
	return $attach; // if attach === false the image will be downloaded 
}

is_xml_preprocess_enabled

Use this for XML files with UTF-16 encoding.

add_filter('is_xml_preprocess_enabled', 'wpai_is_xml_preprocess_enabled', 10, 1);
function wpai_is_xml_preprocess_enabled($is_enabled){
    return false;
}

wp_all_import_images_uploads_dir

add_filter('wp_all_import_images_uploads_dir', 'wpai_wp_all_import_images_uploads_dir', 10, 4);
function wpai_wp_all_import_images_uploads_dir($uploads, $articleData, $current_xml_node, $import_id){
    if ( ! empty($articleData['post_date'])){
        $uploads['path'] = $uploads['basedir'] . '/' . date("Y/m", strtotime($articleData['post_date']));
        $uploads['url'] = $uploads['baseurl'] . '/' . date("Y/m", strtotime($articleData['post_date']));
    }
    return $uploads;
}

Available in WPAI: v4.4.9-beta-2.4

https://secure.helpscout.net/conversation/402212744/40725/#thread-1089767064


I'm seeing that we've got this hook documented, but there's one more example I'd like to add. It's Akshay's snippet here: https://secure.helpscout.net/conversation/435748867/43838/?folderId=410619#thread-1184773125 - with the folder permissions set to 755 (rather than 777).


Update: Got the examples updated (with both of them using mkdir to ensure that the folders are created). All that's left now is to update the list of parameters to indicate which parameter does what (as well as what each parameter contains).


Update: Added the information regarding the parameters.

Doc is located here: https://github.com/soflyy/wp-all-import-action-reference/blob/master/all-import/wp_all_import_images_uploads_dir.php

wp_all_import_get_existing_image

add_filter('wp_all_import_get_existing_image', 'wpai_wp_all_import_get_existing_image', 10, 1);
function wpai_wp_all_import_get_existing_image($attid){
   return $attid;
}

Document wp_all_export_repeater_delimiter

add_filter('wp_all_export_repeater_delimiter', 'wpae_wp_all_export_repeater_delimiter', 10, 2);

function wpae_wp_all_export_repeater_delimiter( $implode_delimiter, $export_id ){
return '#';
}

User import login capitalisation

It seems like, when the "Login" field input is readily available in the source file (eg. "JoeBloggs"), it is stored as "JoeBloggs". I have many usernames generated this way, with capitals.

But, when I run processing on it using a custom function during import, it is converted to lowercase (eg. "joebloggs"). I prefer mixed case.

Specifically, I'm using the following function, with [make_username({name_full[1]})] specified as both "Login" and unique identifier...

 function make_username($name) {

  // convert accented characters
  $no_foreigners = [
    '<' => '', '>' => '', ''' => '', '&' => '',
    '"' => '', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'Ae',
    'Ä' => 'A', 'Å' => 'A', 'Ā' => 'A', 'Ą' => 'A', 'Ă' => 'A', 'Æ' => 'Ae',
    'Ç' => 'C', 'Ć' => 'C', 'Č' => 'C', 'Ĉ' => 'C', 'Ċ' => 'C', 'Ď' => 'D', 'Đ' => 'D',
    'Ð' => 'D', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ē' => 'E',
    'Ę' => 'E', 'Ě' => 'E', 'Ĕ' => 'E', 'Ė' => 'E', 'Ĝ' => 'G', 'Ğ' => 'G',
    'Ġ' => 'G', 'Ģ' => 'G', 'Ĥ' => 'H', 'Ħ' => 'H', 'Ì' => 'I', 'Í' => 'I',
    'Î' => 'I', 'Ï' => 'I', 'Ī' => 'I', 'Ĩ' => 'I', 'Ĭ' => 'I', 'Į' => 'I',
    'İ' => 'I', 'IJ' => 'IJ', 'Ĵ' => 'J', 'Ķ' => 'K', 'Ł' => 'K', 'Ľ' => 'K',
    'Ĺ' => 'K', 'Ļ' => 'K', 'Ŀ' => 'K', 'Ñ' => 'N', 'Ń' => 'N', 'Ň' => 'N',
    'Ņ' => 'N', 'Ŋ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O',
    'Ö' => 'Oe', 'Ö' => 'Oe', 'Ø' => 'O', 'Ō' => 'O', 'Ő' => 'O', 'Ŏ' => 'O',
    'Œ' => 'OE', 'Ŕ' => 'R', 'Ř' => 'R', 'Ŗ' => 'R', 'Ś' => 'S', 'Š' => 'S',
    'Ş' => 'S', 'Ŝ' => 'S', 'Ș' => 'S', 'Ť' => 'T', 'Ţ' => 'T', 'Ŧ' => 'T',
    'Ț' => 'T', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'Ue', 'Ū' => 'U',
    'Ü' => 'Ue', 'Ů' => 'U', 'Ű' => 'U', 'Ŭ' => 'U', 'Ũ' => 'U', 'Ų' => 'U',
    'Ŵ' => 'W', 'Ý' => 'Y', 'Ŷ' => 'Y', 'Ÿ' => 'Y', 'Ź' => 'Z', 'Ž' => 'Z',
    'Ż' => 'Z', 'Þ' => 'T', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a',
    'ä' => 'ae', 'ä' => 'ae', 'å' => 'a', 'ā' => 'a', 'ą' => 'a', 'ă' => 'a',
    'æ' => 'ae', 'ç' => 'c', 'ć' => 'c', 'č' => 'c', 'ĉ' => 'c', 'ċ' => 'c',
    'ď' => 'd', 'đ' => 'd', 'ð' => 'd', 'è' => 'e', 'é' => 'e', 'ê' => 'e',
    'ë' => 'e', 'ē' => 'e', 'ę' => 'e', 'ě' => 'e', 'ĕ' => 'e', 'ė' => 'e',
    'ƒ' => 'f', 'ĝ' => 'g', 'ğ' => 'g', 'ġ' => 'g', 'ģ' => 'g', 'ĥ' => 'h',
    'ħ' => 'h', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ī' => 'i',
    'ĩ' => 'i', 'ĭ' => 'i', 'į' => 'i', 'ı' => 'i', 'ij' => 'ij', 'ĵ' => 'j',
    'ķ' => 'k', 'ĸ' => 'k', 'ł' => 'l', 'ľ' => 'l', 'ĺ' => 'l', 'ļ' => 'l',
    'ŀ' => 'l', 'ñ' => 'n', 'ń' => 'n', 'ň' => 'n', 'ņ' => 'n', 'ʼn' => 'n',
    'ŋ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'oe',
    'ö' => 'oe', 'ø' => 'o', 'ō' => 'o', 'ő' => 'o', 'ŏ' => 'o', 'œ' => 'oe',
    'ŕ' => 'r', 'ř' => 'r', 'ŗ' => 'r', 'š' => 's', 'ù' => 'u', 'ú' => 'u',
    'û' => 'u', 'ü' => 'ue', 'ū' => 'u', 'ü' => 'ue', 'ů' => 'u', 'ű' => 'u',
    'ŭ' => 'u', 'ũ' => 'u', 'ų' => 'u', 'ŵ' => 'w', 'ý' => 'y', 'ÿ' => 'y',
    'ŷ' => 'y', 'ž' => 'z', 'ż' => 'z', 'ź' => 'z', 'þ' => 't', 'ß' => 'ss',
    'ſ' => 'ss', 'ый' => 'iy', 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G',
    'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Ж' => 'ZH', 'З' => 'Z', 'И' => 'I',
    'Й' => 'Y', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O',
    'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F',
    'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '',
    'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'YU', 'Я' => 'YA', 'а' => 'a',
    'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo',
    'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k', 'л' => 'l',
    'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's',
    'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch',
    'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e',
    'ю' => 'yu', 'я' => 'ya'
  ];

  $non_foreign_name = str_replace(array_keys($no_foreigners), $no_foreigners, $name);
  // strip non-letters
  $slugged_name = preg_replace('/[^a-zA-z]/','',$non_foreign_name);

  return $slugged_name;

 }

I read that WordPress Multisite runs sanitisation on usernames when registered through a sign-up form, but that's not what I'm doing here, this is about usernames generated at import.

wp_all_import_attachments_uploads_dir

It's the equivalent of the "wp_all_import_images_uploads_dir" hook, but it only applies to attachments uploaded via the "Download & Import Attachments" field in "Other Post Options".

Document wp_all_export_generate_bundle

This filter can be used to prevent the bundle ZIP file from being generated. Example:

add_filter('wp_all_export_generate_bundle', function(){ return false; });

Can't get attribute value from $data

<property>
	<propertyID>111</propertyID>
	<branchID>11</branchID>
	<clientName>abc</clientName>
	<images>
		<image modified="2018-06-20 23:12:18">
			https://dummyimage.com/300/09f/fff.png
		</image>
		<image modified="2018-06-18 22:17:18">
			https://dummyimage.com/400/09f/fff.png
		</image>
		<image modified="2018-06-18 22:17:18">
			https://dummyimage.com/600/09f/fff.png
		</image>
	</images>
	<virtualTours></virtualTours>
	<externalLinks></externalLinks>
</property>
function my_is_post_to_update( $continue_import, $post_id, $data, $import_id ) { 
	$images = $data['images']['image']["@attributes"]["modified"];
	var_dump($images);
}
add_filter( 'wp_all_import_is_post_to_update', 'my_is_post_to_update', 10, 4 );

Not getting modified date from this function.

Document wp_all_import_search_image_by_wp_attached_file

This filter can be used to stop WP All Import from searching for existing images via _wp_attached_file.

add_filter('wp_all_import_search_image_by_wp_attached_file', 'wpai_wp_all_import_search_image_by_wp_attached_file', 10, 1);
function wpai_wp_all_import_search_image_by_wp_attached_file($is_search_by_wp_attached_file){
	return false;
}

wp_all_import_image_filename does not take args in wp-all-import-pro/classes/api.php

The filter 'wp_all_import_image_filename' in wp-all-import-pro/classes/api.php should be renamed to be specific to PMXI_API::upload_image();

I came across a fatal error when trying to modify the image filename on an ACF image field since the filter 'wp_all_import_image_filename' passed in PMXI_API::upload_image does not pass any arguments other than the image_name.

documents filters to 'delete' and 'update' Custom Fields

add_filter('pmxi_custom_field_to_delete', 'wpai_pmxi_custom_field_to_delete', 10, 4);
function wpai_pmxi_custom_field_to_delete($is_field_to_delete, $pid, $post_type, $import_options, $meta_key){
return false;
}

add_filter('pmxi_custom_field_to_update', 'wpai_pmxi_custom_field_to_update', 10, 4);
function wpai_pmxi_custom_field_to_update($is_field_to_update, $pid, $post_type, $import_options, $meta_key){
return false;
}

pmxe_after_export

I've updated the parameters for this hook, and I've added a code example, but I'd like to do more.

Part of the challenge with this hook was finding out what $exportObj contained. Turns out... dang, that sucker contains a lot of data.

That, and using this (particularly var_export):

update_post_meta("2", "export_object", var_export($exportObj, true));

Really helped (that ended up being what allowed me to tell what was in the object). :)

Update "wp_all_import_is_post_to_create" hook reference

We adjusted the amount of parameters that are available in this hook. I've got this so far:

/**
 * ========================================
 * Filter: wp_all_import_is_post_to_create
 * ========================================
 *
 * Return a boolean indicating if the record should be imported. Note that
 * this is only for new posts. The "wp_all_import_is_post_to_update"
 * filter is for updating existing posts
 * 
 * @param $continue_import   bool (true = create, false = skip)
 * @param $data              array - An array holding values for the current record. If importing from
 *                                        XML, attributes can be accessed as SimpleXMLElement objects.
 * @param $import_id         int   - Import id. It can be used to make the code limited to a specific
 *                                        import only. 
 *
 * @return bool (true = create, false = skip)
 */
function my_is_post_to_create($continue_import, $data, $import_id)
{
    // your code here
    return true;
}
add_filter('wp_all_import_is_post_to_create', 'my_is_post_to_create', 10, 3);

But the example use has to be updated.

wp_all_import_minimum_number_of_variations

SINCE: WooCommerce Add-On v3.0.8-beta-1.3

add_filter('wp_all_import_minimum_number_of_variations', 'wpai_wp_all_import_minimum_number_of_variations', 10, 3);
function wpai_wp_all_import_minimum_number_of_variations($min_number_of_variations, $pid, $import_id) {
  return 1;
}

Convert xml character encoding to utf-8 before processing starts

I am trying to import xml file which its character encoding is not utf-8 and it is not declared in the file (it is utf-16), how is this possible to change the encoding before import process to avoid not valid file exception?
(So the file will be 100% uploaded but just before it starts processing it throws this exception)

There's a problem with your import file
This XML file has errors and is not valid.

I want to add a cron job to update the imported products automatically so the xml encoding needs to be converted automatically.

I declared the encoding in the xml file, and changed the default encoding to utf-16 and also tried the following code, but none of them fixed the issue
<?php
add_action('pmxi_before_xml_import', 'before_xml_import', 10, 1);
function utf16_to_utf8($str) {
$c0 = ord($str[0]);
$c1 = ord($str[1]);

if ($c0 == 0xFE && $c1 == 0xFF) {
    $be = true;
} else if ($c0 == 0xFF && $c1 == 0xFE) {
    $be = false;
} else {
    return $str;
}

$str = substr($str, 2);
$len = strlen($str);
$dec = '';
for ($i = 0; $i < $len; $i += 2) {
    $c = ($be) ? ord($str[$i]) << 8 | ord($str[$i + 1]) : 
            ord($str[$i + 1]) << 8 | ord($str[$i]);
    if ($c >= 0x0001 && $c <= 0x007F) {
        $dec .= chr($c);
    } else if ($c > 0x07FF) {
        $dec .= chr(0xE0 | (($c >> 12) & 0x0F));
        $dec .= chr(0x80 | (($c >>  6) & 0x3F));
        $dec .= chr(0x80 | (($c >>  0) & 0x3F));
    } else {
        $dec .= chr(0xC0 | (($c >>  6) & 0x1F));
        $dec .= chr(0x80 | (($c >>  0) & 0x3F));
    }
}
return $dec;

}

function before_xml_import($import_id) {
$import = new PMXI_Import_Record();
$import->getById($import_id);
$path = $import->path;
$content = utf16_to_utf8(file_get_contents($path));
unlink($path);
$handle = fopen($path, 'w');
fwrite($handle, $content);
fclose($handle);
}
?>

Add example to "wp_all_export_csv_rows" where array_values is used to ensure that only desired data rows are removed

function wp_all_export_csv_rows($articles, $options, $export_id)
{
	// Unless you want this code to execute for every export, be sure to check the export id
	// if ($export_id == 5) { ...
	// Loop through the array and unset() any entries you don't want exported

	foreach ($articles as $key => $article) {
		if ($article["Product Name"] == "Tofudebeast") {
			unset($articles[$key]);			
		}
	}
	$articles = array_values($articles);
	
	return $articles; // Return the array of records to export
}
add_filter('wp_all_export_csv_rows', 'wp_all_export_csv_rows', 10, 3);

Regarding limiting amount of posts to export

I am exporting an XML feed of properties.

I want to limit the number of properties to 200. I asked support and they gave me this:

function my_export_csv_rows($articles, $options, $export_id)
{
    // change 1 to your real export ID
	if($export_id == "1"):
		// change -1 to the number of records you want to export, this will start from the highest post ID and work backward
		// -1 = 1 record exported, -50 = 50 records exported
		$articles = array_slice($articles, -1);
    
        endif;

    	return $articles;
	
}
add_filter('wp_all_export_csv_rows', 'my_export_csv_rows', 10, 3);

However, I have read that wp_all_export_csv_rows is only for csv files. So I found this action reference for wp_all_export_xml_rows, but it seems to be structured totally differently.

I am not very good at php, but maybe some good hearted soul could help me out.

Document wp_all_import_multi_glue

add_filter('wp_all_import_multi_glue', 'wpai_wp_all_import_multi_glue', 10, 1);
function wpai_wp_all_import_multi_glue($delimiter){
   return "|";
}

This changes the delimiter used when returning multiple elements with a single XPath such as {myelement[1]/*}

wp_all_import_images_uploads_dir does not pass $import_id

I have a condition that checks for a specific import ID. The issue is that wp_all_import_images_uploads_dir triggers a number of times without $import_id being passed every time, causing my conditional check to fail for import ID 34.

My wpai_set_upload_folder_by_post_date function seems to run 3 times, the path of directory is incorrect because $import_id argument is not passed every time.

WordPress Version 5.1
WP All Import Pro Version 4.5.6
WP All Import - ACF Add-On Version 3.2.1-beta-1.4

function wpai_set_upload_folder_by_post_date($uploads, $postData, $current_xml_node, $import_id) {

	if ( ! empty($postData['post_date'])) {
		$protected_folder_name = 'protected';

		$uploads['path'] = $uploads['basedir'] . '/' . date("Y/m", strtotime($postData['post_date']));
		$uploads['url'] = $uploads['baseurl'] . '/' . date("Y/m", strtotime($postData['post_date']));

		// import 34 is the specific import where we handle the protected directory
		// it appears removing the condition for $import_id it will work properly
		if ($postData['post_type'] == 'my_custom_post_type' && $import_id == "34") {
			$uploads['path'] = str_replace('uploads', 'uploads/' . $protected_folder_name, $uploads['path']);
			$uploads['url'] = str_replace('uploads', 'uploads/' . $protected_folder_name, $uploads['url']);
		}

		if (!file_exists($uploads['path'])) {
			mkdir($uploads['path'], 0755, true);
		}
		
	}

	return $uploads;

}
add_filter('wp_all_import_images_uploads_dir', 'wpai_set_upload_folder_by_post_date', 10, 4);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.