class shortcode_manager implements shortcode_manager_interface

Shortcode Manager.

Service responsible for managing and rendering shortcodes. Registered as a singleton in the DI container.

Methods

void
register(string $tag, callable $callback)

Registers a shortcode by associating a tag with a callback function.

string
render(string $text)

Processes the given text, parses shortcode patterns, and replaces them with corresponding content based on registered shortcode types.

bool
has(string $tag)

Checks whether a shortcode is registered.

void
clear()

Clears all registered shortcodes.

Details

at line 40
void register(string $tag, callable $callback)

Registers a shortcode by associating a tag with a callback function.

Parameters

string $tag

the name of the shortcode tag to register (case-insensitive)

callable $callback

the callback function that renders the content for the shortcode

Return Value

void

at line 53
string render(string $text)

Processes the given text, parses shortcode patterns, and replaces them with corresponding content based on registered shortcode types.

Parameters

string $text

the input text containing shortcodes to be rendered

Return Value

string

the text with shortcodes replaced by their respective rendered content

at line 87
bool has(string $tag)

Checks whether a shortcode is registered.

Parameters

string $tag

the shortcode tag name to check

Return Value

bool

true if the shortcode is registered; false otherwise

at line 99
void clear()

Clears all registered shortcodes.

Intended for testing purposes only. It will only clear when the PHPUNIT_TEST constant is defined and set to true. In production, this method is a no-op (or you may throw an exception if desired).

Return Value

void