pfeifferNet

Related_Posts
in package

Handle the related posts admin functionality.

  • Add a meta box with related posts on the post edit screen.
  • Add a button to the related posts meta box to (re)generate related posts for the post.
  • Handle the AJAX request to generate related posts for the post.
Tags
since
6.7.0

Table of Contents

Constants

ACTION  = 'generate_related_posts'
The wp_ajax hook action properties.
CAPABILITY  = 'edit_posts'
The user capability required to generate and store related posts.
META_KEY  = 'pnet_related_posts'
Meta key name.
METABOX_CONTAINER  = 'related-posts-metabox.php'
Related posts metabox container partial.
METABOX_ENTRY  = 'related-posts-metabox-entry.php'
Related posts metabox entry partial.
NONCE_NAME  = 'token'
The nonce name.

Properties

$common_related_posts  : Related_Posts
The instance of the Common_Related_Posts class.
$http_handler  : HTTP_Handler
The instance of the HTTP_Handler class.
$instances  : array<string|int, object>
The array of instances of this class and sub-classes.
$metabox_container  : string
Fully qualified path to related posts metabox container partial.
$metabox_entry  : string
Fully qualified path to related posts metabox entry partial.
$progress_container  : string
The progress indicator container markup.

Methods

add_metabox()  : void
Add the metabox to post edit screen.
get_action()  : string
Return the action name.
get_instance()  : object
Creates and/or returns the instance of this class.
get_metabox_content()  : string
Get the related posts metabox entries markup.
handle_ajax_request()  : void
The AJAX call handler.
render_metabox()  : void
Render the metabox on post edit screen.
__construct()  : void
Initialise the class.

Constants

ACTION

The wp_ajax hook action properties.

protected string ACTION = 'generate_related_posts'
Tags
since
6.7.0

CAPABILITY

The user capability required to generate and store related posts.

protected string CAPABILITY = 'edit_posts'
Tags
since
6.7.0

META_KEY

Meta key name.

protected string META_KEY = 'pnet_related_posts'
Tags
since
6.7.0

METABOX_CONTAINER

Related posts metabox container partial.

protected string METABOX_CONTAINER = 'related-posts-metabox.php'
Tags
since
6.7.0

METABOX_ENTRY

Related posts metabox entry partial.

protected string METABOX_ENTRY = 'related-posts-metabox-entry.php'
Tags
since
6.7.0

Properties

$instances

The array of instances of this class and sub-classes.

protected static array<string|int, object> $instances = array()
Tags
since
6.7.0

$metabox_container

Fully qualified path to related posts metabox container partial.

protected string $metabox_container
Tags
since
6.7.0

$metabox_entry

Fully qualified path to related posts metabox entry partial.

protected string $metabox_entry
Tags
since
6.7.0

$progress_container

The progress indicator container markup.

protected string $progress_container = ''
Tags
since
6.7.0

Methods

add_metabox()

Add the metabox to post edit screen.

public add_metabox() : void
Tags
since
6.7.0

get_instance()

Creates and/or returns the instance of this class.

public static get_instance() : object
Tags
since
6.7.0
Return values
object

The instance of this class.

get_metabox_content()

Get the related posts metabox entries markup.

public get_metabox_content(array<string|int, int> $related_post_list) : string
Parameters
$related_post_list : array<string|int, int>

The array of related post IDs.

Tags
since
6.7.0
Return values
string

The markup to display in the related posts meta box.

render_metabox()

Render the metabox on post edit screen.

public render_metabox(WP_Post $post) : void
Parameters
$post : WP_Post

The post object.

Tags
since
6.7.0

        
On this page

Search results