Skip to content

Underpin-WP/admin-notice-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Underpin Admin Notice Loader

Loader That assists with adding admin notices to a WordPress website.

Installation

Using Composer

composer require underpin/admin-notice-loader

Manually

This plugin uses a built-in autoloader, so as long as it is required before Underpin, it should work as-expected.

require_once(__DIR__ . '/underpin-admin-notices/admin-notices.php');

Setup

  1. Install Underpin. See Underpin Docs
  2. Register new admin notices as-needed.

Example

A very basic example could look something like this. This example would always display a notice on the settings page.

\Underpin\underpin()->admin_notices()->add( 'example-notice', [
	'name'                    => 'Example notice',
	'description'             => 'This notice displays all the time.',
	'type'                    => 'notice',
	'is_dismissible'          => false,
	'wrapper_classes'         => [ 'class-1', 'class-2' ],
	'id'                      => 'example-notice',
	'message'                 => 'This will display all the time.',
	'should_display_callback' => '__return_true',
] );

This would display: image

Alternatively, you can extend Admin_Notice and reference the extended class directly, like so:

underpin()->admin_notices()->add('key','Namespace\To\Class');