PHP Class WXR_Import_UI, WordPress-Importer

Datei anzeigen Open project: humanmade/WordPress-Importer

Protected Properties

Property Type Description
$fetch_attachments boolean Set in {@see \display_import_step}.

Public Methods

Method Description
__construct ( ) Constructor.
add_mime_type_xml ( array $mimes ) Add .xml files as supported format in the uploader.
dispatch ( ) Render the import page.
handle_async_upload ( ) Handle an async upload.
imported_comment ( ) Send message when a comment has been imported.
imported_post ( integer $id, array $data ) Send message when a post has been imported.
imported_term ( ) Send message when a term has been imported.
imported_user ( ) Send message when a user has been imported.
on_load ( ) Handle load event for the importer.
show_updates_in_header ( ) Show an update notice in the importer header.
stream_import ( ) Run an import, and send an event-stream response.

Protected Methods

Method Description
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 $index, 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
display_author_step ( ) Display the author picker (or upload errors).
display_error ( WP_Error $err, $step )
display_import_step ( ) Display the actual import step.
display_intro_step ( ) Display introductory text and file upload form
emit_sse_message ( mixed $data ) Emit a Server-Sent Events message.
get_author_mapping ( array $args ) : array Get mapping data from request data.
get_data_for_attachment ( integer $id ) : WXR_Import_Info | WP_Error Get preliminary data for an import file.
get_import_options ( ) : array Get options for the importer.
get_importer ( ) : WXR_Importer Get the importer instance.
get_url ( integer $step ) Get the URL for the importer.
handle_select ( integer | string $id ) : boolean | WP_Error Handle a WXR file selected from the media browser.
handle_upload ( ) : boolean | WP_Error Handles the WXR upload and initial parsing of the file to prepare for displaying author import options
render_footer ( ) Render the importer footer.
render_header ( ) Render the importer header.
render_upload_form ( )

Method Details

__construct() public method

Constructor.
public __construct ( )

add_mime_type_xml() public method

Add .xml files as supported format in the uploader.
public add_mime_type_xml ( array $mimes )
$mimes array Already supported mime types.

allow_create_users() protected method

Default is true, can be filtered via import_allow_create_users
protected allow_create_users ( ) : boolean
return boolean True if creating users is allowed

allow_fetch_attachments() protected method

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.
protected allow_fetch_attachments ( ) : boolean
return boolean True if downloading attachments is allowed

author_select() protected method

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

dispatch() public method

Render the import page.
public dispatch ( )

display_author_step() protected method

Display the author picker (or upload errors).
protected display_author_step ( )

display_error() protected method

protected display_error ( WP_Error $err, $step )
$err WP_Error

display_import_step() protected method

Display the actual import step.
protected display_import_step ( )

display_intro_step() protected method

Display introductory text and file upload form
protected display_intro_step ( )

emit_sse_message() protected method

Emit a Server-Sent Events message.
protected emit_sse_message ( mixed $data )
$data mixed Data to be JSON-encoded and sent in the message.

get_author_mapping() protected method

Parses form request data into an internally usable mapping format.
protected get_author_mapping ( array $args ) : array
$args array Raw (UNSLASHED) POST data to parse.
return array Map containing `mapping` and `slug_overrides` keys.

get_data_for_attachment() protected method

This is a quick pre-parse to verify the file and grab authors from it.
protected get_data_for_attachment ( integer $id ) : WXR_Import_Info | WP_Error
$id integer Media item ID.
return WXR_Import_Info | WP_Error Import info instance on success, error otherwise.

get_import_options() protected method

Get options for the importer.
protected get_import_options ( ) : array
return array Options to pass to WXR_Importer::__construct

get_importer() protected method

Get the importer instance.
protected get_importer ( ) : WXR_Importer
return WXR_Importer

get_url() protected method

Get the URL for the importer.
protected get_url ( integer $step )
$step integer Go to step rather than start.

handle_async_upload() public method

Triggers on async-upload.php?action=wxr-import-upload to handle Plupload requests from the importer.
public handle_async_upload ( )

handle_select() protected method

Handle a WXR file selected from the media browser.
protected handle_select ( integer | string $id ) : boolean | WP_Error
$id integer | string Media item to import from.
return boolean | WP_Error True on success, error object otherwise.

handle_upload() protected method

Handles the WXR upload and initial parsing of the file to prepare for displaying author import options
protected handle_upload ( ) : boolean | WP_Error
return boolean | WP_Error True on success, error object otherwise.

imported_comment() public method

Send message when a comment has been imported.
public imported_comment ( )

imported_post() public method

Send message when a post has been imported.
public imported_post ( integer $id, array $data )
$id integer Post ID.
$data array Post data saved to the DB.

imported_term() public method

Send message when a term has been imported.
public imported_term ( )

imported_user() public method

Send message when a user has been imported.
public imported_user ( )

on_load() public method

Handle load event for the importer.
public on_load ( )

render_header() protected method

Render the importer header.
protected render_header ( )

render_upload_form() protected method

protected render_upload_form ( )

show_updates_in_header() public method

Show an update notice in the importer header.

stream_import() public method

Streams logs and success messages to the browser to allow live status and updates.
public stream_import ( )

Property Details

$fetch_attachments protected_oe property

Set in {@see \display_import_step}.
protected bool $fetch_attachments
return boolean