PHPackages                             thanks-to-it/wp-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. [Admin Panels](/categories/admin)
4. /
5. thanks-to-it/wp-admin-notices

ActiveLibrary[Admin Panels](/categories/admin)

thanks-to-it/wp-admin-notices
=============================

Manage WordPress Admin Notices easily

51132PHP

Since Feb 21Pushed 7y ago1 watchersCompare

[ Source](https://github.com/thanks-to-it/wp-admin-notices)[ Packagist](https://packagist.org/packages/thanks-to-it/wp-admin-notices)[ RSS](/packages/thanks-to-it-wp-admin-notices/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

WP Admin Notices
================

[](#wp-admin-notices)

An easy and convenient way to create WordPress admin notices that can be closed persistently. Besides that it has some cool features:

- Keep your notices hidden only for the user who closed it.
- Display your notice on specific situations, like when some plugin gets updated or activated or on specific admin screen ids or on $\_GET / $\_POST requests,
- [Create your own special cases](https://github.com/thanks-to-it/wp-admin-notices/wiki/Custom-display_on) where/when your notice should be displayed

Simple Usage
------------

[](#simple-usage)

```
add_action( 'admin_notices', function () {
	$notices_manager = \ThanksToIT\WPAN\get_notices_manager();
	$notices_manager->create_notice( array(
		'id'         => 'my-notice',
		'content'    => 'My Notice',
	) );
} );
```

**Note:** By default, this library will make notices persist, meaning they will not be displayed again after user close them, unless they expire

Initialization
--------------

[](#initialization)

In order to make it work perfectly, you need to **initialize** it like this:

```
add_action( 'wp_ajax_' . 'tttwpan_dismiss_persist', array( 'ThanksToIT\WPAN\Notices_Manager', 'ajax_dismiss' ) );
add_action( 'activated_plugin', array( 'ThanksToIT\WPAN\Notices_Manager', 'set_activated_plugin' ) );
add_action( 'upgrader_process_complete', array( 'ThanksToIT\WPAN\Notices_Manager', 'set_upgrader_process' ), 10, 2 );
```

And it's **important** to make these calls before **any other hook** on your plugin/theme. But don't worry, this library will be loaded only when it's necessary, as it's being called on the proper hooks

create\_notice() parameters
---------------------------

[](#create_notice-parameters)

- **id** (String) - Identifies the notice.
- **type** (String) - The type of notice, used on notice class in order to setup its color. Possible values are `'notice-info'`, `'notice-warning'`, `'notice-success'`, `'notice-error'`, `'notice-info'`. Default value is `'notice-info'`.
- **content** (String) - Notice content.
- **dismissible** (Boolean) - If notice should be dismissible. In other words, if you can close it. Default is `true`.
- **dismissal\_expiration** (int) - How long in seconds the notice will keep closed. Values bigger than zero will make the notice persist after closed. If you set 0, it will no longer persist. Default is `MONTH_IN_SECONDS`.
- **display\_on** (array) - Situations where/when the notice should be displayed. Possible values below:
    - **screen\_id** (array). Displays the notice on specific admin screen ids. Example: `'screen_id' => array( 'plugins' )`.
    - **activated\_plugin** (array). Displays if some plugin gets activated. Example: `'activated_plugin' => array('akismet/akismet.php')`.
    - **updated\_plugin** (array). Displays if some plugin gets updated. Example: `'updated_plugin' => array('akismet/akismet.php')`.
    - **request** (array) - Displays on $\_GET or $\_POST values. Note: It takes an array of arrays with `'key'` and `'value'` parameters. Example: `'request' => array( array( 'key' => 'show_notice', 'value' => '1' ), ) `.
- **keep\_active\_on** (array) - Keeps the notice always opened once the display\_on requirements are met, until the user close the notice. Default value is `array( 'activated_plugin', 'updated_plugin' )`,

Examples
--------

[](#examples)

### Create a notice that will be closed for 1 week

[](#create-a-notice-that-will-be-closed-for-1-week)

```
add_action( 'admin_notices', function () {
	$notices_manager = \ThanksToIT\WPAN\get_notices_manager();
	$notices_manager->create_notice( array(
		'id'         => '1-week-notice',
		'content'    => '1 week notice',
		'dismissal_expiration' => WEEK_IN_SECONDS,
	) );
} );
```

### Create a notice that will be displayed on plugins page only

[](#create-a-notice-that-will-be-displayed-on-plugins-page-only)

```
add_action( 'admin_notices', function () {
	$notices_manager = \ThanksToIT\WPAN\get_notices_manager();
	$notices_manager->create_notice( array(
		'id'         => 'plugins-page-notice',
		'content'    => 'plugins page notice',
		'display_on' => array(
			'screen_id' => array( 'plugins' ),
		)
	) );
} );
```

### Create a notice that will be displayed after the [Akismet](https://br.wordpress.org/plugins/akismet/) plugin gets activated

[](#create-a-notice-that-will-be-displayed-after-the-akismet-plugin-gets-activated)

```
add_action( 'admin_notices', function () {
	$notices_manager = \ThanksToIT\WPAN\get_notices_manager();
	$notices_manager->create_notice( array(
		'id'         => 'akismet-notice',
		'content'    => 'Akismet notice',
		'display_on' => array(
			'activated_plugin' => array('akismet/akismet.php')
		)
	) );
} );
```

Package Installation (via Composer)
-----------------------------------

[](#package-installation-via-composer)

To install this package, edit your `composer.json` file:

```
{
    "require": {
        "thanks-to-it/wp-admin-notices": "dev-master"
    }
}
```

Now run:

`$ composer install`

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b4b75988e6d015150217b3b9730d2341eae639521e0d6de0578b48b94f35d11?d=identicon)[pablo.pacheco](/maintainers/pablo.pacheco)

---

Top Contributors

[![pablo-sg-pacheco](https://avatars.githubusercontent.com/u/8193404?v=4)](https://github.com/pablo-sg-pacheco "pablo-sg-pacheco (49 commits)")

---

Tags

adminadmin-dashboardnoticenoticeswordpress

### Embed Badge

![Health badge](/badges/thanks-to-it-wp-admin-notices/health.svg)

```
[![Health](https://phpackages.com/badges/thanks-to-it-wp-admin-notices/health.svg)](https://phpackages.com/packages/thanks-to-it-wp-admin-notices)
```

###  Alternatives

[jeroennoten/laravel-adminlte

Easy AdminLTE integration with Laravel

4.0k4.8M43](/packages/jeroennoten-laravel-adminlte)[dmstr/yii2-adminlte-asset

AdminLTE backend theme asset bundle for Yii 2.0 Framework

1.1k1.8M67](/packages/dmstr-yii2-adminlte-asset)[dwij/laraadmin

LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like CRUD Generation, Module Manager, Media, Menus, Backups and much more

1.6k68.7k](/packages/dwij-laraadmin)[filament/spatie-laravel-media-library-plugin

Filament support for `spatie/laravel-medialibrary`.

1764.8M125](/packages/filament-spatie-laravel-media-library-plugin)[bezhansalleh/filament-exceptions

A Simple &amp; Beautiful Pluggable Exception Viewer for FilamentPHP's Admin Panel

193195.9k13](/packages/bezhansalleh-filament-exceptions)[filament/infolists

Easily add beautiful read-only infolists to any Livewire component.

1220.8M36](/packages/filament-infolists)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
