awesome9 / notifications
WordPress notification ceneter.
1.0.2
2021-07-10 02:03 UTC
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2024-12-10 10:34:47 UTC
README
📃 About Notifications
This package provides ease of managing temporary and permanent notification within WordPress.
💾 Installation
composer require awesome9/notifications
🕹 Usage
First, you need to spin out configuration for your notification center.
Awesome9\Notifications\Center::get() ->set_storage( 'awesome9_plugin_notifications' ); // Option name to be save persistent notifications in DB.
Now, let's add and remove some data to be output in admin.
// This notification shows once its a temporary notification. Awesome9\Notifications\Center::get() ->add( 'Your message goes here.', array( 'id' => 'awesome9_some_id' 'type' => \Awesome9\Notifications\Notification::ERROR, 'screen' => 'post', 'classes' => 'style-me-custom' ) ); // Now let's add a persistent one which is dismissible by user. Awesome9\Notifications\Center::get() ->add( 'Your message goes here.', array( 'id' => 'awesome9_some_id_2' 'type' => \Awesome9\Notifications\Notification::ERROR, 'persistent' => 'some_unique_Id', 'screen' => 'post', 'classes' => 'style-me-custom' ) ); // Let's remove a notification. Awesome9\Notifications\Center::get() ->remove( 'awesome9_some_id' )
Available options to pass in add function
Helper functions
You can use the procedural approach as well:
Awesome9\Notifications\add( $message, $options = array() ); Awesome9\Notifications\remove( $notification_id );
All the parameters remains the same as for the JSON
class.