PHPackages                             wpscholar/wp-transient-admin-notices - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wpscholar/wp-transient-admin-notices

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wpscholar/wp-transient-admin-notices
====================================

Display admin notices in WordPress after a page redirect or reload.

1.0(8y ago)534GPL-2.0+PHP

Since Nov 2Pushed 8y ago1 watchersCompare

[ Source](https://github.com/wpscholar/wp-transient-admin-notices)[ Packagist](https://packagist.org/packages/wpscholar/wp-transient-admin-notices)[ RSS](/packages/wpscholar-wp-transient-admin-notices/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

WordPress Transient Admin Notices
=================================

[](#wordpress-transient-admin-notices)

Handles the display of admin notices in WordPress after a page redirect or reload.

Details
-------

[](#details)

When creating a new instance of `TransientAdminNotices`, you will need to provide a transient name. This is used as either the cache key, when caching is enabled, or the database option name, if caching isn't an option. If you're notice is user-specific, be sure to scope your transient name to the user.

Ensure that you instantiate the class on the `admin_init` hook. This ensures that the class can automatically setup a hook to render your notices on the `admin_notices` hook and that it only runs in the WordPress admin. Note that you must create an instance, even if you are not adding new notices, in order for notices from a previous page load to display.

All notices added to your instance require a key, the message you want to display, and the notice type. The key can be any string you want and can be used to later get or remove that specific notice from the queue.

Notice Types
------------

[](#notice-types)

These notice types are the types provided by WordPress, but can be passed in to the `add()` method to customize how your notices will display.

- `success` - Displays with a green bar
- `info` - Displays with a blue bar (default)
- `warning` - Displays with an orange bar
- `error` - Displays with a red bar

Sample Usage
------------

[](#sample-usage)

```
