Documentation

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
since
1.0.0

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
since
1.0.0

__toString()

Custom toString magic method.

public __toString() : string

Returns the shortcode as a JSON string.

Tags
since
1.0.0
Return values
string

JSON string.

initialize()

Initializes the shortcode.

private initialize() : void

Hooks the action to register the shortcode and adds the shortcode to the registry.

Tags
since
1.0.0

        
On this page

Search results