Documentation

O3PO_ShortcodeTemplate
in package

A class to represent shortcode templates.

Tags
subpackage

O3PO/includes

author

Christian Gogolin o3po@quantum-journal.org

Table of Contents

Properties

$shortcodes  : array<string|int, mixed>
Array holding the shortcodes of this template
$template  : string
The template

Methods

__construct()  : mixed
Construct a shortcode template.
example_expand()  : string
Return the template with short codes replaced by their example values
expand()  : string
Return the expanded version of the template
get_shortcode_descriptions()  : array<string|int, mixed>
Get all the descriptions
get_shortcodes()  : array<string|int, mixed>
Get all the shortcodes
render_short_codes()  : mixed
Render a list of shortcodes as html to help users.

Properties

$shortcodes

Array holding the shortcodes of this template

private array<string|int, mixed> $shortcodes

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].

Tags
since
0.4.0
access

private

Methods

__construct()

Construct a shortcode template.

public __construct(string $template, array<string|int, mixed> $shortcodes) : mixed
Parameters
$template : string

The template containing a subset of the shortcodes.

$shortcodes : array<string|int, mixed>

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

Tags
since
0.4.0
access

public

example_expand()

Return the template with short codes replaced by their example values

public example_expand() : string
Tags
since
0.4.0
access

public

Return values
string —

The expanded template based on the examples.

expand()

Return the expanded version of the template

public expand(array<string|int, mixed> $replacements[, bool $error_if_not_all_appearing_specified = true ]) : string
Parameters
$replacements : array<string|int, mixed>

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.

$error_if_not_all_appearing_specified : bool = true

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

Tags
since
0.4.0
access

public

Return values
string —

The expanded template.

get_shortcode_descriptions()

Get all the descriptions

public get_shortcode_descriptions() : array<string|int, mixed>
Tags
since
0.4.0
access

public

Return values
array<string|int, mixed> —

Associative array of shortcode descriptions.

get_shortcodes()

Get all the shortcodes

public get_shortcodes() : array<string|int, mixed>
Tags
since
0.4.0
access

public

Return values
array<string|int, mixed> —

The array of all shortcodes.

render_short_codes()

Render a list of shortcodes as html to help users.

public render_short_codes() : mixed
Tags
sinde

0.4.0

access

public


        
On this page

Search results