https://github.com/underpin-wp/admin-notice-loader
Adds admin notices to WordPress admin area.
https://github.com/underpin-wp/admin-notice-loader
admin-notices underpin wordpress
Last synced: about 1 month ago
JSON representation
Adds admin notices to WordPress admin area.
- Host: GitHub
- URL: https://github.com/underpin-wp/admin-notice-loader
- Owner: Underpin-WP
- Created: 2021-05-03T13:42:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-24T21:30:11.000Z (over 4 years ago)
- Last Synced: 2025-03-08T01:01:52.168Z (over 1 year ago)
- Topics: admin-notices, underpin, wordpress
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 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](https://www.github.com/underpin-wp/underpin)
1. 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.
```php
\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:

Alternatively, you can extend `Admin_Notice` and reference the extended class directly, like so:
```php
underpin()->admin_notices()->add('key','Namespace\To\Class');
```