Nested Fields

Nested Fields

There are some settings that you add to your plugin that not all users need. To keep the user interface clean and organized for the majority of users you can nest and organized fields in a variety of ways.

The simplest method is to add an options panel. Here we will add an options panel to nest the price postfix in an expandable accordion.

$this->add_on->add_field( 'property_price', 'Property Price', 'text', null, 'Only digits, example: 435000' );

$this->add_on->add_options(
null,
'Price Settings',
array(
$this->add_on->add_field( 'property_price_postfix', 'Price Postfix', 'text', null, 'Example: Per Month' )
)
);

You can choose to add such an options panel attached to the price field.

$this->add_on->add_options(
$this->add_on->add_field( 'property_price', 'Property Price', 'text', null, 'Only digits, example: 435000' ),
'Price Settings',
array(
$this->add_on->add_field( 'property_price_postfix', 'Price Postfix', 'text', null, 'Example: Per Month' ),
$this->add_on->add_field( 'property_price_currency', 'Currency Symbol', 'text', null, 'Example: $, or €' )
)
);

Nested Radio Fields

You can also nest fields within the radio field. You can add as many fields as you like to the radio field』s options array.

$this->add_on->add_field(
'property_location',
'Property Location',
'radio',
array(
'enter_address' => array(
'Enter Address',
$this->add_on->add_field( 'property_address', 'Property Address', 'text' )
),
'enter_coordinates' => array(
'Enter Coordinates',
$this->add_on->add_field( 'property_coordinates', 'Property Coordinates', 'text' )
),
)
);

No Limits

You can even get a little crazy. There is no limit to how you can combine options panels and nested radio fields.

$this->add_on->add_field(
'location_settings',
'Property Location',
'radio',
array(
'search_by_address' => array(
'Search by Address',
$this->add_on->add_options(
$this->add_on->add_field( 'property_address','Property Address','text' ),
'Google Geocode API Settings',
array(
$this->add_on->add_field(
'geocode_method',
'Request Method',
'radio',
array(
'key_false' => array(
'No API Key',
'Limited number of requests.'
),
'key_true' => array(
'Google Developers API Key',
$this->add_on->add_field( 'api_key', 'API Key', 'text' ),
'Up to 2,500 requests per day and 5 requests per second.'
)
)
)
) // end Google Geocode API Settings fields
)
), // end Search by Address radio field
'enter_coordinates' => array(
'Enter Coordinates',
$this->add_on->add_field( 'property_latitude', 'Latitude', 'text' ),
$this->add_on->add_field( 'property_longitude', 'Longitude', 'text' )
)
)
);

Related

Add-On Structure

Text Fields

Radio Fields

Image Fields

Adding Support For Your Theme or Plugin

Adding Support For Your Theme or Plugin

WP All Import can be extended using our Add-On API to fully support any plugin or theme. Does your plugin or theme use custom database tables, inter-related post types, or some other unique setup? No problem, as you can write custom code to accommodate any situation.

Are you a plugin or theme developer?

Creating a WP All Import add-on will give your users an easy and free way to import their data to your plugin or theme.

An add-on can make things MUCH easier for your users if your plugin/theme doesn』t store data in the 「normal」 places in WordPress.

For example, many plugins and themes use nested serialized arrays and custom gallery fields to store data, but WP All Import doesn』t provide a simple way to import to those.

Note: Add-ons can be used with both the free and paid versions of WP All Import. This means all of your users will have an easy way to make use of the add-on you create.

Best of all, coding add-ons is extremely easy using our Rapid Add-On API.

An add-on is just a normal WordPress plugin, and a simple add-on can be done with less than 20 lines of code.

Continue to Add-On Structure to learn how to code an add-on.

What's Next?

Add-On Structure

Best Practices

A Complete Add-On

Related

Text Fields

Radio Fields

Image Fields

Nested Fields

Radio Fields

Radio Fields

Radio fields allow the user to specify one of multiple, predefined values. These fields should all be defined in your add-on's constructor.

$this->add_on->add_field(
'property_type',
'Property Type',
'radio',
array(
'rent' => 'For Rent/Lease',
'buy' => 'For Sale'
)
);

The keys in the options array are the actual values that will be passed to the import function. The values are the labels that will be shown to the user in the interface:

Radio Field

If the values in the user』s XML/CSV file are different than the values required by your radio field, the user can use the built-in mapping interface to translate them:

Radio Field Mapping

Related

Add-On Structure

Text Fields

Image Fields

Nested Fields

The Structure of an Import Add-On

The Structure of an Import Add-On

WP All Import Add-Ons are WordPress plugins that make use of WP All Import's Rapid Add-On API. A few simple lines of code is all it takes to add UI elements to WP All Import and then determine how that data gets imported.

There are four main parts to an add-on. First, you need to register your code as a plugin to WordPress and then as an add-on to WP All Import. Next, you add UI elements for your user to drag and drop data into. Then you tell WP All Import how to import this new data. Finally, you under which circumstances the add-on should run.

Now we'll go through each part of a simple add-on for WP All Import.

1. Create a new WordPress plugin and include the rapid-addon.php file.

To get started, you need to tell WordPress that this is a plugin and then set the groundwork for our import add-on. Start with the WordPress plugin header and then instantiate a class for your add-on.

/*
Plugin Name: My First Add-On
Description: A super awesome add-on for WP All Import!
Version: 1.0
Author: WP All Import
*/
include "rapid-addon.php";

final class my_first_add_on {

protected static $instance;

protected $add_on;

static public function get_instance() {
if ( self::$instance == NULL ) {
self::$instance = new self();
}
return self::$instance;
}

2. Initialize the add-on.

Next, create a new instance of the RapidAddon class in the add-on's constructor. Pass the add-on』s name and slug to the RapidAddon's class constructor. The slug should be unique to the add-on and different than the add-on's class name.

protected function __construct() {

// Define the add-on
$this->add_on = new RapidAddon( 'My First Add-On', 'my_first_addon' );

3. Add UI fields to the import template.

When setting up an import the user will drag and drop their data into WP All Import. The code below will add two text fields to the add-on – one for Property Location, and one for Property Price.

$this->add_on->add_field('property_location', 'Property Location', 'text');
$this->add_on->add_field('property_address', 'Property Address', 'text');

After all of the UI fields are set up, define the import method for your add-on with the snippet below. Each time a post is imported or updated, WP All Import will call this method and pass the post ID and the imported data. You'll also need to initialize the add-on with init.

$this->add_on->set_import_function([ $this, 'import' ]);
add_action( 'init', [ $this, 'init' ] );

4. Tell WP All Import how to import data to your theme or plugin.

Here we will get the values of the two fields we created earlier and import them as custom fields.

public function import( $post_id, $data, $import_options, $article ) {

$fields = array(
'property_location',
'property_address'
);

foreach ( $fields as $field ) {
// Make sure the user has allowed this field to be updated.
if ( empty( $article['ID'] ) || $this->add_on->can_update_meta( $field, $import_options ) ) {

// Update the custom field with the imported data.
update_post_meta( $post_id, $field, $data[ $field ] );
}
}
}

5. Specify when your add-on runs.

Earlier we initialized our add-on with init. By default, add-ons will always run. You probably want to check to make sure a theme or plugin is active, or limit your add-on to specific custom post types.

public function init() {

$this->add_on->run( array( "themes" => array("Twenty Fourteen", "Twenty Fifteen") ) );

}

The above code will only allow the add-on to run if the Twenty Fourteen or Twenty Fifteen theme is active.

6. Close out the add-on.

Finally, we need to call the get_instance() method at the end of the file, outside of the class definition:

my_first_add_on::get_instance();

7. That』s all, you are done coding!

To see the add-on in action, install and activate this plugin, and do an import with WP All Import.

The add-on will appear in Step 3 of WP All Import as a box titled My First Add-On:

My First Add-On

Related

Text Fields

Radio Fields

Image Fields

Nested Fields

Text Fields

Text Fields

If you need users to be able to input text so they can import a string, use a text input field. This is useful when the possible values for the field aren』t constrained to a predefined list. These fields should all be defined in your add-on's constructor.

$this->add_on->add_field( 'property_address', 'Property Address', 'text', null, 'Tooltip', false, 'Default Text' );

Here』s what a text input field looks like:

Add-On Text Field

You can also add a textarea field:

$this->add_on->( 'field_name', 'Field Name', 'textarea', null, 'Tooltip', false, 'Default Text');

And, it will look like this:

Text Area Field

Display Text & Titles

Other times you might want to include title or text to explain things to users. You can use the following functions to add titles and text to the UI of your add-on.

$this->add_on->add_title( 'Title Text', 'Text that will appear as a tooltip next to the title.' );
$this->add_on->add_text( 'This is text that will appear as a normal paragraph.' );

Related

Add-On Structure

Radio Fields

Image Fields

Nested Fields

Overview

Overview

The Advanced Custom Fields add-on for WP All Import makes it possible to import to ACF5/ACF Pro, or ACF4.

To import to Advanced Custom Fields, you must have one of the Advanced Custom Fields plugins linked to in the previous sentence installed, and the Advanced Custom Fields add-on for WP All Import installed. You can download the Advanced Custom Fields add-on for WP All Import from the customer portal.

Importing to Advanced Custom Fields is the same as importing to normal Custom Fields, except for repeater fields.

Here』s how it works:

Create your field group and add all of your fields via Advanced Custom Fields.Make sure our ACF Add-On is active.Start a new import – during Step 3, you』ll see the ACF fields associated with the post type that you』re importing:

ACF Example

Repeater Fields

Repeater Fields

Our ACF add-on for WP All Import provides 3 modes for importing to repeater fields. The option to use depends on the type of file you are using, as well as the way your data is structured.

Note: Importing data from several records into a repeater field for a single post is not supported. All of the data for a repeater field must be present in the same record.

So for example, while the data in the 「Sizes」 column in this file can be imported into a repeater field, due to the data being in the same record:

ACF Data Structure

The data in the 「Sizes」 column in this next file will not be imported as desired, since the data is spread out across several records:

Incorrect Data Structure

Depending on the import settings, either a separate post would be created for each row, or only the 「Large」 value will be present in the repeater field for 「Test Post」 (since the prior values that were imported would be overwritten).

Fixed Repeater Mode

Use Fixed Repeater Mode when each piece of your repeating data is stored in separate columns or elements. For example, if you have a repeater field containing an image, and your CSV file has 5 columns – image_1, image_2, image_3, etc:

Fixed Repeater File

Then you should use Fixed Repeater Mode. Manually add 5 rows to the repeater by clicking Add Row:

Fixed Repeater Add Row

And then drag & drop image_1 to the first row, image_2 to the second row, etc.

Check the 「Ignore blank fields」 box if some of the records in your file don』t contain values for all 5 images. For example, if image_3 and onwards are blank for a certain record, WP All Import will only add 2 rows to the repeater for that record.

Variable Repeater Mode (XML)

Use this option if your repeating data is stored in XML format as 「sibling」 elements, for example:

image1.jpg
image2.jpg
image3.jpg
image4.jpg
image5.jpg

Dragging & dropping won』t generate the correct XPath expressions when using Variable Repeater Mode (XML). You need to modify your XPath expressions as per WP All Import's FOREACH syntax.
In this video 「Variable Repeater Mode (XML)」 is used.
Variable Repeater Mode (CSV)
If your repeating data is stored in a single column in your CSV file, and is separated by a separator character, use this option.
For example, if you have a repeater field containing ingredients (Name and Measure – i.e. 1/2 cup is the measure and butter is the name), and the names & measures are stored in separate columns in your CSV file:
Variable Repeater CSV

Then use this option. Since this repeater data is comma separated, change the 「Separator Character」 setting from a pipe character to a comma, and drag & drop the Names & Measures columns into the appropriate sub-fields in the repeater field. The end result should look like this:

Variable Repeater Mode

When the data is imported, the first item in the Names column will be associated with the first item in the Measures column, the 2nd item in the Names column with the 2nd in the Measures column, etc.

Here are the Hooks Provided By WP All Import and WP All Export

Here are the Hooks Provided By WP All Import and WP All Export

Our Action Reference provides hooks that allow you to change how WP All Import processes data. After customizing the examples based on your needs, you can place them either in WP All Import's Function Editor or your theme's functions.php file.

Click Here for more information.

pmxi_saved_post

This action fires when WP All Import saves a post of any type. The post ID, the record's data from your file, and a boolean value showing if the post is being updated are provided.

Parameters

ParamTypeDescription$post_idintThe ID of the item (post/user/taxonomy) saved or updated.$xml_nodeSimpleXMLElementThe libxml resource of the current XML element.$is_updateboolReturns 0 for new item 1 for updated item.

Usage

function my_saved_post( $post_id, $xml_node, $is_update ) {

// Retrieve the import ID.
$import_id = ( isset( $_GET['id'] ) ? $_GET['id'] : ( isset( $_GET['import_id'] ) ? $_GET['import_id'] : 'new' ) );

// Only run for import 8.
if ( $import_id == '8' ) {

// Convert SimpleXml object to array for easier use.
$record = json_decode( json_encode( ( array ) $xml_node ), 1 );

// Do something.

}

}
add_action( 'pmxi_saved_post', 'my_saved_post', 10, 3 );

Search the docs for pmxi_saved_post to see real-world code snippets that use this filter.

pmxi_before_xml_import

This action fires before any records are imported. It's used to call code that validates the import file or other code that needs to run at the start. It's called regardless of import file type used.

Parameters

ParamTypeDescription$import_idintThe ID of the import that's about to run.

Usage

function before_xml_import( $import_id ) {

// Only Run for import ID 5.
if ($import_id == 5) {

}

}
add_action('pmxi_before_xml_import', 'before_xml_import', 10, 1);

Search the docs for pmxi_before_xml_import to see real-world code snippets that use this filter.

pmxi_after_xml_import

This action fires after at the end of each import. The import object contains the values configured for the import and statistics for the last run.

Parameters

ParamTypeDescription$import_idintThe ID of the import that's about to run.$importobjectThe import object.

Usage

function after_xml_import( $import_id, $import ) {
// Only run if import ID is 5.
if ($import_id == 5) { // Do something. }
}
add_action( 'pmxi_after_xml_import', 'after_xml_import', 10, 2 );

Search the docs for pmxi_after_xml_import to see real-world code snippets that use this filter.

pmxi_update_post_meta

This action fires when WP All Import creates or updates post meta (custom fields). The post ID, field name, and field value are provided.

Parameters

ParamTypeDescription$post_idintThe ID of the imported item.$meta_keystring The name/key of the field that's being saved. $meta_valuemixed The value imported into the field.

Usage

function my_update_post_meta( $post_id, $meta_key, $meta_value) {

// Do something.

}

add_action( 'pmxi_update_post_meta', 'my_update_post_meta', 10, 3 );

Search the docs for pmxi_update_post_meta to see real-world code snippets that use this filter.

pmxi_gallery_image

This action fires each time an image is imported. It provides the post ID, image attachment ID, and image filepath as parameters. Whether or not existing images are deleted before new ones are imported is also indicated.

Parameters

ParamTypeDescription$post_idintThe ID of the imported item.$att_idintThe ID of the image that was imported.$filepathstringThe local file path to the full size image.$is_keep_existing_imagesbool/emptyReturns 1 if keeping existing images. Always cast as empty in the function arguments.

Usage

function wpai_image_imported( $post_id, $att_id, $filepath, $is_keep_existing_images = '' ) {

// Do something.

}
add_action( 'pmxi_gallery_image', 'wpai_image_imported', 10, 4 );

Search the docs for pmxi_gallery_image to see real-world code snippets that use this filter.

pmxi_attachment_uploaded

This action fires when an attachment is uploaded. It provides the post ID, attachment ID, and attachment file path. If you need to work with images use pmxi_gallery_image.

Parameters

ParamTypeDescription$post_idintThe post ID that's being imported.$att_idintThe attachment ID.$filepathstringThe full path to the file: C:pathtowordpresswp-contentuploads20105filename.png

Usage

function my_attachment_uploaded($pid, $attid, $filepath){
$attachment = get_post($attid);
// Do something with $attachment.
}add_action('pmxi_attachment_uploaded', 'my_attachment_uploaded', 10, 3);

Search the docs for pmxi_attachment_uploaded to see real-world code snippets that use this filter.

wp_all_import_is_post_to_update

This filter is used to determine if a post should be updated or skipped. It takes the post ID and, optionally, an array of XML nodes. The returned value should be either true to update the post or false to skip it.

Parameters

ParamTypeDescription$continuebooltrue to update, false to skip.$post_idintThe Post ID that's about to be updated.$xml_nodearrayAn array containing the data for the current import record.$import_idintThe ID of the import that's running.

Usage

function my_is_post_to_update( $continue, $post_id, $xml_node, $import_id ) {
// Run this code on a specific import
if ($import_id === 5) {
// Do something to decide if this post should update
if ( ... ) {
return true;
}
// Don't update this post
return false;
}
}

add_filter( 'wp_all_import_is_post_to_update', 'my_is_post_to_update', 10, 4 );

Search the docs for wp_all_import_is_post_to_update to see real-world code snippets that use this filter.

pmxi_acf_custom_field

This filter allows the modification of ACF field values. Only fields set to be updated or created during the import will fire this hook.

Parameters

ParamTypeDescription$valuemixedThe value being imported to the ACF field.$post_idintThe Post ID that's being imported.$namestringThe ACF field name.

Usage

function wp_all_import_pmxi_acf_custom_field( $value, $pid, $name ) {
// Code here.
}add_filter( 'pmxi_acf_custom_field', 'wp_all_import_pmxi_acf_custom_field', 10, 3 );

Search the docs for pmxi_acf_custom_field to see real-world code snippets that use this filter.

pmxi_after_post_import

This action fires after each imported post. If you need post IDs you should use pmxi_saved_post.

Parameters

ParamTypeDescription$import_idintThe import ID that's running.

Usage

function my_after_post_import($import_id)
{
// Only run for import ID 5.
if ($import_id === 5) { // Do something.
}
}
add_action('pmxi_after_post_import', 'my_after_post_import', 10, 1);

Search the docs for pmxi_after_post_import to see real-world code snippets that use this filter.

pmxi_article_data

This filter allows updating core post fields before each post is imported. When updating, $post_to_update contains the current post's WP_Post object. The current file record's data is in $current_xml_node.

Parameters

ParamTypeDescription$articleDataarrayCurrent article data.$importobjectThe import object.$post_to_updateobjectPost object for the post that's being updated.$current_xml_nodearrayParsed data for the current import record.

Here are the fields available for modification in the $articleData array:

array(15) { ["post_type"]=>string ["post_status"]=>string ["comment_status"]=>string ["ping_status"]=>string ["post_title"]=>string ["post_excerpt"]=>string ["post_name"]=>string ["post_content"]=>string ["post_date"]=>string ["post_date_gmt"]=>string ["post_author"]=>int ["menu_order"]=>int ["post_parent"]=>int ["page_template"]=>string ["ID"]=>string }

Usage

function my_pmxi_article_data( $articleData, $import, $post_to_update, $current_xml_node ) {
// Do something with the article data.
return $articleData;
}
add_filter('pmxi_article_data', 'my_pmxi_article_data', 10, 4);

Search the docs for pmxi_article_data to see real-world code snippets that use this filter.

pmxi_before_delete_post

This action fires just before WP All Import deletes a post. The post ID and import object are provided as parameters.

Parameters

ParamTypeDescription$post_idintThe post ID that's about to be deleted.$importobjectThe import object.

Usage

function before_delete_post( $post_id, $import ) {

// do something before post is deleted

}

add_action('pmxi_before_delete_post', 'before_delete_post', 10, 2);

Search the docs for pmxi_before_delete_post to see real-world code snippets that use this filter.

pmxi_custom_field

This filter first before a custom field's value is saved. If the field is being updated the $original_value is provided. The $value is provided and must be returned. The field's name, $key, and the post being updated, $post_id, are available.

Parameters

ParamTypeDescription$valuestringThe value being imported into the custom field.$post_idintThe post ID.$keystringThe custom field key.$original_valuestringOriginal, unserialized, value.$existing_meta_keysarrayExisting meta keys.$import_idintThe import ID that's running.

Usage

function my_custom_field( $value, $post_id, $key, $original_value, $existing_meta_keys, $import_id ) {

// Only run for import ID 5.
if ($import_id === 5) {

// Only modify the 'myField' custom field for post 65.
if( $key == 'myField' && $post_id == 65 ){

// Do something.

}

}

// Return the value for the custom field.
return $value;
}

add_filter( 'pmxi_custom_field', 'my_custom_field', 10, 6 );

Search the docs for pmxi_custom_field to see real-world code snippets that use this filter.

pmxi_delete_post

This action fires just before posts are deleted at the end of an import when using the 'Delete products that are no longer present in your file' option. It allows performing actions on the posts immediately before they are deleted. The list of post IDs to be deleted and the import object are provided.

Parameters

ParamTypeDescription$idsarrayArray of post IDs that will be deleted.$importobjectThe import object.

Usage

function wpai_pmxi_delete_post( $ids = array(), $import ){

foreach( $ids as $pid ) {

// do something with post using ID - $pid

}
}
add_action( 'pmxi_delete_post', 'wpai_pmxi_delete_post', 10, 2 );

Search the docs for pmxi_delete_post to see real-world code snippets that use this filter.

pmxi_single_category

This filter fires before taxonomy terms are imported and can be used to filter them. An array containing the term information and the taxonomy name are provided.

Parameters

ParamTypeDescription$term_intoarrayArray with term information.$tax_namestringThe taxonomy name.

Here is the $term_into array:

Array
(
[name] => {string}
[parent] => {int or empty if none}
[assign] => {bool}
[is_mapping] => {1 if true, empty if false}
[hierarchy_level] => {int}
[max_hierarchy_level] => {int}
)

Usage

function wpai_pmxi_single_category( $term_into, $tax_name ) {

// Do something.

// Return the updated term information.
return $term_into;

}

add_filter( 'pmxi_single_category', 'wpai_pmxi_single_category', 10, 2 );

Search the docs for pmxi_single_category to see real-world code snippets that use this filter.

wp_all_import_attachments_uploads_dir

DescriptionCan be used to change the directory that imported attachments are saved to.

Parameters

ParamTypeDescription$uploadsarrayContains information related to the WordPress uploads path & URL.$articleDataarrayContains a list of data related to the post/user/taxonomy being imported.$current_xml_nodearrayArray of data for current import record.$import_idintThe import ID that's running.

Usage

add_filter( 'wp_all_import_attachments_uploads_dir', 'wpai_wp_all_import_attachments_uploads_dir', 10, 4 );
function wpai_wp_all_import_attachments_uploads_dir( $uploads, $articleData, $current_xml_node, $import_id ) {
return $uploads;
}

Search the docs for wp_all_import_attachments_uploads_dir to see real-world code snippets that use this hook.

wp_all_import_auto_create_csv_headers

DescriptionAuto generate headers, or use headers in file.

You cannot call this hook from WP All Import's Function Editor. It must be saved in a plugin or in your theme.

Parameters

ParamTypeDescription$create_headersboolAuto-generate headers? true / false.$import_idintThe import ID that's running.

Usage

add_filter( 'wp_all_import_auto_create_csv_headers', 'wpai_wp_all_import_auto_create_csv_headers', 10, 2 );
function wpai_wp_all_import_auto_create_csv_headers( $create_headers, $import_id ){
// Return true to auto-generate header, or false to use the header in the file.
return $create_headers;
}

Search the docs for wp_all_import_auto_create_csv_headers to see real-world code snippets that use this hook.

wp_all_import_copy_uploaded_file_into_files_folder

DescriptionReturn TRUE and WP All Import will copy uploaded import file into /wp-content/uploads/wpallimport/files folder.

Parameters

ParamTypeDescription$copy_uploaded_filesboolCopy file? true / false.

Usage

function wpai_wp_all_import_copy_uploaded_file_into_files_folder( $copy_uploaded_files ) {
return $copy_uploaded_files;
}
add_filter( 'wp_all_import_copy_uploaded_file_into_files_folder', 'wpai_wp_all_import_copy_uploaded_file_into_files_folder', 10, 1 );

Search the docs for wp_all_import_copy_uploaded_file_into_files_folder to see real-world code snippets that use this hook.

wp_all_import_curl_download_only

DescriptionForce WP All Import to download the feed on the first request (skips reading headers). Useful if feeds reject multiple pings/requests.

This code must be added in a plugin or your theme. It will not work in WP All Import's Function Editor.

Parameters

ParamTypeDescription$download_onlyboolOnly download via curl? true / false.

Usage

add_filter( 'wp_all_import_curl_download_only', 'wpai_wp_all_import_curl_download_only', 10, 1 );

function wpai_wp_all_import_curl_download_only( $download_only ){
return true;
}

Search the docs for wp_all_import_curl_download_only to see real-world code snippets that use this hook.

wp_all_import_feed_type

DescriptionCan be used to define the feed type (xml/csv/json/etc).

This code must be added in a plugin or your theme. It will not work in WP All Import's Function Editor.

Parameters

ParamTypeDescription$typestringThe feed type.$urlstringThe URL that's being imported.

Usage

add_filter( 'wp_all_import_feed_type', 'wpai_feed_type', 10, 2 );
function wpai_feed_type( $type, $url ){
// Check $url and return $type.
return $type;
}

Search the docs for wp_all_import_feed_type to see real-world code snippets that use this hook.

wp_all_import_get_image_from_gallery

DescriptionCalled after an existing image is found in the Media Library. Only works with the "Use images currently in Media Library" and "Use images currently uploaded in wp-content/uploads/wpallimport/files/" options.

Parameters

ParamTypeDescription$attachobjectThe existing image that will be attached.$image_namestringThe image name that will be imported.$targetDirstringThe directory that the image will be uploaded to.

Usage

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
}

Search the docs for wp_all_import_get_image_from_gallery to see real-world code snippets that use this hook.

wp_all_import_handle_upload

DescriptionFilters the data array for attachments & images uploaded through WP All Import.

Parameters

ParamTypeDescription$filearrayContains the filepath, URL & filetype

Usage

add_filter( 'wp_all_import_handle_upload', 'wpai_wp_all_import_handle_upload', 10, 1 );
function wpai_wp_all_import_handle_upload( $file ){
// Handle & return $file here.
}

Search the docs for wp_all_import_handle_upload to see real-world code snippets that use this hook.

wp_all_import_image_filename

DescriptionCan be used to set a custom filename for an imported image.

Parameters

ParamTypeDescription$filenamestringThe filename as created by the import.$img_titlestringFrom "SEO and advanced options". Will always be blank for ACF fields.$img_captionstringFrom "SEO and advanced options". Will always be blank for ACF fields.$img_altstringFrom "SEO and advanced options". Will always be blank for ACF fields.$articleDataarrayArray of current import item data.$import_idintThe import ID.$img_urlstringThe image URL.

Usage

function wpai_image_filename( $filename = '', $img_title = '', $img_caption = '', $img_alt = '', $articleData = '', $import_id = '', $img_url = '' ) {
// Your code
return $filename;
}
add_filter( 'wp_all_import_image_filename', 'wpai_image_filename', 10, 7 );

Search the docs for wp_all_import_image_filename to see real-world code snippets that use this hook.

wp_all_import_images_uploads_dir

DescriptionCan be used to set a custom path in which images (as well as media intended for ACF fields) are uploaded. Only applies to media uploaded via WP All Import.

Parameters

ParamTypeDescription$uploadsarrayContains information related to the WordPress uploads path & URL$articleDataarrayContains a list of data related to the post/user/taxonomy being imported$current_xml_nodearrayContains a list of nodes within the current import record$import_idintContains the ID of the import.

Usage

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 ) {
// Do something with code here.
return $uploads;
}

Search the docs for wp_all_import_images_uploads_dir to see real-world code snippets that use this hook.

wp_all_import_is_check_duplicates

DescriptionTurn duplicate checking on/off. If you turn it off, WP All Import will create duplicate items each re-run.

Parameters

ParamTypeDescription$is_check_duplicatesboolCheck for duplicates? true / false.$import_idintThe import ID.

Usage

add_filter( 'wp_all_import_is_check_duplicates', 'wpai_is_check_duplicates', 10, 2 );

function wpai_is_check_duplicates( $is_check_duplicates, $import_id ) {
// Cancel checking for duplicates if this is import ID 10.
return ( $import_id == 10 ) ? false : true;
}

Search the docs for wp_all_import_is_check_duplicates to see real-world code snippets that use this hook.

wp_all_import_is_php_allowed

DescriptionDetermine whether PHP functions in the import template will be executed.

Parameters

ParamTypeDescription$is_php_allowedboolExecute functions? true / false.

Usage

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

Search the docs for wp_all_import_is_php_allowed to see real-world code snippets that use this hook.

wp_all_import_is_post_to_create

DescriptionThis filter is used to determine if a post should be created or skipped. The returned value should be either true to create the post or false to skip it.

Parameters

ParamTypeDescription$continue_importboolCreate post? true / false.$dataarrayAn array holding values for the current record. If importing from XML, attributes can be accessed as SimpleXMLElement objects.$import_idintThe import ID.

Usage

function my_is_post_to_create( $continue_import, $data, $import_id ) {
// Unless you want this code to execute for every import, check the import id
// if ($import_id === 5) { ... }
return true;
}
add_filter( 'wp_all_import_is_post_to_create', 'my_is_post_to_create', 10, 3 );

Search the docs for wp_all_import_is_post_to_create to see real-world code snippets that use this hook.

wp_all_import_is_post_to_delete

DescriptionThis fires when a missing post is about to be deleted by an import.

Parameters

ParamTypeDescription$is_post_to_deleteboolDelete post? true / false.$post_idintThe post ID that's about to be deleted.$importobjectThe import object.

Usage

function my_is_post_to_delete( $is_post_to_delete, $post_id, $import ) {
// Unless you want this code to execute for every import, check the import id
// if ( $import->id == 5 ) { ... }
return true;
}
add_filter( 'wp_all_import_is_post_to_delete', 'my_is_post_to_delete', 10, 3 );

Search the docs for wp_all_import_is_post_to_delete to see real-world code snippets that use this hook.

wp_all_import_is_unlink_missing_posts

DescriptionUsed to completely remove the relationship between import and post from pmxi_posts database table.

Parameters

ParamTypeDescription$is_unlink_missingboolUnlink post? true / false.$import_idintThe import ID.$post_idintThe post ID.

Usage

add_filter( 'wp_all_import_is_unlink_missing_posts', 'wpai_wp_all_import_is_unlink_missing_posts', 10, 3 );

function wpai_wp_all_import_is_unlink_missing_posts( $is_unlink_missing, $import_id, $post_id ) {
// Do something with code here.
return $is_unlink_missing;
}

Search the docs for wp_all_import_is_unlink_missing_posts to see real-world code snippets that use this hook.

wp_all_import_multi_glue

DescriptionChange the delimiter used when querying multiple values with XPath (default is ", "). Learn about XPath queries here: XPath Queries.

Parameters

ParamTypeDescription$delimiterstringThe delimiter.

Usage

add_filter( 'wp_all_import_multi_glue', 'wpai_wp_all_import_multi_glue', 10, 1 );
function wpai_wp_all_import_multi_glue( $delimiter ) {
// change delimiter if you want.
// e.g.:
// $delimiter = '|';
return $delimiter;
}

Search the docs for wp_all_import_multi_glue to see real-world code snippets that use this hook.

wp_all_import_phpexcel_object

DescriptionAccess/modify the PHPExcel object and file path for the import file.

Parameters

ParamTypeDescription$PHPExcelobjectThe PHPExcel object.$xlsFilePathstringThe path to the import file.

Usage

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;
}

Search the docs for wp_all_import_phpexcel_object to see real-world code snippets that use this hook.

wp_all_import_search_image_by_wp_attached_file

DescriptionCan be used to stop WP All Import from looking for existing images via _wp_attached_file.

Parameters

ParamTypeDescription$is_search_by_wp_attached_fileboolLook in _wp_attached_file? true / false.

Usage

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 ) {
// do something with code here
return $is_search_by_wp_attached_file;
}

Search the docs for wp_all_import_search_image_by_wp_attached_file to see real-world code snippets that use this hook.

wp_all_import_set_post_terms

DescriptionCalled when WP All Import is setting the post taxonomy terms.

Parameters

ParamTypeDescription$term_taxonomy_idsarrayArray of taxonomy IDs.$tx_namestringThe name of the taxonomy.$pidintThe post ID.$import_idintThe import ID.

Usage

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( $term_taxonomy_ids, $tx_name, $pid, $import_id ) {
// Code here.
return $term_taxonomy_ids;
}

Search the docs for wp_all_import_set_post_terms to see real-world code snippets that use this hook.

wp_all_import_skip_x_csv_rows

DescriptionSpecifies the amount of rows to be skipped. You must use this hook in a plugin or your theme, not in WP All Import's Function Editor.

Parameters

ParamTypeDescription$skip_rowsbool/intReturn false to not skip rows. Return integer to specify how many rows to skip.$import_idintThe import ID.

Usage

add_filter( 'wp_all_import_skip_x_csv_rows', 'wpai_skip_rows', 10, 2 );

function wpai_skip_rows( $skip_rows, $import_id ) {
// Handle & return $skip_rows here.
}

Search the docs for wp_all_import_skip_x_csv_rows to see real-world code snippets that use this hook.

wp_all_import_specified_records

DescriptionUse this to override the specified records to be imported. It's a comma separated list of ints or int ranges. e.g. "1-7,10,15-20". The integers represent the position in the data file.

Parameters

ParamTypeDescription$specified_recordsstringThe current value from the "Import only specified records" option.$import_idintThe import ID.$root_nodes???

Usage

function my_specified_records( $specified_records, $import_id, $root_nodes ) {
// Unless you want this code to execute for every import, check the import id
// if ($import_id === 5) { ... }
// your code here
return $specified_records;
}

add_filter( 'wp_all_import_specified_records', 'my_specified_records', 10, 3 );

Search the docs for wp_all_import_specified_records to see real-world code snippets that use this hook.

wp_all_import_use_wp_set_object_terms

DescriptionForce WP All Import to use the wp_set_object_terms() WordPress function. Using this function is a bit slower, but it's sometimes necessary for compatibility with certain themes and plugins.

Parameters

ParamTypeDescription$use_wp_set_object_termsboolReturn true to use WordPress function wp_set_object_terms(). Return false to use pure SQL.$tx_namestringThe taxonomy name.

Usage

function wpai_wp_all_import_use_wp_set_object_terms( $use_wp_set_object_terms, $tx_name ) {
return $use_wp_set_object_terms;
}

add_filter( 'wp_all_import_use_wp_set_object_terms', 'wpai_wp_all_import_use_wp_set_object_terms', 10, 2 );

Search the docs for wp_all_import_use_wp_set_object_terms to see real-world code snippets that use this hook.

wpallimport_after_images_import

DescriptionCalled after the images section of the import is processed, but only when the "Keep images currently in Media Library" option is enabled.

Parameters

ParamTypeDescription$post_idintThe post ID.$gallery_attachment_idsarrayAn array of the images that were imported to the post.$missing_imagesarrayAn array of the images that were missing, based on previous imports.

Usage

function soflyy_img_import( $post_id, $gallery_attachment_ids, $missing_images ) {
// do something
}

add_action( 'wpallimport_after_images_import', 'soflyy_img_import', 10, 3 );

Search the docs for wpallimport_after_images_import to see real-world code snippets that use this hook.

wpallimport_xml_row

DescriptionAllows reading or modification of the data record before importing. All file types (CSV/JSON/XLS/XLSX/TXT/etc) are converted to XML, so this hook works with all of them.

Please note that XML nodes generated by this hook can't be used in "FOREACH" ACF Repeater fields.

Parameters

ParamTypeDescription$xml_nodelibxml resourceSimpleXMLElement containing the current records data.

Usage

function wpai_xml_row( $xml_node ) {
// Modify simpleXML object as needed
return $xml_node;
}
add_filter( 'wpallimport_xml_row', 'wpai_xml_row', 10, 1 );

Search the docs for wpallimport_xml_row to see real-world code snippets that use this hook.

pmxi_product_variation_saved

This action fires each time WP All Import save a product variation. The variation's ID is provided.

Parameters

ParamTypeDescription$variation_idintThe variation ID.

Usage

function wpai_wp_all_import_variation_imported( $variation_id ){

// Do something.

}

add_action( 'pmxi_product_variation_saved', 'wpai_wp_all_import_variation_imported', 10, 1 );

Search the docs for pmxi_product_variation_saved to see real-world code snippets that use this filter.

wp_all_import_get_prices_from_first_variation

DescriptionCan be used to set the parent product price to the price of the first variation in the case that WP All Import converts the product to a simple product.

Parameters

ParamTypeDescription$get_prices_from_first_variationboolSet parent product price to first variation price? true / false.$product_idintThe product ID.$import_idintThe import ID.

Usage

function wpai_wp_all_import_get_prices_from_first_variation( $get_prices_from_first_variation, $product_id, $import_id ) {
// do something
return $get_prices_from_first_variation;
}

add_filter( 'wp_all_import_get_prices_from_first_variation', 'wpai_wp_all_import_get_prices_from_first_variation', 10, 3 );

Search the docs for wp_all_import_get_prices_from_first_variation to see real-world code snippets that use this hook.

wp_all_import_make_product_simple

DescriptionCalled after a product is converted into a Simple Product by our WooCommerce Add-On. This only happens when the "Create products with no variations as simple product" option is enabled.

Parameters

ParamTypeDescription$product_idintThe product ID.$import_idintThe import ID.

Usage

function wpai_wp_all_import_make_product_simple( $product_id, $import_id ) {
// Code here.
}

add_action( 'wp_all_import_make_product_simple', 'wpai_wp_all_import_make_product_simple', 10, 2 );

Search the docs for wp_all_import_make_product_simple to see real-world code snippets that use this hook.

wp_all_import_product_attributes_delimiter

DescriptionModify the delimiter used to separate multiple attributes in the WooCommerce Add-On. Default is the pipe symbol "|".

Parameters

ParamTypeDescription$delimiterstringDefault is "|".$product_idintThe product ID.$import_idintThe import ID.

Usage

function wpai_wp_all_import_product_attributes_delimiter( $delimiter, $product_id, $import_id ) {
return $delimiter;
}

add_filter( 'wp_all_import_product_attributes_delimiter', 'wpai_wp_all_import_product_attributes_delimiter', 10, 3 );

Search the docs for wp_all_import_product_attributes_delimiter to see real-world code snippets that use this hook.

wp_all_import_variable_product_imported

DescriptionCalled when WP All Import saves a variable product

Parameters

ParamTypeDescription$product_idintThe product ID.

Usage

add_action( 'wp_all_import_variable_product_imported', 'wpai_wp_all_import_variable_product_imported', 10, 1 );

function wpai_wp_all_import_variable_product_imported( $post_parent ) {
// Code here.
}

Search the docs for wp_all_import_variable_product_imported to see real-world code snippets that use this hook.

wp_all_import_variation_any_attribute

DescriptionReturn true to set variation as "Any" in the case that multiple attribute values are present (e.g.: L|XL|XXL).

Parameters

ParamTypeDescription$variation_any_attributeboolSet variation to "Any"? true / false.$import_idintThe import ID.

Usage

function wpai_wp_all_import_variation_any_attribute( $variation_any_attribute, $import_id ) {
return $variation_any_attribute;
}

add_filter( 'wp_all_import_variation_any_attribute', 'wpai_wp_all_import_variation_any_attribute', 10, 2 );

Search the docs for wp_all_import_variation_any_attribute to see real-world code snippets that use this hook.

wp_all_import_variation_taxonomies

DescriptionCan be used to add taxonomies to WooCommerce product variations, which isn't supported by WooCommerce out of the box.

Parameters

ParamTypeDescription$taxonomiesarrayList of taxonomies.

Usage

add_filter( 'wp_all_import_variation_taxonomies', 'wpai_wp_all_import_variation_taxonomies', 10, 1 );

function wpai_wp_all_import_variation_taxonomies( $taxonomies ){
if ( ! in_array( 'my_taxonomy_name', $taxonomies ) ) $taxonomies[] = 'my_taxonomy_name';
return $taxonomies;
}

Search the docs for wp_all_import_variation_taxonomies to see real-world code snippets that use this hook.

pmxe_after_export

This action is used to run code after the export has completed. It provides the export ID and an object containing stats, settings, data, etc for the export.

Parameters

ParamTypeDescription$export_idintThe export ID.$exportObjobjectThe export object.

Usage

function wp_all_export_after_export( $export_id, $exportObj ) {
// Run for export 5 only
if ( $export_id === 5 ) {
        // Do something
}
}
add_action( 'pmxe_after_export', 'wp_all_export_after_export', 10, 2 );

Search the docs for pmxe_after_export to see real-world code snippets that use this filter.

pmxe_after_iteration

This action fires after each iteration only when running via cron. It provides the export ID and an object containing stats, settings, data, etc for the export.

Parameters

ParamTypeDescription$export_idintThe export ID.$exportObjobjectThe export object.

Usage

function wpae_continue_cron( $export_id, $exportObj ) {
// Run this for a specific export
if ($export_id === 5) { // Do something }
} add_action( 'pmxe_after_iteration', 'wpae_continue_cron', 10, 2 );

Search the docs for pmxe_after_iteration to see real-world code snippets that use this filter.

pmxe_before_export

This action runs at the start of an export before any data is processed. It provides the export ID and must be called outside of the Function Editor - such as from your theme's functions.php file.

Parameters

ParamTypeDescription$export_idintThe export ID.

Usage

function wp_all_export_before_export( $export_id ) {
// Run this for a specific export.
if ($export_id === 5) { // Do something.
}
} add_action( 'pmxe_before_export', 'wp_all_export_before_export', 10, 1 );

Search the docs for pmxe_before_export to see real-world code snippets that use this filter.

pmxe_exported_post

This action fires after each record is saved to the export file. It provides the post ID and an object containing stats, settings, data, etc for the export.

Parameters

ParamTypeDescription$post_idintThe post ID.$exportObjobjectThe export object.

Usage

function wpae_pmxe_exported_post( $post_id, $exportObject ) { // Only run for a certain post.
if( $post_id == 55 ){ // Do something.
}}
add_action('pmxe_exported_post', 'wpae_pmxe_exported_post', 10, 2);

Search the docs for pmxe_exported_post to see real-world code snippets that use this filter.

pmxe_woo_field

This filter allows WooCommerce field values to be modified as they're exported. It provides the field's value, name, and the post ID. You must return the value as a string.

Parameters

ParamTypeDescription$valuemixedThe value of the field.$field_namestringThe field name.$pidintThe post ID.

Usage

function wp_all_export_woo_field( $value, $field_name, $pid ) { if( $field_name == '_a_field' ){
// Generate the new value
return $new_value; } else { return $value; }
}add_filter( 'pmxe_woo_field', 'wp_all_export_woo_field', 10, 3 );

Search the docs for pmxe_woo_field to see real-world code snippets that use this filter.

wp_all_export_additional_data

This filter only fires when Simple XML Feed exports run. It does nothing for any other export type. Any additional fields currently added will be in the $add_data parameter. The $options parameter contains the full export configuration. The export ID is provided in the last parameter.

Parameters

ParamTypeDescription$add_dataarrayAny additional data to add, empty by default.$optionsarrayExport options array containing the export's configuration.$export_idintID of the running export.

Usage

function wpae_additional_data( $add_data, $options, $export_id ) {

// Add data as needed.

// Return the updated data array.
return $add_data;

}

add_filter( 'wp_all_export_additional_data', 'wpae_additional_data', 10, 2 );

Search the docs for wp_all_export_additional_data to see real-world code snippets that use this filter.

wp_all_export_after_csv_line

This filter fires after each CSV line and provides the file resource handle so that additional characters can be added. The second parameter provides the export ID.

Parameters

ParamTypeDescription$streamfile system pointer resourceThe resource handle pointing to the export file.$export_idintThe export ID.

Usage

function wpae_wp_all_export_after_csv_line( $stream, $export_id ){

// Do something.

return $stream;

}

add_filter( 'wp_all_export_after_csv_line', 'wpae_wp_all_export_after_csv_line', 10, 2 );

Search the docs for wp_all_export_after_csv_line to see real-world code snippets that use this filter.

wp_all_export_config_options

This filter fires during exports and was specifically added to allow changing the max_execution_time and max_input_time values. The other options are listed below but should not be modified with the filter.

Parameters

ParamTypeDescription$optionsarrayExport configuration options.

Option array values:

Array
(
[info_api_url] => http://www.wpallimport.com
[scheduling_license] => {hashed string}
[scheduling_license_status] => {status string}
[dismiss] => 0
[dismiss_manage_top] => 0
[dismiss_manage_bottom] => 0
[cron_job_key] => {string}
[max_input_time] => -1
[max_execution_time] => -1
[secure] => 1
[license] => {hashed string}
[license_status] => {status string}
[zapier_api_key] => {string}
[zapier_invitation_url] =>
[zapier_invitation_url_received] =>
)

Usage

function wpai_wp_all_import_config_options( $options ) {

// Do something.

return $options;

}

add_filter( 'wp_all_export_config_options', 'wpai_wp_all_import_config_options', 10, 1 );

Search the docs for wp_all_export_config_options to see real-world code snippets that use this filter.

wp_all_export_csv_headers

DescriptionManipulate export file headers.

Parameters

ParamTypeDescription$headersarrayCurrent headers.$export_idintThe export ID.

Usage

add_filter( 'wp_all_export_csv_headers', 'wpae_wp_all_export_csv_headers', 10, 2 );

function wpae_wp_all_export_csv_headers( $headers, $export_id ) {
// Code here.
return $headers;
}

Search the docs for wp_all_export_csv_headers to see real-world code snippets that use this hook.

wp_all_export_csv_rows

DescriptionFilters the records to export. This is for CSV formatted exports only. See 'wp_all_export_xml_rows' for filtering XML exports.

Parameters

ParamTypeDescription$articlesarrayAn array of records for exporting. Each article is keyed by the column header name for that field.$optionsarrayThe export configuration options.$export_idintThe export ID.

Usage

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["Title"] == "Something") {
// unset($articles[$key]);
// }
// }
return $articles; // Return the array of records to export
}
add_filter( 'wp_all_export_csv_rows', 'wp_all_export_csv_rows', 10, 3 );

Search the docs for wp_all_export_csv_rows to see real-world code snippets that use this hook.

wp_all_export_export_file_name

DescriptionFilter to change the filename of the exported data file

Parameters

ParamTypeDescription$file_path stringThe file path, including the filename.$export_id intThe export ID.

Usage

function wpae_wp_all_export_export_file_name( $file_path, $export_id ){
// Unless you want your code to execute for every export, be sure to check the export id
// if ($export_id === 5) { ... }

return $file_path;
}

add_filter( 'wp_all_export_export_file_name', 'wpae_wp_all_export_export_file_name', 10, 2 );

Search the docs for wp_all_export_export_file_name to see real-world code snippets that use this hook.

wp_all_export_generate_bundle

DescriptionDetermine whether the bundle zip file should be generated.

Parameters

ParamTypeDescription$is_generate_bundle boolGenerate bundle? true / false.

Usage

add_filter( 'wp_all_export_generate_bundle', 'wpae_do_not_generate_bundle', 10, 1 );
function wpae_do_not_generate_bundle( $is_generate_bundle ) {
return $is_generate_bundle ;
}

Search the docs for wp_all_export_generate_bundle to see real-world code snippets that use this hook.

wp_all_export_implode_delimiter

DescriptionModify the implode delimiter for export fields. Default delimiter is the pipe symbol "|".

Parameters

ParamTypeDescription$implode_delimiterstringThe delimiter to be used. Default is "|".$export_idintThe export ID.

Usage

function wpae_wp_all_export_implode_delimiter( $implode_delimiter, $export_id ) {
// do something
return $implode_delimiter;
}

add_filter( 'wp_all_export_implode_delimiter', 'wpae_wp_all_export_implode_delimiter', 10, 2 );

Search the docs for wp_all_export_implode_delimiter to see real-world code snippets that use this hook.

wp_all_export_is_csv_headers_enabled

DescriptionCan be used to completely remove the CSV header.

Parameters

ParamTypeDescription$is_headers_enabled boolKeep headers? true / false.$export_idintThe export ID.

Usage

add_filter( 'wp_all_export_is_csv_headers_enabled', 'wpae_wp_all_export_is_csv_headers_enabled', 10, 2 );

function wpae_wp_all_export_is_csv_headers_enabled( $is_headers_enabled, $export_id ){
// return 'false' to remove the header.
return $is_headers_enabled;
}

Search the docs for wp_all_export_is_csv_headers_enabled to see real-world code snippets that use this hook.

wp_all_export_order_item

DescriptionFilters the items in a WooCommerce Order to export.

Parameters

ParamTypeDescription$is_export_recordboolInclude item in export? true / false.$product_idintThe product ID.$export_optionsarrayThe export options array.$export_idintThe export ID.

Usage

function filter_my_order_items ( $is_export_record, $product_id, $export_options, $export_id ) {
// Unless you want this to execute for every export you should check the id here:
// if ( $export_id === 5 ) {
// Your code here
return true;
}
add_filter( "wp_all_export_order_item", "filter_my_order_items", 10, 4 );

Search the docs for wp_all_export_order_item to see real-world code snippets that use this hook.

wp_all_export_pre_csv_headers

DescriptionAllows for CSV headers to be added above the default headers.

Parameters

ParamTypeDescription$preCsvHeadersbool / stringThe headers to add to the file. Default false.$export_idintThe export ID.

Usage

add_filter( 'wp_all_export_pre_csv_headers', 'export_add_headers', 10, 2 );

function export_add_headers ( $preCsvHeaders, $exportId ) {
// Modify & return $preCsvHeaders
return $preCsvHeaders;
}

Search the docs for wp_all_export_pre_csv_headers to see real-world code snippets that use this hook.

wp_all_export_product_variation_mode

DescriptionChoose whether to export parent products or just variations.

Parameters

ParamTypeDescription$exportVariationMode stringExport variation mode.$export_idintThe export ID.

Usage

add_filter( 'wp_all_export_product_variation_mode', 'export_only_variations', 10, 2 );
function export_only_variations( $exportVariationMode, $exportID ) {
return XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION; // Only export variations for variable products, don't export the parent products
}

Search the docs for wp_all_export_product_variation_mode to see real-world code snippets that use this hook.

wp_all_export_raw_prices

DescriptionCan be used to disable price formatting for WooCommerce exports.

Parameters

ParamTypeDescription$raw_pricesboolDisable price formatting? true / false.

Usage

add_filter( 'wp_all_export_raw_prices', 'my_disable_formatting', 10, 1 );

function my_disable_formatting( $raw_prices ) {
// do something
return $raw_prices;
}

Search the docs for wp_all_export_raw_prices to see real-world code snippets that use this hook.

wp_all_export_repeater_delimiter

DescriptionDefine the delimiter used for ACF Repeater fields. Default is comma.

Parameters

ParamTypeDescription$implode_delimiterstringThe delimiter to use. Default ",".$export_idintThe export ID.

Usage

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 $implode_delimiter;
}

Search the docs for wp_all_export_repeater_delimiter to see real-world code snippets that use this hook.

wp_all_export_use_csv_compliant_line_endings

DescriptionUse custom CSV writer when affected by https://bugs.php.net/bug.php?id=43225.

Parameters

ParamTypeDescription$use_compliant_endingsboolUse compliant endings? true / false.

Usage

add_filter( 'wp_all_export_csv_strategy', function( $csvStrategy ) {
return WpaeCsvCsvWriter::CSV_STRATEGY_CUSTOM;
}, 10, 1 );
add_filter( 'wp_all_export_use_csv_compliant_line_endings', function( $useCsvCompliantLineEndings ) {
return true;
}, 10, 1 );

Search the docs for wp_all_export_use_csv_compliant_line_endings to see real-world code snippets that use this hook.

wp_all_export_xml_rows

DescriptionFilter a single XML record for conditional export. See wp_all_export_csv_rows for CSV exports.

Parameters

ParamTypeDescription$is_export_recordboolInclude record in export? true / false.$recordobjectRecord object.$export_optionsarrayThe export options.$export_idintThe export ID.

Usage

function my_wp_all_export_xml_rows( $is_export_record, $record, $export_options, $export_id ) {
// Unless you want this code to execute for every export, be sure to check the export id
//
// if ( $export_id == 5 ) { ...
// Check $record object and return true to export or false to skip
return true;
}
add_filter( 'wp_all_export_xml_rows', 'my_wp_all_export_xml_rows', 10, 4 );

Search the docs for wp_all_export_xml_rows to see real-world code snippets that use this hook.

wp_all_export_zapier_response

DescriptionCan be used to manipulate the response sent to Zapier.

Parameters

ParamTypeDescription$responsearrayThe response to Zapier.

Usage

add_filter( 'wp_all_export_zapier_response', 'wpae_wp_all_export_zapier_response', 10, 1 );

function wpae_wp_all_export_zapier_response( $response ) {
// Code here.
return $response;
}

Search the docs for wp_all_export_zapier_response to see real-world code snippets that use this example.

pmxi_custom_types

This filter allows modifying the option shown in the post type dropdown on Step 1 of an import. The current list of types and the list being updated are available as parameters. The custom_types list is where you'd add a post type to the dropdown that doesn't otherwise appear. The hidden_post_types list allows removing items from the dropdown.

Parameters

ParamTypeDescription$custom_typesarrayThe list of post types that will be available.$typestringWhich type of list is being updated - custom_types or hidden_post_types

Usage

function wpai_custom_types( $custom_types ) {

// Modify the custom types to be shown on Step 1.

// Return the updated list.
return $custom_types;

}
add_filter( 'pmxi_custom_types', 'wpai_custom_types', 10, 1 );

Search the docs for pmxi_custom_types to see real-world code snippets that use this filter.

pmxi_visible_template_sections

This filter allows modifying what sections are shown on Step 3 and Manage Imports > Edit Import. It provides an array of sections set to show and the post type being imported.

Parameters

ParamTypeDescription$sectionsstring arrayThe sections to show on Step 3. Possible options:'caption', 'main', 'taxonomies', 'cf', 'featured', 'other', 'nested'$post_typestringThe post type being imported.

Usage

function show_addon_section_users_customers( $sections, $post_type ) {

// Do something for your post type.
if ( 'your_post_type' == $post_type )

// Do something.

return $sections;
}

add_filter( 'pmxi_visible_template_sections', 'show_addon_section_users_customers', 11, 2 );

Search the docs for pmxi_visible_template_sections to see real-world code snippets that use this filter.

wp_all_import_minimum_number_of_variations

DescriptionUse this hook to set the minimum number of variations a product can have before it's converted to a simple product by the "Create products with no variations as simple products" option.

Parameters

ParamTypeDescription$min_variationsintMinimum number of variations. Default 2.$product_idboolThe Product ID.$import_idstringThe Import ID.

Usage

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;}

Search the docs for wp_all_import_minimum_number_of_variations to see real-world code snippets that use this hook.

wpai_is_case_insensitive_taxonomy_mapping

DescriptionReturn true to make the mapping rules in the "Enable Mapping for Categories" section case insensitive. Added in WP All Import v4.7.0-beta-1.1.

Parameters

ParamTypeDescription$is_case_insensitiveboolDefaults to false.$tx_namestringThe taxonomy name.

Usage

add_filter( 'wpai_is_case_insensitive_taxonomy_mapping', 'my_is_case_insensitive_mapping', 10, 2 );

function my_is_case_insensitive_mapping( $is_case_insensitive, $tx_name ) {
// Return true to make it case insensitive
return $is_case_insensitive;
}

Search the docs for wpai_is_case_insensitive_taxonomy_mapping to see real-world code snippets that use this hook.

wp_all_import_post_skipped

DescriptionFires whenever an import record is SKIPPED.

Parameters

ParamTypeDescription$post_to_update_idintThe post ID, or 0 if there's no post.$import_idintThe import ID.$current_xml_nodearrayAn array with the current import record's data.

Usage

// Log all skips
add_action( 'wp_all_import_post_skipped', 'my_log_skips', 10, 3 );

function my_log_skips( $created, $import_id, $xml_data ) {
$uploads = wp_upload_dir();
$log_file_name = $uploads['basedir'] . '/' . $import_id . '_import_custom_log.txt';
if ( file_exists( $log_file_name ) ) {
$existing_data = file_get_contents( $log_file_name );
} else {
touch( $log_file_name );
$existing_data = '';
}

if ( $created == 0 ) {
$created = 'N/A';
}

if ( array_key_exists( 'sku', $xml_data ) && array_key_existS( 'title', $xml_data ) ) {
$existing_data .= '[ID: ' . $created . '] [SKU: ' . $xml_data['sku'] . '] [Title: ' . $xml_data['title'] . '] has been skipped.' . PHP_EOL;
file_put_contents( $log_file_name, $existing_data );
}
}

Search the docs for wp_all_import_post_skipped to see other real-world code snippets that use this hook.

Filtering with XPath

Filtering with XPath

In Step 2 of WP All Import, you can specify filtering options to only import records in your file that match your criteria.

Filtering Options

WP All Import filters your file using XPath. The visual filtering options designer, shown above, lets you visually construct an XPath expression.

First, add your filtering rules by specifying the rule criteria and clicking the Add Rule button.

Then click Apply Filters to XPath to generate an XPath expression.

You can also manually write an XPath expression to filter your file. Learn more at https://www.w3schools.com/xml/xpath_syntax.asp.

Import Processing

Import Processing

WP All Import splits your import into small, manageable chunks, and then imports each chunk individually.

This is to make it more likely that WP All Import will be able to get around script execution time limits and work on old, slow, or overcrowded servers, and to get around script.

On the Manage Imports -> Import Settings page, you can configure the way in which WP All Import splits your file into chunks and processes your import.

Configure Options

Iterative, Piece-By-Piece Processing

This option enables WP All Import to process the import in smaller pieces – known as 「iterations」. Each iteration must be able to process faster than any script execution time limits on your server.

The default 「In each iteration, process __ records」 setting should be lowered if you see an 「Import XML – Error」 midway through your import.

If WP All Import has been configured to download images, keep in mind that the amount of time for the images to download is counted towards the script execution time.

If you are processing 20 records per iteration, and each record has 5 associated images, that means your server must be able to download 20 * 5 = 100 images faster than any script execution time limits your server might have.

Import Speed

Think your import is running slower than it should be? Check out our guide on import speed.