PHP Класс WP_Import

Наследование: extends WP_Importer
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$author_mapping
$authors
$base_url
$categories
$featured_images
$fetch_attachments
$id max. supported WXR version
$max_wxr_version
$menu_item_orphans
$missing_menu_items
$post_orphans
$posts
$processed_authors mappings from old information to new
$processed_menu_items
$processed_posts
$processed_terms
$tags
$terms
$url_remap
$version information to import from WXR file

Открытые методы

Метод Описание
WP_Import ( )
allow_create_users ( ) : boolean Decide whether or not the importer is allowed to create users.
allow_fetch_attachments ( ) : boolean Decide whether or not the importer should attempt to download attachment files.
author_select ( integer $n, array $author ) Display import options for an individual author. That is, either create a new user based on import info or map to an existing user
backfill_attachment_urls ( ) Use stored mapping information to update old attachment URLs
backfill_parents ( ) Attempt to associate posts and menu items with previously missing parents
bump_request_timeout ( $val ) : integer Added to http_request_timeout filter to force timeout at 60 seconds during import
cmpr_strlen ( $a, $b ) return the difference in length between two strings
dispatch ( ) Registered callback function for the WordPress Importer
fetch_remote_file ( string $url, array $post ) : array | WP_Error Attempt to download a remote file attachment
footer ( ) Close div.wrap
get_author_mapping ( ) 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_authors_from_import ( array $import_data ) Retrieve authors from parsed WXR data
greet ( ) Display introductory text and file upload form
handle_upload ( ) : boolean Handles the WXR upload and initial parsing of the file to prepare for displaying author import options
header ( ) Display import page title
import ( string $file ) The main controller for the actual import stage.
import_end ( ) Performs post-import cleanup of files and the cache
import_options ( ) Display pre-import options, author importing/mapping and option to fetch attachments
import_start ( string $file ) Parses the WXR file and prepares us for the task of processing parsed data
is_valid_meta_key ( string $key ) : string | boolean Decide if the given meta key maps to information we will want to import
max_attachment_size ( ) : integer Decide what the maximum file size for downloaded attachments is.
parse ( string $file ) : array Parse a WXR file
process_attachment ( array $post, string $url ) : integer | WP_Error If fetching attachments is enabled then attempt to create a new attachment
process_categories ( ) Create new categories based on import information
process_menu_item ( array $item ) Attempt to create a new menu item from import data
process_posts ( ) Create new posts based on import information
process_tags ( ) Create new post tags based on import information
process_terms ( ) Create new terms based on import information
remap_featured_images ( ) Update _thumbnail_id meta to new, imported attachment IDs

Описание методов

WP_Import() публичный Метод

public WP_Import ( )

allow_create_users() публичный Метод

Default is true, can be filtered via import_allow_create_users
public allow_create_users ( ) : boolean
Результат boolean True if creating users is allowed

allow_fetch_attachments() публичный Метод

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.
public allow_fetch_attachments ( ) : boolean
Результат boolean True if downloading attachments is allowed

author_select() публичный Метод

Display import options for an individual author. That is, either create a new user based on import info or map to an existing user
public author_select ( integer $n, array $author )
$n integer Index for each author in the form
$author array Author information, e.g. login, display name, email

backfill_attachment_urls() публичный Метод

Use stored mapping information to update old attachment URLs

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
public backfill_parents ( )

bump_request_timeout() публичный Метод

Added to http_request_timeout filter to force timeout at 60 seconds during import
public bump_request_timeout ( $val ) : integer
Результат integer 60

cmpr_strlen() публичный Метод

return the difference in length between two strings
public cmpr_strlen ( $a, $b )

dispatch() публичный Метод

Manages the three separate stages of the WXR import process
public dispatch ( )

fetch_remote_file() публичный Метод

Attempt to download a remote file attachment
public fetch_remote_file ( string $url, array $post ) : array | WP_Error
$url string URL of item to fetch
$post array Attachment details
Результат array | WP_Error Local file location details on success, WP_Error otherwise

get_author_mapping() публичный Метод

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
public get_author_mapping ( )

get_authors_from_import() публичный Метод

Uses the provided author information from WXR 1.1 files or extracts info from each post for WXR 1.0 files
public get_authors_from_import ( array $import_data )
$import_data array Data returned by a WXR parser

greet() публичный Метод

Display introductory text and file upload form
public greet ( )

handle_upload() публичный Метод

Handles the WXR upload and initial parsing of the file to prepare for displaying author import options
public handle_upload ( ) : boolean
Результат boolean False if error uploading or invalid file, true otherwise

header() публичный Метод

Display import page title
public header ( )

import() публичный Метод

The main controller for the actual import stage.
public import ( string $file )
$file string Path to the WXR file for importing

import_end() публичный Метод

Performs post-import cleanup of files and the cache
public import_end ( )

import_options() публичный Метод

Display pre-import options, author importing/mapping and option to fetch attachments
public import_options ( )

import_start() публичный Метод

Parses the WXR file and prepares us for the task of processing parsed data
public import_start ( string $file )
$file string Path to the WXR file for importing

is_valid_meta_key() публичный Метод

Decide if the given meta key maps to information we will want to import
public is_valid_meta_key ( string $key ) : string | boolean
$key string The meta key to check
Результат string | boolean The key if we do want to import, false if not

max_attachment_size() публичный Метод

Default is 0 (unlimited), can be filtered via import_attachment_size_limit
public max_attachment_size ( ) : integer
Результат integer Maximum attachment file size to import

parse() публичный Метод

Parse a WXR file
public parse ( string $file ) : array
$file string Path to WXR file for parsing
Результат array Information gathered from the WXR file

process_attachment() публичный Метод

If fetching attachments is enabled then attempt to create a new attachment
public process_attachment ( array $post, string $url ) : integer | WP_Error
$post array Attachment post details from WXR
$url string URL to fetch attachment from
Результат integer | WP_Error Post ID on success, WP_Error otherwise

process_categories() публичный Метод

Doesn't create a new category if its slug already exists
public process_categories ( )

process_menu_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).
public process_menu_item ( array $item )
$item array Menu item details from WXR file

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.
public process_posts ( )

process_tags() публичный Метод

Doesn't create a tag if its slug already exists
public process_tags ( )

process_terms() публичный Метод

Doesn't create a term its slug already exists
public process_terms ( )

Описание свойств

$author_mapping публичное свойство

public $author_mapping

$authors публичное свойство

public $authors

$base_url публичное свойство

public $base_url

$categories публичное свойство

public $categories

$fetch_attachments публичное свойство

public $fetch_attachments

$id публичное свойство

max. supported WXR version
public $id

$max_wxr_version публичное свойство

public $max_wxr_version

$menu_item_orphans публичное свойство

public $menu_item_orphans

$missing_menu_items публичное свойство

public $missing_menu_items

$post_orphans публичное свойство

public $post_orphans

$posts публичное свойство

public $posts

$processed_authors публичное свойство

mappings from old information to new
public $processed_authors

$processed_menu_items публичное свойство

public $processed_menu_items

$processed_posts публичное свойство

public $processed_posts

$processed_terms публичное свойство

public $processed_terms

$tags публичное свойство

public $tags

$terms публичное свойство

public $terms

$url_remap публичное свойство

public $url_remap

$version публичное свойство

information to import from WXR file
public $version