Shortcodes
in package
Shortcodes Registration class.
Enables the batch registration of shortcodes, simplifying the process of defining and managing custom shortcodes within a WordPress theme or plugin. Utilizes the Shortcode module for each shortcode's registration, ensuring that shortcodes are added in accordance with WordPress standards and best practices.
Tags
Table of Contents
Methods
- set() : void
- Registers multiple shortcodes in bulk.
Methods
set()
Registers multiple shortcodes in bulk.
public
static set([array<string|int, mixed> $shortcodes = [] ]) : void
This method simplifies the registration of custom shortcodes by accepting an array of shortcode definitions. Each definition specifies the shortcode's tag and the function that handles the shortcode's output, allowing for comprehensive and flexible shortcode creation.
Example usage:
Shortcodes::set([
[
'tag' => 'custom_shortcode',
'callback' => 'custom_shortcode_handler_function',
// Optionally, you can specify an action hook for advanced shortcode initialization.
],
...
]);
Parameters
- $shortcodes : array<string|int, mixed> = []
-
An array of shortcode definitions. Each definition is an associative array that includes a 'tag' for the shortcode and a 'callback' for the function that generates the shortcode's output.