WPV_Import

Extends \WP_Importer

Methods

WPV_Import

WPV_Import() 

Registered callback function for the WordPress Importer

dispatch() 

Manages the three separate stages of the WXR import process

The main controller for the actual import stage.

import(string $file) 

Arguments

$file

string

Path to the WXR file for importing

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

import_start(string $file) 

Arguments

$file

string

Path to the WXR file for importing

Performs post-import cleanup of files and the cache

import_end() 

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

handle_upload() : bool

Response

bool

False if error uploading or invalid file, true otherwise

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

Arguments

$import_data

array

Data returned by a WXR parser

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

import_options() 

Display import options for an individual author. That is, either create a new user based on import info or map to an existing user

author_select(int $n, array $author) 

Arguments

$n

int

Index for each author in the form

$author

array

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

Map old author logins to local user IDs based on decisions made in import options form. 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

get_author_mapping() 

Create new categories based on import information

process_categories() 

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

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

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.

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).

Arguments

$item

array

Menu item details from WXR file

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

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

Arguments

$post

array

Attachment post details from WXR

$url

string

URL to fetch attachment from

Response

int|\WP_Error

Post ID on success, WP_Error otherwise

Attempt to download a remote file attachment

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

Arguments

$url

string

URL of item to fetch

$post

array

Attachment details

Response

array|\WP_Error

Local file location details on success, WP_Error otherwise

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

Use stored mapping information to update old attachment URLs

backfill_attachment_urls() 

Parse a WXR file

parse(string $file) : array

Arguments

$file

string

Path to WXR file for parsing

Response

array

Information gathered from the WXR file

header

header() 

Display introductory text and file upload form

greet() 

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

is_valid_meta_key(string $key) : string|bool

Arguments

$key

string

The meta key to check

Response

string|bool

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

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

Response

bool

True 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.

Response

bool

True if downloading attachments is allowed

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

Response

int

Maximum attachment file size to import

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

bump_request_timeout($val) : int

Arguments

$val

Response

int

60

cmpr_strlen

cmpr_strlen($a, $b) 

Arguments

$a

$b

Properties

max_wxr_version

max_wxr_version : 

id

id : 

version

version : 

authors

authors : 

posts

posts : 

terms

terms : 

categories

categories : 

tags

tags : 

base_url

base_url : 

front_page

front_page : 

processed_authors

processed_authors : 

author_mapping

author_mapping : 

processed_terms

processed_terms : 

processed_posts

processed_posts : 

post_orphans

post_orphans : 

processed_menu_items

processed_menu_items : 

menu_item_orphans

menu_item_orphans : 

missing_menu_items

missing_menu_items : 

fetch_attachments

fetch_attachments : 

url_remap

url_remap :