Messages
in package
Provide messages for frontend display.
Tags
Table of Contents
Constants
- BANNER_CONTAINER = 'banner.php'
- Banner container partial.
- SNACKBAR_CONTAINER = 'snackbar.php'
- Snackbar container partial.
Properties
- $banner_container : string
- The fully qualified path to the banner container partial.
- $helper : Content
- The instance of the helper class.
- $icons : Icons
- The instance of the SVG icon handler.
- $instances : array<string|int, object>
- The array of instances of this class and sub-classes.
- $snackbar_container : string
- The fully qualified path to the snackbar container partial.
Methods
- get_banner() : string
- Return a rendered banner message.
- get_instance() : object
- Creates and/or returns the instance of this class.
- get_message() : string
- Finds and returns the message text for the given code.
- get_snackbar() : string
- Return a rendered snackbar message.
- __construct() : void
- Initialise the class.
- get_message_class() : string
- Returns the message class for the given level.
Constants
BANNER_CONTAINER
Banner container partial.
protected
string
BANNER_CONTAINER
= 'banner.php'
Tags
SNACKBAR_CONTAINER
Snackbar container partial.
protected
string
SNACKBAR_CONTAINER
= 'snackbar.php'
Tags
Properties
$banner_container
The fully qualified path to the banner container partial.
protected
string
$banner_container
= ''
Tags
$helper
The instance of the helper class.
protected
Content
$helper
Tags
$icons
The instance of the SVG icon handler.
protected
Icons
$icons
Tags
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
$snackbar_container
The fully qualified path to the snackbar container partial.
protected
string
$snackbar_container
= ''
Tags
Methods
get_banner()
Return a rendered banner message.
public
get_banner(string $code[, string $level = 'info' ][, string $redirect = '' ][, array<string|int, string> $buttons = array() ]) : string
Parameters
- $code : string
-
The message to retrieve and render.
- $level : string = 'info'
-
Optional. The level of notification to generate. Defaults to info.
- $redirect : string = ''
-
Optional. A URL to redirect to when the banner is closed. Default is empty.
- $buttons : array<string|int, string> = array()
-
Optional. An array of additional buttons on banner. Default is empty. @type string $url The fully qualified URL for the button link. @type string $text The text for the button. @type string $title The title attribute for the button.
Tags
Return values
string —The rendered banner, or empty if code is invalid.
get_instance()
Creates and/or returns the instance of this class.
public
static get_instance() : object
Tags
Return values
object —The instance of this class.
get_message()
Finds and returns the message text for the given code.
public
get_message(string $code) : string
Parameters
- $code : string
-
The message code to look up.
Tags
Return values
string —The message text.
get_snackbar()
Return a rendered snackbar message.
public
get_snackbar(string $code[, string $level = 'info' ]) : string
Parameters
- $code : string
-
The message to retrieve and render.
- $level : string = 'info'
-
Optional. The level of notification to generate. Defaults to info.
Tags
Return values
string —The rendered snackbar, or empty if code invalid.
__construct()
Initialise the class.
protected
__construct() : void
Tags
get_message_class()
Returns the message class for the given level.
protected
get_message_class([string $level = 'info' ]) : string
Parameters
- $level : string = 'info'
-
Optional. The level of notification to generate. Defaults to info.
Tags
Return values
string —The message class.