AdminNotification
Display Wordpress admin notification banners. This class consists of mostly static helper methods to display and store notification data as COOKIE values (since Wordpress does a number of internal redirects).
Table of Contents
- COOKIE_KEY = 'flash_message'
- MESSAGE_TYPE_ERROR = 'error'
- MESSAGE_TYPE_INFO = 'info'
- MESSAGE_TYPE_WARNING = 'warning'
- error() : void
- A shortcut for AdminNotification::MESSAGE_TYPE_ERROR notification types.
- flashMessage() : void
- Display the stored cookie message.
- info() : void
- A shortcut for AdminNotification::MESSAGE_TYPE_INFO notification types.
- message() : void
- Display an admin notification. If the notification needs to survive a Wordpress redirect, set the $flash value to "true". Available types:
- warning() : void
- A shortcut for AdminNotification::MESSAGE_TYPE_WARNING notification types.
Constants
COOKIE_KEY
public
mixed
COOKIE_KEY
= 'flash_message'
MESSAGE_TYPE_ERROR
public
mixed
MESSAGE_TYPE_ERROR
= 'error'
MESSAGE_TYPE_INFO
public
mixed
MESSAGE_TYPE_INFO
= 'info'
MESSAGE_TYPE_WARNING
public
mixed
MESSAGE_TYPE_WARNING
= 'warning'
Methods
error()
A shortcut for AdminNotification::MESSAGE_TYPE_ERROR notification types.
public
static error(string $message[, bool $flash = false ]) : void
Parameters
- $message : string
- $flash : bool = false
Return values
void —flashMessage()
Display the stored cookie message.
public
static flashMessage() : void
Return values
void —info()
A shortcut for AdminNotification::MESSAGE_TYPE_INFO notification types.
public
static info(string $message[, bool $flash = false ]) : void
Parameters
- $message : string
- $flash : bool = false
Return values
void —message()
Display an admin notification. If the notification needs to survive a Wordpress redirect, set the $flash value to "true". Available types:
public
static message([string $message = '' ][, string $type = AdminNotification::MESSAGE_TYPE_INFO ][, bool $flash = false ]) : void
AdminNotification::MESSAGE_TYPE_ERROR
AdminNotification::MESSAGE_TYPE_INFO
AdminNotification::MESSAGE_TYPE_WARNING
Parameters
- $message : string = ''
- $type : string = AdminNotification::MESSAGE_TYPE_INFO
- $flash : bool = false
-
Default is false.
Return values
void —warning()
A shortcut for AdminNotification::MESSAGE_TYPE_WARNING notification types.
public
static warning(string $message[, bool $flash = false ]) : void
Parameters
- $message : string
- $flash : bool = false