PostType
in package
PostType Module class.
Table of Contents
Properties
- $action_hook : ActionHook
- ActionHook instance.
- $args : array<string|int, mixed>|null
- An array of arguments for registering a post type.
- $post_type : string
- Post type key.
Methods
- __construct() : mixed
- Constructor.
- __toString() : string
- Custom toString magic method.
- register_post_type() : void
- Registers the post type with WordPress.
- initialize() : void
- Initializes the post type.
Properties
$action_hook
ActionHook instance.
private
ActionHook
$action_hook
ActionHook object for the register_post_type method.
Tags
$args
An array of arguments for registering a post type.
private
array<string|int, mixed>|null
$args
Array or query string of arguments for registering a post type.
Tags
$post_type
Post type key.
private
string
$post_type
Post type key. Must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores. See sanitize_key() .
Tags
Methods
__construct()
Constructor.
public
__construct(string $post_type, array<string|int, mixed> $args[, ActionHook $action_hook = null ]) : mixed
Constructs the PostType object by setting the post type key, arguments, and action hook.
Parameters
- $post_type : string
-
Post type key. Must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores. See sanitize_key() .
- $args : array<string|int, mixed>
-
Array or query string of arguments for registering a post type.
- $action_hook : ActionHook = null
-
Optional. ActionHook instance. Default 'init'.
Tags
__toString()
Custom toString magic method.
public
__toString() : string
Returns the post type as a JSON string.
Tags
Return values
string —JSON string.
register_post_type()
Registers the post type with WordPress.
public
register_post_type() : void
Uses the register_post_type()
function to register the post type.
Tags
initialize()
Initializes the post type.
private
initialize() : void
Hooks the action to register the post type and adds the post type to the registry.