Properties

$instance

$instance : mixed

Public static variable to hold the single instance of MainWP_Child_Posts.

Type

mixed — Default null

$comments_and_clauses

$comments_and_clauses : string

Comments and clauses.

Type

string — Comments and clauses.

$posts_where_suffix

$posts_where_suffix : string

Posts with given suffix.

Type

string — Posts with given suffix.

Methods

get_class_name()

get_class_name() : string

Get class name.

Returns

string —

CLASS Class name.

__construct()

__construct() 

MainWP_Child_Posts constructor

Run any time class is called.

get_instance()

get_instance() : \MainWP\Child\MainWP_Child_Posts|null

Create a public static instance of MainWP_Child_Posts.

Returns

\MainWP\Child\MainWP_Child_Posts|null

get_recent_posts()

get_recent_posts(array  $pAllowedStatuses, integer  $pCount, string  $type = 'post', null  $extra = null) : array

Get recent posts.

Parameters

array $pAllowedStatuses

Array of allowed post statuses.

integer $pCount

Number of posts.

string $type

Post type.

null $extra

Extra tokens.

Returns

array —

$allPost Return array of recent posts.

get_recent_posts_int()

get_recent_posts_int(string  $status, integer  $pCount, string  $type, array  $allPosts, null  $extra = null) 

Initiate get recent posts.

Parameters

string $status

Post status.

integer $pCount

Number of posts.

string $type

Post type.

array $allPosts

All posts array.

null $extra

Extra tokens.

get_all_posts()

get_all_posts() 

Get all posts.

get_all_pages()

get_all_pages() 

Get all pages.

posts_where()

posts_where(string  $where) : string

Append the Post's SQL WHERE clause suffix.

Parameters

string $where

Post's SQL WHERE clause.

Returns

string —

$where The full SQL WHERE clause with the appended suffix.

get_all_posts_by_type()

get_all_posts_by_type(string  $type) 

Get all posts by type.

Parameters

string $type

Post type.

get_post_type_name()

get_post_type_name(string  $post_type_slug) : string

Gets the singular post type label

Parameters

string $post_type_slug

Post type slug.

Returns

string —

Post type label

replace_advanced_image()

replace_advanced_image(array  $content, array  $upload_dir, boolean  $withslashes = false) : mixed

Method replace_advanced_image()

Handle upload advanced image.

Parameters

array $content

post content data.

array $upload_dir

upload directory info.

boolean $withslashes

to use preg pattern with slashes.

Returns

mixed —

array of result.

get_out_post()

get_out_post(array  $post, string  $extra, array  $tokens) : array

Build Post.

Parameters

array $post

Post array.

string $extra

Post date & time.

array $tokens

Post tokens.

Returns

array —

$outPost Return completed post.

get_post_edit()

get_post_edit(string  $id) : array|boolean

Get post edit data.

Parameters

string $id

Post ID.

Returns

array|boolean —

Return $post_data or FALSE on failure.

get_page_edit()

get_page_edit(string  $id) : array|boolean

Get page edit data.

Parameters

string $id

Page ID.

Returns

array|boolean —

Return $post_data or FALSE on failure.

create_post()

create_post(array  $new_post, array  $post_custom, string  $post_category, string  $post_featured_image, string  $upload_dir, string  $post_tags, array  $others = array()) : array|array<mixed,string>

Create new post.

Parameters

array $new_post

Post data array.

array $post_custom

Post custom meta data.

string $post_category

Post categories.

string $post_featured_image

Post featured image.

string $upload_dir

Upload directory.

string $post_tags

Post tags.

array $others

Other data.

Returns

array|array<mixed,string> —

$ret Return success array, permalink & Post ID.

set_post_custom_data()

set_post_custom_data(array  $new_post, array  $post_custom, string  $post_tags, string  $edit_post_id, boolean  $is_post_plus) 

Set custom post data.

Parameters

array $new_post

Post data array.

array $post_custom

Post custom meta data.

string $post_tags

Post tags.

string $edit_post_id

Edit Post ID.

boolean $is_post_plus

TRUE|FALSE, Whether or not this came from MainWP Post Plus Extension.

update_post_data()

update_post_data(string  $new_post_id, array  $post_custom, string  $post_category, string  $post_featured_image, boolean  $check_image_existed, boolean  $is_post_plus, array  $others) 

Update post data.

Parameters

string $new_post_id

New post ID.

array $post_custom

Post custom meta data.

string $post_category

Post categories.

string $post_featured_image

Post featured image.

boolean $check_image_existed

TRUE|FALSE, Whether or not featured image already exists.

boolean $is_post_plus

TRUE|FALSE, Whether or not this came from MainWP Post Plus Extension.

array $others

Others data.

update_wp_rocket_custom_post()

update_wp_rocket_custom_post(array  $post_custom) 

Update WPRocket custom post.

Parameters

array $post_custom

Post custom meta data.

update_found_images()

update_found_images(array  $new_post, string  $upload_dir, boolean  $check_image_existed) 

Search for all the images added to the new post.

Parameters

array $new_post

Post data array.

string $upload_dir

Upload directory.

boolean $check_image_existed

TRUE|FALSE, Whether or not featured image already exists.

create_has_shortcode_gallery()

create_has_shortcode_gallery(array  $new_post) 

Create shortcode image gallery.

Parameters

array $new_post

Post data array.

create_post_plus()

create_post_plus(array  $new_post, array  $post_custom) 

Create post plus post.

Parameters

array $new_post

Post data array.

array $post_custom

Post custom meta data.

post_plus_update_author()

post_plus_update_author(string  $new_post_id, array  $post_custom) 

Update post plus author.

Parameters

string $new_post_id

New post ID.

array $post_custom

Post custom meta data.

post_plus_update_categories()

post_plus_update_categories(string  $new_post_id, array  $post_custom) 

Update post plus categories.

Parameters

string $new_post_id

New post ID.

array $post_custom

Post custom meta data.

create_set_categories()

create_set_categories(string  $new_post_id, string  $post_category, boolean  $post_to_only) 

Create new and set categories.

Parameters

string $new_post_id

New post ID.

string $post_category

Post category.

boolean $post_to_only

TRUE|FALSE, Whether or not to post only to this category.

set_custom_post_fields()

set_custom_post_fields(string  $new_post_id, array  $post_custom, boolean  $seo_ext_activated, boolean  $post_to_only) 

Set custom post fields.

Parameters

string $new_post_id

New post ID.

array $post_custom

Post custom meta data.

boolean $seo_ext_activated

TRUE|FALSE, Whether or not Yoast SEO is activateed or not.

boolean $post_to_only

TRUE|FALSE, Whether or not to post only to this category.

update_seo_meta()

update_seo_meta(string  $new_post_id, array  $post_custom) 

Update Yoast SEO Extension meta.

Parameters

string $new_post_id

New post ID.

array $post_custom

Post custom meta data.

create_featured_image()

create_featured_image(string  $new_post_id, string  $post_featured_image, boolean  $check_image_existed, array  $others) 

Create featured image.

Parameters

string $new_post_id

New post ID.

string $post_featured_image

Post featured image.

boolean $check_image_existed

TRUE|FALSE, Whether or not featured image already exists.

array $others

Post custom others meta data.