\O3PO_ShortcodeTemplate

A class to represent shortcode templates.

Summary

Methods
Properties
Constants
__construct()
get_shortcodes()
get_shortcode_descriptions()
expand()
example_expand()
render_short_codes()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$shortcodes
$template
N/A

Properties

$shortcodes

$shortcodes : array

Array holding the shortcodes of this template

Type

array — The array keys are the shortcodes, the values are arrays with two fields: 'description' holding the description of the shortcode and 'example' holding an exemplary value which is representative for the values with which the shortcode is ususally replaced. Shortcodes must be of the format [shortcode].

$template

$template : string

The template

Type

string — The string specifying the template.

Methods

__construct()

__construct(string  $template, array  $shortcodes) 

Construct a shortcode template.

Parameters

string $template

The template containing a subset of the shortcodes.

array $shortcodes

Array whose keys are the shortcodes inclosed in [...] and whose values are associative arrays containing a 'description' and an 'example' value for the shortcode.

get_shortcodes()

get_shortcodes() : array

Get all the shortcodes

Returns

array —

The array of all shortcodes.

get_shortcode_descriptions()

get_shortcode_descriptions() : array

Get all the descriptions

Returns

array —

Associative array of shortcode descriptions.

expand()

expand(array  $replacements, boolean  $error_if_not_all_appearing_specified = true) : string

Return the expanded version of the template

Parameters

array $replacements

Array of strings with which to replace the shortcodes. Must be either an array of the same length as $shortcodes or have a subset of shortcodes as array keys and their replacements as values.

boolean $error_if_not_all_appearing_specified

Throw an exception if template contains shortcodes for which no value was provided (default true).

Returns

string —

The expanded template.

example_expand()

example_expand() : string

Return the template with short codes replaced by their example values

Returns

string —

The expanded template based on the examples.

render_short_codes()

render_short_codes() 

Render a list of shortcodes as html to help users.