PHP 클래스 WXR_Importer, WordPress-Importer

상속: extends WP_Importer
파일 보기 프로젝트 열기: humanmade/WordPress-Importer 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$base_url
$categories information to import from WXR file
$exists
$featured_images
$logger WP_Importer_Logger Logger instance.
$mapping NEW STYLE
$menu_item_orphans
$missing_menu_items
$processed_menu_items
$processed_posts
$processed_terms TODO: REMOVE THESE
$requires_remapping
$tags
$url_remap
$user_slug_override
$version string Defaults to 1.0 for compatibility. Typically overridden by a tag at the start of the file.

공개 메소드들

메소드 설명
__construct ( array $options = [] ) Constructor
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
get_preliminary_information ( string $file ) The main controller for the actual import stage.
import ( string $file ) The main controller for the actual import stage.
is_valid_meta_key ( string $key ) : string | boolean Decide if the given meta key maps to information we will want to import
parse_authors ( string $file ) The main controller for the actual import stage.
remap_featured_images ( ) Update _thumbnail_id meta to new, imported attachment IDs
set_logger ( $logger )
set_user_mapping ( array $mapping ) Set the user mapping.
set_user_slug_overrides ( string[] $overrides ) Set the user slug overrides.
sort_comments_by_id ( array $a, array $b ) : integer Callback for usort to sort comments by ID

보호된 메소드들

메소드 설명
comment_exists ( array $data ) : integer | boolean Does the comment exist?
fetch_remote_file ( string $url, array $post ) : array | WP_Error Attempt to download a remote file attachment
get_reader ( string $file ) : XMLReader | WP_Error Get a stream reader for the file.
import_end ( ) Performs post-import cleanup of files and the cache
import_start ( string $file ) Parses the WXR file and prepares us for the task of processing parsed data
log_error ( WP_Error $error ) Log an error instance to the logger.
mark_comment_exists ( array $data, integer $comment_id ) Mark the comment as existing.
mark_post_exists ( array $data, integer $post_id ) Mark the post as existing.
mark_term_exists ( array $data, integer $term_id ) Mark the term as existing.
max_attachment_size ( ) : integer Decide what the maximum file size for downloaded attachments is.
parse_author_node ( $node )
parse_category_node ( $node )
parse_comment_node ( DOMElement $node ) : array Parse a comment node into comment data.
parse_meta_node ( DOMElement $node ) : array | null Parse a meta node into meta data.
parse_post_node ( DOMElement $node ) : array | WP_Error Parse a post node into post data.
parse_term_node ( $node, $type = 'term' )
post_exists ( array $data ) : integer | boolean Does the post exist?
post_process ( )
post_process_comments ( $todo )
post_process_menu_item ( $post_id )
post_process_posts ( $todo )
prefill_existing_comments ( ) Prefill existing comment data.
prefill_existing_posts ( ) Prefill existing post data.
prefill_existing_terms ( ) Prefill existing term data.
process_attachment ( array $post, $meta, $remote_url ) : integer | WP_Error If fetching attachments is enabled then attempt to create a new attachment
process_author ( $data, $meta )
process_comments ( array $comments, integer $post_id, array $post, $post_exists = false ) : integer | WP_Error Process and import comment data.
process_menu_item_meta ( $post_id, $data, $meta ) Attempt to create a new menu item from import data
process_post ( $data, $meta, $comments, $terms ) Create new posts based on import information
process_post_meta ( array $meta, integer $post_id, array $post ) : integer | WP_Error Process and import post meta items.
process_term ( $data, $meta )
replace_attachment_urls_in_content ( ) Use stored mapping information to update old attachment URLs
term_exists ( array $data ) : integer | boolean Does the term exist?

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( array $options = [] )
$options array { @var bool $prefill_existing_posts Should we prefill `post_exists` calls? (True prefills and uses more memory, false checks once per imported post and takes longer. Default is true.) @var bool $prefill_existing_comments Should we prefill `comment_exists` calls? (True prefills and uses more memory, false checks once per imported comment and takes longer. Default is true.) @var bool $prefill_existing_terms Should we prefill `term_exists` calls? (True prefills and uses more memory, false checks once per imported term and takes longer. Default is true.) @var bool $update_attachment_guids Should attachment GUIDs be updated to the new URL? (True updates the GUID, which keeps compatibility with v1, false doesn't update, and allows deduplication and reimporting. Default is false.) @var bool $fetch_attachments Fetch attachments from the remote server. (True fetches and creates attachment posts, false skips attachments. Default is false.) @var bool $aggressive_url_search Should we search/replace for URLs aggressively? (True searches all posts' content for old URLs and replaces, false checks for `` only. Default is false.) @var int $default_author User ID to use if author is missing or invalid. (Default is null, which leaves posts unassigned.) }

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 )

comment_exists() 보호된 메소드

Does the comment exist?
protected comment_exists ( array $data ) : integer | boolean
$data array Comment data to check against.
리턴 integer | boolean Existing comment ID if it exists, false otherwise.

fetch_remote_file() 보호된 메소드

Attempt to download a remote file attachment
protected 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_preliminary_information() 공개 메소드

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

get_reader() 보호된 메소드

Get a stream reader for the file.
protected get_reader ( string $file ) : XMLReader | WP_Error
$file string Path to the XML file.
리턴 XMLReader | WP_Error Reader instance on success, error otherwise.

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
protected import_end ( )

import_start() 보호된 메소드

Parses the WXR file and prepares us for the task of processing parsed data
protected 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

log_error() 보호된 메소드

Log an error instance to the logger.
protected log_error ( WP_Error $error )
$error WP_Error Error instance to log.

mark_comment_exists() 보호된 메소드

Mark the comment as existing.
protected mark_comment_exists ( array $data, integer $comment_id )
$data array Comment data to mark as existing.
$comment_id integer Comment ID.

mark_post_exists() 보호된 메소드

Mark the post as existing.
protected mark_post_exists ( array $data, integer $post_id )
$data array Post data to mark as existing.
$post_id integer Post ID.

mark_term_exists() 보호된 메소드

Mark the term as existing.
protected mark_term_exists ( array $data, integer $term_id )
$data array Term data to mark as existing.
$term_id integer Term ID.

max_attachment_size() 보호된 메소드

Default is 0 (unlimited), can be filtered via import_attachment_size_limit
protected max_attachment_size ( ) : integer
리턴 integer Maximum attachment file size to import

parse_author_node() 보호된 메소드

protected parse_author_node ( $node )

parse_authors() 공개 메소드

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

parse_category_node() 보호된 메소드

protected parse_category_node ( $node )

parse_comment_node() 보호된 메소드

Parse a comment node into comment data.
protected parse_comment_node ( DOMElement $node ) : array
$node DOMElement Parent node of comment data (typically `wp:comment`).
리턴 array Comment data array.

parse_meta_node() 보호된 메소드

Parse a meta node into meta data.
protected parse_meta_node ( DOMElement $node ) : array | null
$node DOMElement Parent node of meta data (typically `wp:postmeta` or `wp:commentmeta`).
리턴 array | null Meta data array on success, or null on error.

parse_post_node() 보호된 메소드

Parse a post node into post data.
protected parse_post_node ( DOMElement $node ) : array | WP_Error
$node DOMElement Parent node of post data (typically `item`).
리턴 array | WP_Error Post data array on success, error otherwise.

parse_term_node() 보호된 메소드

protected parse_term_node ( $node, $type = 'term' )

post_exists() 보호된 메소드

Does the post exist?
protected post_exists ( array $data ) : integer | boolean
$data array Post data to check against.
리턴 integer | boolean Existing post ID if it exists, false otherwise.

post_process() 보호된 메소드

protected post_process ( )

post_process_comments() 보호된 메소드

protected post_process_comments ( $todo )

post_process_menu_item() 보호된 메소드

protected post_process_menu_item ( $post_id )

post_process_posts() 보호된 메소드

protected post_process_posts ( $todo )

prefill_existing_comments() 보호된 메소드

Prefill existing comment data.
또한 보기: self::prefill_existing_posts() for justification of why this exists.

prefill_existing_posts() 보호된 메소드

This preloads all GUIDs into memory, allowing us to avoid hitting the database when we need to check for existence. With larger imports, this becomes prohibitively slow to perform SELECT queries on each. By preloading all this data into memory, it's a constant-time lookup in PHP instead. However, this does use a lot more memory, so for sites doing small imports onto a large site, it may be a better tradeoff to use on-the-fly checking instead.
protected prefill_existing_posts ( )

prefill_existing_terms() 보호된 메소드

Prefill existing term data.
또한 보기: self::prefill_existing_posts() for justification of why this exists.
protected prefill_existing_terms ( )

process_attachment() 보호된 메소드

If fetching attachments is enabled then attempt to create a new attachment
protected process_attachment ( array $post, $meta, $remote_url ) : integer | WP_Error
$post array Attachment post details from WXR
리턴 integer | WP_Error Post ID on success, WP_Error otherwise

process_author() 보호된 메소드

protected process_author ( $data, $meta )

process_comments() 보호된 메소드

Process and import comment data.
protected process_comments ( array $comments, integer $post_id, array $post, $post_exists = false ) : integer | WP_Error
$comments array List of comment data arrays.
$post_id integer Post to associate with.
$post array Post data.
리턴 integer | WP_Error Number of comments imported on success, error otherwise.

process_menu_item_meta() 보호된 메소드

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).
protected process_menu_item_meta ( $post_id, $data, $meta )

process_post() 보호된 메소드

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.
protected process_post ( $data, $meta, $comments, $terms )

process_post_meta() 보호된 메소드

Process and import post meta items.
protected process_post_meta ( array $meta, integer $post_id, array $post ) : integer | WP_Error
$meta array List of meta data arrays
$post_id integer Post to associate with
$post array Post data
리턴 integer | WP_Error Number of meta items imported on success, error otherwise.

process_term() 보호된 메소드

protected process_term ( $data, $meta )

replace_attachment_urls_in_content() 보호된 메소드

Use stored mapping information to update old attachment URLs

set_logger() 공개 메소드

public set_logger ( $logger )

set_user_mapping() 공개 메소드

Set the user mapping.
public set_user_mapping ( array $mapping )
$mapping array List of map arrays (containing `old_slug`, `old_id`, `new_id`)

set_user_slug_overrides() 공개 메소드

Allows overriding the slug in the import with a custom/renamed version.
public set_user_slug_overrides ( string[] $overrides )
$overrides string[] Map of old slug to new slug.

sort_comments_by_id() 공개 정적인 메소드

Callback for usort to sort comments by ID
public static sort_comments_by_id ( array $a, array $b ) : integer
$a array Comment data for the first comment
$b array Comment data for the second comment
리턴 integer

term_exists() 보호된 메소드

Does the term exist?
protected term_exists ( array $data ) : integer | boolean
$data array Term data to check against.
리턴 integer | boolean Existing term ID if it exists, false otherwise.

프로퍼티 상세

$base_url 보호되어 있는 프로퍼티

protected $base_url

$categories 보호되어 있는 프로퍼티

information to import from WXR file
protected $categories

$exists 보호되어 있는 프로퍼티

protected $exists

$logger 보호되어 있는 프로퍼티

Logger instance.
protected WP_Importer_Logger $logger
리턴 WP_Importer_Logger

$mapping 보호되어 있는 프로퍼티

NEW STYLE
protected $mapping

$menu_item_orphans 보호되어 있는 프로퍼티

protected $menu_item_orphans

$missing_menu_items 보호되어 있는 프로퍼티

protected $missing_menu_items

$processed_menu_items 보호되어 있는 프로퍼티

protected $processed_menu_items

$processed_posts 보호되어 있는 프로퍼티

protected $processed_posts

$processed_terms 보호되어 있는 프로퍼티

TODO: REMOVE THESE
protected $processed_terms

$requires_remapping 보호되어 있는 프로퍼티

protected $requires_remapping

$tags 보호되어 있는 프로퍼티

protected $tags

$url_remap 보호되어 있는 프로퍼티

protected $url_remap

$user_slug_override 보호되어 있는 프로퍼티

protected $user_slug_override

$version 보호되어 있는 프로퍼티

Defaults to 1.0 for compatibility. Typically overridden by a tag at the start of the file.
protected string $version
리턴 string