alessandrotesoro/wp-notices

This package is abandoned and no longer maintained. No replacement package was suggested.

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

1.0.3 2019-05-29 11:24 UTC

This package is auto-updated.

Last update: 2020-09-29 14:09:12 UTC


README

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