Shortcode
in package
Shortcode Module class.
Table of Contents
Properties
- $action_hook : ActionHook
- ActionHook instance.
- $callback : callable
- Callback function.
- $tag : string
- Shortcode tag.
Methods
- __construct() : mixed
- Constructor.
- __toString() : string
- Custom toString magic method.
- add_shortcode() : void
- Adds the shortcode to WordPress.
- initialize() : void
- Initializes the shortcode.
Properties
$action_hook
ActionHook instance.
private
ActionHook
$action_hook
ActionHook object for the add_shortcode method.
Tags
$callback
Callback function.
private
callable
$callback
Callback function to run when the shortcode is found.
Tags
$tag
Shortcode tag.
private
string
$tag
Shortcode tag to be searched in post content.
Tags
Methods
__construct()
Constructor.
public
__construct(string $tag, callable $callback[, ActionHook $action_hook = null ]) : mixed
Constructs the Shortcode object by setting the tag, callback, and action_hook.
Parameters
- $tag : string
-
Shortcode tag to be searched in post content.
- $callback : callable
-
Callback function to run when the shortcode is found.
- $action_hook : ActionHook = null
-
Optional. ActionHook instance. Default 'init'.
Tags
__toString()
Custom toString magic method.
public
__toString() : string
Returns the shortcode as a JSON string.
Tags
Return values
string —JSON string.
add_shortcode()
Adds the shortcode to WordPress.
public
add_shortcode() : void
Uses the add_shortcode()
function to add the shortcode to WordPress.
Tags
initialize()
Initializes the shortcode.
private
initialize() : void
Hooks the action to register the shortcode and adds the shortcode to the registry.