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
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
CAPABILITY
The user capability required to generate and store related posts.
protected
string
CAPABILITY
= 'edit_posts'
Tags
META_KEY
Meta key name.
protected
string
META_KEY
= 'pnet_related_posts'
Tags
METABOX_CONTAINER
Related posts metabox container partial.
protected
string
METABOX_CONTAINER
= 'related-posts-metabox.php'
Tags
METABOX_ENTRY
Related posts metabox entry partial.
protected
string
METABOX_ENTRY
= 'related-posts-metabox-entry.php'
Tags
NONCE_NAME
The nonce name.
protected
string
NONCE_NAME
= 'token'
Tags
Properties
$common_related_posts
The instance of the Common_Related_Posts class.
protected
Related_Posts
$common_related_posts
Tags
$http_handler
The instance of the HTTP_Handler class.
protected
HTTP_Handler
$http_handler
Tags
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
$metabox_container
Fully qualified path to related posts metabox container partial.
protected
string
$metabox_container
Tags
$metabox_entry
Fully qualified path to related posts metabox entry partial.
protected
string
$metabox_entry
Tags
$progress_container
The progress indicator container markup.
protected
string
$progress_container
= ''
Tags
Methods
add_metabox()
Add the metabox to post edit screen.
public
add_metabox() : void
Tags
get_action()
Return the action name.
public
get_action() : string
- This is the {action} part of the wp_ajax hook name.
Tags
Return values
string —The action name.
get_instance()
Creates and/or returns the instance of this class.
public
static get_instance() : object
Tags
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
Return values
string —The markup to display in the related posts meta box.
handle_ajax_request()
The AJAX call handler.
public
handle_ajax_request() : void
Tags
render_metabox()
Render the metabox on post edit screen.
public
render_metabox(WP_Post $post) : void
Parameters
- $post : WP_Post
-
The post object.
Tags
__construct()
Initialise the class.
protected
__construct() : void