Meta_Box
abstract class Meta_Box extends Singleton
A manager for Meta Boxes that appear on admin edit pages. Manages the form rendering and post save hooking processes.
Properties
| static protected Singleton[] | $_instances | from Singleton | |
| string | $context | ||
| string | $priority | ||
| string|array | $screen | ||
| string | $permissions |
Methods
Construct the Meta_Box. Set the default properties if they are not set.
Maybe initialize singleton instance and return the instance.
A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.
The function that will output the Meta Box HTML. Hooked by { $this->add_meta_box() } through { self::_render() }.
The code to be run after the _save_post hook checks.
A meta key to use when saving the Post Meta to the database. Should be lowercase and underscored.
Return the ID of the Meta Box (used in the "id" attribute, says WordPress docs, i.e. the "id" attribute in the HTML DOM for Javascript events).
The title of the Meta Box.
A generated nonce for super class forms.
A generated nonce action for super class forms.
Get the HTML name attribute prefix for grouping data inputs in this meta box.
WordPress hook for 'save_post', verify autosaving and Meta Box nonce.
The hook to use when adding the meta box to the WordPress environment. The gets called in { $this->add_meta_box() }.
Add the Meta Box to the WordPress environment.
Return the expected input data from the POST data.
Details
at line 108
__construct()
Construct the Meta_Box. Set the default properties if they are not set.
in
Singleton at line 42
final static Singleton
instance(mixed $args = null)
Maybe initialize singleton instance and return the instance.
in
Singleton at line 63
final static array
get_instances()
Return a copy of the instances array.
in
Singleton at line 72
final protected ReflectionClass
get_class_reflection()
A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.
at line 50
abstract static protected
render()
The function that will output the Meta Box HTML. Hooked by { $this->add_meta_box() } through { self::_render() }.
at line 58
abstract static protected
save_post(int $post_id, WP_Post|null $Post = null)
The code to be run after the _save_post hook checks.
at line 65
abstract static string
meta_key()
A meta key to use when saving the Post Meta to the database. Should be lowercase and underscored.
at line 73
abstract static string
get_id()
Return the ID of the Meta Box (used in the "id" attribute, says WordPress docs, i.e. the "id" attribute in the HTML DOM for Javascript events).
The ID should be lowercase and underscored to be consistent with the { $this->meta_key() } value.
at line 80
abstract static string
get_title()
The title of the Meta Box.
at line 87
final static string
get_nonce()
A generated nonce for super class forms.
at line 94
final static string
get_nonce_action()
A generated nonce action for super class forms.
at line 103
final static string
create_input_name(string $input_name)
Get the HTML name attribute prefix for grouping data inputs in this meta box.
at line 124
final static
_save_post(int $post_id, WP_Post|null $Post = null)
WordPress hook for 'save_post', verify autosaving and Meta Box nonce.
at line 151
final static
_render()
The hook to use when adding the meta box to the WordPress environment. The gets called in { $this->add_meta_box() }.
at line 159
final
add_meta_box()
Add the Meta Box to the WordPress environment.
at line 175
final static mixed
get_post_data()
Return the expected input data from the POST data.