Methods

WPV_Import()

WPV_Import() 

Decide whether or not the importer is allowed to create users.

allow_create_users() : bool

Default is true, can be filtered via import_allow_create_users

Returns

boolTrue if creating users is allowed

Decide whether or not the importer should attempt to download attachment files.

allow_fetch_attachments() : bool

Default is true, can be filtered via import_allow_fetch_attachments. The choice made at the import options screen must also be true, false here hides that checkbox.

Returns

boolTrue if downloading attachments is allowed

Display import options for an individual author.

author_select(int $n, array $author) 

That is, either create a new user based on import info or map to an existing user

Parameters

$n

int

Index for each author in the form

$author

array

Author information, e.g. login, display name, email

Use stored mapping information to update old attachment URLs

backfill_attachment_urls() 

Attempt to associate posts and menu items with previously missing parents

backfill_parents() 

An imported post's parent may not have been imported when it was first created so try again. Similarly for child menu items and menu items which were missing the object (e.g. post) they represent in the menu

Added to http_request_timeout filter to force timeout at 60 seconds during import

bump_request_timeout() : int

Returns

int60

cmpr_strlen()

cmpr_strlen($a, $b) 

Parameters

$a

$b

Registered callback function for the WordPress Importer

dispatch() 

Manages the three separate stages of the WXR import process

Attempt to download a remote file attachment

fetch_remote_file(string $url, array $post) : array | \WP_Error

Parameters

$url

string

URL of item to fetch

$post

array

Attachment details

Returns

array\WP_ErrorLocal file location details on success, WP_Error otherwise

Map old author logins to local user IDs based on decisions made in import options form.

get_author_mapping() 

Can map to an existing user, create a new user or falls back to the current user in case of error with either of the previous

Retrieve authors from parsed WXR data

get_authors_from_import(array $import_data) 

Uses the provided author information from WXR 1.1 files or extracts info from each post for WXR 1.0 files

Parameters

$import_data

array

Data returned by a WXR parser

Display introductory text and file upload form

greet() 

Handles the WXR upload and initial parsing of the file to prepare for displaying author import options

handle_upload() : bool

Returns

boolFalse if error uploading or invalid file, true otherwise

header()

header() 

The main controller for the actual import stage.

import(string $file) 

Parameters

$file

string

Path to the WXR file for importing

Performs post-import cleanup of files and the cache

import_end() 

Display pre-import options, author importing/mapping and option to fetch attachments

import_options() 

Parses the WXR file and prepares us for the task of processing parsed data

import_start(string $file) 

Parameters

$file

string

Path to the WXR file for importing

Decide if the given meta key maps to information we will want to import

is_valid_meta_key(string $key) : string | bool

Parameters

$key

string

The meta key to check

Returns

stringboolThe key if we do want to import, false if not

Decide what the maximum file size for downloaded attachments is.

max_attachment_size() : int

Default is 0 (unlimited), can be filtered via import_attachment_size_limit

Returns

intMaximum attachment file size to import

Parse a WXR file

parse(string $file) : array

Parameters

$file

string

Path to WXR file for parsing

Returns

arrayInformation gathered from the WXR file

If fetching attachments is enabled then attempt to create a new attachment

process_attachment(array $post, string $url) : int | \WP_Error

Parameters

$post

array

Attachment post details from WXR

$url

string

URL to fetch attachment from

Returns

int\WP_ErrorPost ID on success, WP_Error otherwise

Create new categories based on import information

process_categories() 

Doesn't create a new category if its slug already exists

Attempt to create a new menu item from import data

process_menu_item(array $item) 

Fails for draft, orphaned menu items and those without an associated nav_menu or an invalid nav_menu term. If the post type or term object which the menu item represents doesn't exist then the menu item will not be imported (waits until the end of the import to retry again before discarding).

Parameters

$item

array

Menu item details from WXR file

Create new posts based on import information

process_posts() 

Posts marked as having a parent which doesn't exist will become top level items. Doesn't create a new post if: the post type doesn't exist, the given post ID is already noted as imported or a post with the same title and date already exists. Note that new/updated terms, comments and meta are imported for the last of the above.

Create new post tags based on import information

process_tags() 

Doesn't create a tag if its slug already exists

Create new terms based on import information

process_terms() 

Doesn't create a term its slug already exists

 Properties

 

$author_mapping 
 

$authors 
 

$base_url 
 

$categories 
   

$fetch_attachments 
 

$id 
 

$max_wxr_version 
 

$menu_item_orphans 
 

$missing_menu_items 
 

$post_orphans 
 

$posts 
 

$processed_authors 
 

$processed_menu_items 
 

$processed_posts 
 

$processed_terms 
 

$tags 
 

$terms 
 

$url_remap 
 

$version