Skip to content

An helper library to create persistent and dismissible WordPress admin notices.

License

Notifications You must be signed in to change notification settings

WPUserManager/wp-notices

Repository files navigation

wp-notices

Packagist Packagist3 Packagist2 PHP from Packagist Github commits (since latest release)

An helper library to create persistent and dismissible WordPress admin notices.

Installation

Composer is required.

composer require alessandrotesoro/wp-notices

Usage

Import the library and assign it your own namespace:

use TDP\WP_Notice as MYNOTICES;

Create a wrapper function:

function mynotices() {
	return MYNOTICES::instance();
}

Create a global notice for all users:

mynotices()->register_notice( 'my_notice', 'warning', 'This is the message' ) );

Or create a notice for the currently logged in user only:

mynotices()->register_notice( 'my_notice', 'warning', 'This is the message', array( 'scope' => 'user' ) ) );

Available parameters

Parameter Type Options Defaults Description
id string Required ID to identify the notice
type string success, warning, error, info Determine the type of notice
message string The message you wish to display within WordPress
args array scope (global, user), dismissible (true/false), cap, class scope = global, dismissible = true Additional settings available for the notice

About

An helper library to create persistent and dismissible WordPress admin notices.

Resources

License

Stars

Watchers

Forks

Packages

No packages published