Skip to content
An helper library to create persistent and dismissible WordPress admin notices.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets/js
.distignore
.editorconfig
.gitattributes
.gitignore
LICENSE
composer.json
readme.md
wp-notices.php

readme.md

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
You can’t perform that action at this time.