shazzad / wp-admin-notice
Library to add & display admin notices in WordPress
Installs: 543
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:wordpress-library
This package is auto-updated.
Last update: 2025-07-29 02:33:52 UTC
README
Helper class to display admin notices.
Installation
composer require shazzad/wp-admin-notice
Initialization
Initialize the service provider.
\Shazzad\WpAdminNotice\Provider::setup();
Adding notice.
Call the function do_action
with appropriate parameter to add a notice.
This code must be placed before wp admin area start rendering content on screen.
Use admin_notices
, all_admin_notices
or network_admin_notices
action hook to add notice.
do_action( 'swpan_notice', array( 'success' => __('You setting is stored successfully.'), 'id' => 'plugin-setting', ) ); do_action( 'swpan_notice', array( 'error' => __('Sorry, we could not save your settings.'), ) );
Adding user notice.
Use user notice when you perform some action and redirect the user to a page. The notice will be stored for until it is displayed to the user. Add a third parameter to the action hook to add a user notice.
do_action( 'swpan_notice', array( 'message' => __('You setting is stored successfully.'), 'type' => 'success', 'id' => 'my-notice-id', ), 'user' ); do_action( 'swpan_notice', array( 'message' => __('Sorry, we could not save your settings.'), 'type' => 'error', 'id' => 'my-notice-id', ), 'user' );
Requirements
- WordPress: 6.0.1
- PHP: 7.4
- Tested: 6.2.2