\lloc\Msls\ContentImportContentImporter

Class ContentImporter

Handles the request for a content import.

Summary

Methods
Properties
Constants
instance()
__construct()
get_logger()
set_logger()
get_relations()
set_relations()
handle_import()
parse_sources()
handle()
import_content()
filter_empty()
No public properties found
No constants found
pre_flight_check()
get_the_blog_post_ID()
insert_blog_post()
update_inserted_blog_post_data()
redirect_to_blog_post()
$main
$logger
$relations
$handle
$has_created_post
N/A
No private methods found
No private properties found
N/A

Properties

$handle

$handle : boolean

Type

boolean — Whether the class should handle requests or not.

$has_created_post

$has_created_post : integer

Type

integer — The ID of the post the class created while handling the request, if any.

Methods

instance()

instance() : static

Gets or creates an instance of the called class

Returns

static

__construct()

__construct(\lloc\Msls\MslsMain|null  $main = null) 

ContentImporter constructor.

Parameters

\lloc\Msls\MslsMain|null $main

handle_import()

handle_import(array|null  $data = array()) : array

Handles an import request happening during a post save or a template redirect.

Parameters

array|null $data

Returns

array —

The updated, if needed, data array.

parse_sources()

parse_sources() : array|boolean

Parses the source blog and post IDs from the $_POST array validating them.

Returns

array|boolean

handle()

handle(  $handle) 

Parameters

$handle

import_content()

import_content(\lloc\Msls\ContentImport\ImportCoordinates  $import_coordinates, array  $post_fields = array()) : array

Imports content according to the provided coordinates.

Parameters

\lloc\Msls\ContentImport\ImportCoordinates $import_coordinates
array $post_fields

An optional array of post fields; this can be left empty if the method is not called as a consequence of filtering the wp_insert_post_data filter.

Returns

array —

An array of modified post fields.

filter_empty()

filter_empty(boolean  $empty) : boolean

Filters whether the post should be considered empty or not.

Empty posts would not be saved to database but it's fine if in the context of a content import as it will be populated.

Parameters

boolean $empty

Returns

boolean

pre_flight_check()

pre_flight_check(array  $data = array()) : boolean

Whether the importer should run or not.

Parameters

array $data

Returns

boolean

get_the_blog_post_ID()

get_the_blog_post_ID(  $blog_id) 

Parameters

$blog_id

insert_blog_post()

insert_blog_post(  $blog_id, array  $data = array()) 

Parameters

$blog_id
array $data

update_inserted_blog_post_data()

update_inserted_blog_post_data(  $blog_id, integer  $post_id, array  $data) : array

Parameters

$blog_id
integer $post_id
array $data

Returns

array

redirect_to_blog_post()

redirect_to_blog_post(  $dest_blog_id,   $post_id) 

Parameters

$dest_blog_id
$post_id