PHPackages                             wpdesk/wp-notice - 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. wpdesk/wp-notice

ActiveLibrary[Admin Panels](/categories/admin)

wpdesk/wp-notice
================

Library for displaying Wordpress notices.

3.3.0(1y ago)071.3k↑15.6%13MITPHPPHP &gt;=7.4CI failing

Since Sep 25Pushed 1mo agoCompare

[ Source](https://github.com/WP-Desk/wp-notice)[ Packagist](https://packagist.org/packages/wpdesk/wp-notice)[ Docs](https://gitlab.com/wpdesk/wp-notice)[ RSS](/packages/wpdesk-wp-notice/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (8)Versions (39)Used By (13)

[![pipeline status](https://camo.githubusercontent.com/4288de72586fb84bfddea283e710c0d00a155daeffc1ddbead66678a19046d0e/68747470733a2f2f6769746c61622e636f6d2f77706465736b2f77702d6e6f746963652f6261646765732f6d61737465722f706970656c696e652e737667)](https://gitlab.com/wpdesk/wp-notice/pipelines)[![coverage report](https://camo.githubusercontent.com/b66e9326b8c6eb1ade3090f85b536e1a896e8b7e0cec51c8a3821502a29325d8/68747470733a2f2f6769746c61622e636f6d2f77706465736b2f77702d6e6f746963652f6261646765732f6d61737465722f636f7665726167652e7376673f6a6f623d696e746567726174696f6e2b746573742b6c6173746573742b636f766572616765)](https://gitlab.com/wpdesk/wp-notice/commits/master)[![Latest Stable Version](https://camo.githubusercontent.com/facedee6cbfa73c159659430b6acdfb3b96bb631d9ebc3ce24a8417b9d76f942/68747470733a2f2f706f7365722e707567782e6f72672f77706465736b2f77702d6e6f746963652f762f737461626c65)](https://packagist.org/packages/wpdesk/wp-notice)[![Total Downloads](https://camo.githubusercontent.com/b279e75bbcc3440fbba1715c1f0d0317b76d9d39c73347b088f0f3143a9cad2e/68747470733a2f2f706f7365722e707567782e6f72672f77706465736b2f77702d6e6f746963652f646f776e6c6f616473)](https://packagist.org/packages/wpdesk/wp-notice)[![Latest Unstable Version](https://camo.githubusercontent.com/2751b78e033142151d7bf03825567e0e0d35cadddaffab9bb1611fc1d54885ca/68747470733a2f2f706f7365722e707567782e6f72672f77706465736b2f77702d6e6f746963652f762f756e737461626c65)](https://packagist.org/packages/wpdesk/wp-notice)[![License](https://camo.githubusercontent.com/5854d5456e7be8f3244811182498086512f8abfe09d6496ce22489acbfa55334/68747470733a2f2f706f7365722e707567782e6f72672f77706465736b2f77702d6e6f746963652f6c6963656e7365)](https://packagist.org/packages/wpdesk/wp-notice)

wp-notice
=========

[](#wp-notice)

A simple library for WordPress plugins that displays admin notices. This package is a Composer library intended to be loaded by a plugin; it is not a standalone WordPress plugin.

It can be used to:

- Display simple error, warning, success and info notices.
- Display non-persistent WordPress dismissible notices.
- Display permanently dismissible notices.
- Handle permanent dismiss actions with AJAX requests.
- Display notices in the block editor when the notice is created with Gutenberg support enabled.

Requirements
------------

[](#requirements)

- PHP 7.4 or later.
- WordPress admin context.
- Composer is recommended for installation and autoloading.

Installation via Composer
-------------------------

[](#installation-via-composer)

Install the package with [Composer](https://getcomposer.org/):

```
composer require wpdesk/wp-notice
```

Load Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading) in your plugin:

```
require_once 'vendor/autoload.php';
```

Manual installation
-------------------

[](#manual-installation)

If you prefer not to use Composer in the target plugin, download a built library release, for example the [latest library artifact](https://gitlab.com/wpdesk/wp-notice/-/jobs/artifacts/master/download?job=library), and include `init.php`:

```
require_once '/path/to/wp-notice/init.php';
```

The `init.php` file loads `vendor/autoload.php`. If you install from a source checkout instead of a built artifact, run `composer install` first so the `vendor` directory exists.

Getting Started
---------------

[](#getting-started)

### Notices usage example

[](#notices-usage-example)

```
$notice = wpdesk_wp_notice('Notice text goes here');

// Is equivalent to:
$notice = WPDeskWpNotice('Notice text goes here');

// Is equivalent to:
$notice = \WPDesk\Notice\Factory::notice('Notice text goes here');

// Is equivalent to:
$notice = new \WPDesk\Notice\Notice('Notice text goes here');
```

A notice object registers itself on `admin_notices` and `admin_footer`. Create it before WordPress runs `admin_notices`; for example, create it during your plugin bootstrap or on an earlier admin hook such as `admin_init`. The object removes its hooks after output, so the same object is rendered once.

### Notice types

[](#notice-types)

The supported notice types are `info`, `error`, `warning` and `success`.

```
wpdesk_wp_notice_info('Information message');
wpdesk_wp_notice_error('Error message');
wpdesk_wp_notice_warning('Warning message');
wpdesk_wp_notice_success('Success message');
```

The generic helper accepts the type, dismissible flag and priority:

```
wpdesk_wp_notice('Notice text goes here', 'warning', true, 20);
```

The parameters are:

- `$noticeContent` - notice content.
- `$noticeType` - one of `info`, `error`, `warning`, `success`; defaults to `info`.
- `$dismissible` - adds the WordPress `is-dismissible` class; defaults to `false`.
- `$priority` - hook priority for displaying the notice; defaults to `10`.

Notice content is wrapped in a `` tag unless it already starts with `` or ``. The final output is passed through `wp_kses_post()`.

### Custom attributes

[](#custom-attributes)

When you need custom attributes or classes, use the returned object:

```
$notice = wpdesk_wp_notice_warning('Notice text goes here');
$notice->addAttribute('id', 'my-notice');
$notice->addAttribute('class', 'my-custom-class');
```

The `class` attribute is appended to the generated WordPress notice classes.

Permanently dismissible notices
-------------------------------

[](#permanently-dismissible-notices)

### AJAX handler

[](#ajax-handler)

To use permanently dismissible notices, initialize the AJAX handler before admin scripts are enqueued:

```
wpdesk_init_wp_notice_ajax_handler();

// Is equivalent to:
( new \WPDesk\Notice\AjaxHandler() )->hooks();
```

You can pass a custom assets URL if your plugin bundles the library assets in a non-standard location:

```
wpdesk_init_wp_notice_ajax_handler('https://example.com/wp-content/plugins/my-plugin/vendor/wpdesk/wp-notice/assets/');
```

The assets URL must point to the directory containing `js/notice.js`, `js/gutenberg.js` and `css/admin.css`.

### Displaying the permanently dismissible notices

[](#displaying-the-permanently-dismissible-notices)

Use the following code to display a permanently dismissible notice:

```
wpdesk_permanent_dismissible_wp_notice( 'Notice text goes here', 'notice-name' );

// Is equivalent to
$notice = new \WPDesk\Notice\PermanentDismissibleNotice( 'Notice text goes here', 'notice-name' );
```

The helper accepts notice content, a stable notice name, notice type and priority:

```
wpdesk_permanent_dismissible_wp_notice(
    'Notice text goes here',
    'notice-name',
    'warning',
    20
);
```

The notice name is used to build the WordPress option name `wpdesk_notice_dismiss_{noticeName}`. When the notice is dismissed, the AJAX handler validates the nonce, requires `current_user_can('edit_posts')`, stores the option value `1` and fires the `wpdesk_notice_dismissed_notice` action with the notice name and optional source.

```
add_action('wpdesk_notice_dismissed_notice', function ($noticeName, $source) {
    // React to a permanently dismissed notice.
}, 10, 2);
```

Dismissal is stored in a WordPress option, so it is site-wide rather than per-user. To show a dismissed notice again, call `undoDismiss()` on the `PermanentDismissibleNotice` object.

### Gutenberg notices

[](#gutenberg-notices)

When constructing notices directly, the last constructor argument enables block editor support:

```
new \WPDesk\Notice\Notice(
    'Notice text goes here',
    'info',
    true,
    10,
    [],
    true
);
```

The AJAX handler always enqueues `js/notice.js`. It additionally enqueues `js/gutenberg.js` in the block editor and `css/admin.css` outside the block editor. Gutenberg-targeted notices receive the `wpdesk-notice-gutenberg` class.

Development
-----------

[](#development)

Install dependencies:

```
composer install
```

Available Composer scripts:

```
composer phpcs
composer phpunit-unit
composer phpunit-unit-fast
composer phpunit-integration
composer phpunit-integration-fast
```

The test suites use the PHPUnit configuration files included in the repository.

Project documentation
---------------------

[](#project-documentation)

PHPDoc:

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance70

Regular maintenance activity

Popularity27

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 89.2% 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.

###  Release Activity

Cadence

Every ~80 days

Recently: every ~201 days

Total

31

Last Release

458d ago

Major Versions

1.0.2 → 2.02018-10-08

2.3 → 3.02019-02-21

PHP version history (3 changes)1.0PHP &gt;=5.5

3.2.2PHP &gt;=7.0.8

3.3.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/16497f8884c0767d3a114cc1cf8daaa639bac052178b03c59d59dfa95569d50b?d=identicon)[dyszczo](/maintainers/dyszczo)

![](https://www.gravatar.com/avatar/e6b9d73e70788735e2d8af0fba63affafdea243effde5eeae3e6fbb1e5d828e6?d=identicon)[grola](/maintainers/grola)

![](https://www.gravatar.com/avatar/97ac8b53a77161e994c106cc2136cf0601d404e5fd4a3295884d692c767636c7?d=identicon)[bjaskulski](/maintainers/bjaskulski)

![](https://www.gravatar.com/avatar/2f0fae5494288bf0f4a8d503303f10043a9efed544696d7244a9510c2e430ce0?d=identicon)[wpdesk-marcin](/maintainers/wpdesk-marcin)

---

Top Contributors

[![seostudio](https://avatars.githubusercontent.com/u/8124521?v=4)](https://github.com/seostudio "seostudio (107 commits)")[![dyszczo](https://avatars.githubusercontent.com/u/1263190?v=4)](https://github.com/dyszczo "dyszczo (8 commits)")[![bart-jaskulski](https://avatars.githubusercontent.com/u/56613051?v=4)](https://github.com/bart-jaskulski "bart-jaskulski (5 commits)")

---

Tags

wordpressadminnotice

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/wpdesk-wp-notice/health.svg)

```
[![Health](https://phpackages.com/badges/wpdesk-wp-notice/health.svg)](https://phpackages.com/packages/wpdesk-wp-notice)
```

###  Alternatives

[wecodemore/current-admin-info

Displays info about the current admin screen and its globals, contextual hooks, etc.

842.7k](/packages/wecodemore-current-admin-info)

PHPackages © 2026

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