Notice

The Admin_Notice class, responsible for creating admin notices.

Each notice is a new instance of the object.

Tags
since
1.0.0

Table of Contents

$dismiss  : Dismiss
An instance of the \WPTRT\AdminNotices\Dismiss object.
$allowed_html  : array<string|int, mixed>
Allowed HTML in the message.
$allowed_types  : array<string|int, mixed>
An array of allowed types.
$id  : string
The notice-ID.
$message  : string
The notice message.
$options  : array<string|int, mixed>
The notice arguments.
__construct()  : mixed
Constructor.
get_classes()  : string
Get the notice classes.
get_message()  : string
Returns the message.
get_title()  : string
Returns the title.
show()  : bool
Determine if the notice should be shown or not.
the_notice()  : void
Prints the notice.
is_screen()  : bool
Evaluate if we're on the right place depending on the "screens" argument.

Properties

$dismiss

An instance of the \WPTRT\AdminNotices\Dismiss object.

public Dismiss $dismiss
Tags
access

public

since
1.0

$allowed_html

Allowed HTML in the message.

private array<string|int, mixed> $allowed_html = ['p' => [], 'a' => ['href' => [], 'rel' => []], 'em' => [], 'strong' => [], 'br' => []]
Tags
access

private

since
1.0

$allowed_types

An array of allowed types.

private array<string|int, mixed> $allowed_types = ['info', 'success', 'error', 'warning']
Tags
access

private

since
1.0

$id

The notice-ID.

private string $id
Tags
access

private

since
1.0

$message

The notice message.

private string $message
Tags
access

private

since
1.0

$options

The notice arguments.

private array<string|int, mixed> $options = ['scope' => 'global', 'type' => 'info', 'alt_style' => false, 'capability' => 'edit_theme_options', 'option_prefix' => 'wptrt_notice_dismissed', 'screens' => []]
Tags
access

private

since
1.0

Methods

__construct()

Constructor.

public __construct(string $id, string $title, string $message[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$id : string

A unique ID for this notice. Can contain lowercase characters and underscores.

$title : string

The title for our notice.

$message : string

The message for our notice.

$options : array<string|int, mixed> = []

An array of additional options to change the defaults for this notice. [ 'screens' => (array) An array of screens where the notice will be displayed. Leave empty to always show. Defaults to an empty array. 'scope' => (string) Can be "global" or "user". Determines if the dismissed status will be saved as an option or user-meta. Defaults to "global". 'type' => (string) Can be one of "info", "success", "warning", "error". Defaults to "info". 'alt_style' => (bool) Whether we want to use alt styles or not. Defaults to false. 'capability' => (string) The user capability required to see the notice. Defaults to "edit_theme_options". 'option_prefix' => (string) The prefix that will be used to build the option (or post-meta) name. Can contain lowercase latin letters and underscores. ].

Tags
access

public

since
1.0
Return values
mixed

get_classes()

Get the notice classes.

public get_classes() : string
Tags
access

public

since
1.0
Return values
string

get_message()

Returns the message.

public get_message() : string
Tags
access

public

since
1.0
Return values
string

get_title()

Returns the title.

public get_title() : string
Tags
access

public

since
1.0
Return values
string

show()

Determine if the notice should be shown or not.

public show() : bool
Tags
access

public

since
1.0
Return values
bool

the_notice()

Prints the notice.

public the_notice() : void
Tags
access

public

since
1.0
Return values
void

is_screen()

Evaluate if we're on the right place depending on the "screens" argument.

private is_screen() : bool
Tags
access

private

since
1.0
Return values
bool

Search results