PHPackages                             pressmodo/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. pressmodo/wp-admin-notices

ActiveLibrary[Admin Panels](/categories/admin)

pressmodo/wp-admin-notices
==========================

An helper library to create persistent and dismissible WordPress admin notices.

1.1.3(5y ago)3311GPL-3.0-or-laterPHPPHP &gt;=5.6

Since Feb 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Pressmodo/wp-admin-notices)[ Packagist](https://packagist.org/packages/pressmodo/wp-admin-notices)[ Docs](https://github.com/pressmodo/wp-admin-notices)[ RSS](/packages/pressmodo-wp-admin-notices/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

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

[](#wp-admin-notices)

An helper library to create persistent and dismissible WordPress admin notices.

Notices created using this method are automatically dismissible.

Usage
-----

[](#usage)

```
$my_notices = new \Pressmodo\AdminNotices\Notices();

// Add a notice.
$my_notices->add( (string) $id, (string) $title, (string) $content, (array) $options );

// Boot things up.
$my_notices->boot();
```

After you instantiate the `Notices` object using `$my_notices = new \Pressmodo\AdminNotices\Notices();` you can add new notices using the `add()` method.

The arguments of this method are:

ParameterTypeDescription`$id``string`RequiredA unique ID for this notice. **The ID can contain lowercase latin letters and underscores**. It is used to construct the option (or user-meta) key that will be strored in the database.`$title``string`RequiredThe title for your notice. If you don't want to use a title you can use set it to `false`.`$message``string`RequiredThe content for the notice you want to create. Please note that the only acceptable tags here are ``, ``, ``, ``.`$options``array`OptionalExtra arguments for this notice. Can be used to alter the notice's default behavior.The `$options` argument is an array that can have the following optional items:

KeyTypeValueDefault`scope``string`Can be `global` or `user`. Determines if the dismissed status will be saved as an option or user-meta.`global``type``string`Can be one of `info`, `success`, `warning`, `error`.`info``alt_style``bool`Set to true if you want to use alternative styles. These have a background-color depending on the `type` argument - in contrast to the normal styles that use a white background.`false``dismissible``bool`Set to false to make the notice non dismissible.`true``capability``string`The user capability required to see the notice. For a list of all available capabilities please refer to the [Roles and Capabilities](https://wordpress.org/support/article/roles-and-capabilities/) article.`edit_theme_options``screens``array`An array of screens where the notice will be displayed. For a reference of all available screen-IDs, refer to [this article](https://codex.wordpress.org/Plugin_API/Admin_Screen_Reference).`[]``option_prefix``string`The prefix that will be used to build the option (or user-meta) name. Can contain lowercase latin letters and underscores. The actual option is built by combining the `option_prefix` argument with the defined ID from the 1st argument of the `add()` method.`pressmodo_notice_dismissed`Examples
--------

[](#examples)

You can add the following code within your theme's existing code.

First we need to instantiate the `Notices` object:

```
use Pressmodo\AdminNotices\Notices;

$my_notices = new Notices();
```

To add a simple, default notice:

```
$my_notices->add(
    'my_theme_notice',                           // Unique ID.
    esc_html__( 'Notice Title', 'textdomain' ),  // The title for this notice.
    esc_html__( 'Notice content', 'textdomain' ) // The content for this notice.
);
```

The above example will create a new notice that will only show on all dashboard pages. When the notice gets dismissed, a new option will be saved in the database with the key `pressmodo_notice_dismissed_my_theme_notice`. The key gets created by appending the `$id` to the default prefix for the option (`pressmodo_notice_dismissed`), separated by an underscore.

To add a more customized notice:

```
$my_notices->add(
    'my_notice',                                  // Unique ID.
    esc_html__( 'Notice Title', 'textdomain' ),   // The title for this notice.
    esc_html__( 'Notice content', 'textdomain' ), // The content for this notice.
    [
        'scope'         => 'user',       // Dismiss is per-user instead of global.
        'screens'       => [ 'themes' ], // Only show notice in the "themes" screen.
        'type'          => 'warning',    // Make this a warning (orange color).
        'alt_style'     => true,         // Use alt styles.
        'option_prefix' => 'my_theme',   // Change the user-meta prefix.
    ]
);
```

The above example will create a new notice that will only show in the "Themes" screen in the dashboard. When the notice gets dismissed, a new user-meta will be saved and the key for the stored user-meta will be `my_theme_my_notice`. The key gets created by appending the `$id` to our defined `option_prefix`, separated by an underscore.

The `Notices` class can be used to add multiple notices. Once you have finished adding the notices, you will have to run the `boot` method so that the notices can be added to the dashboard:

```
$my_notices->boot();
```

To sum up all the above, a complete example of how to add an admin notice would look like this:

```
$my_notices = new \Pressmodo\AdminNotices\Notices();
$my_notices->add( 'my_theme_notice', __( 'Title', 'textdomain' ), __( 'Content', 'textdomain' ) );
$my_notices->boot();
```

Autoloading
-----------

[](#autoloading)

You'll need to use an autoloader with this. Ideally, this would be [Composer](https://getcomposer.org).

### Composer

[](#composer)

From the command line:

```
composer require pressmodo/wp-admin-notices
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~20 days

Total

5

Last Release

2186d ago

### Community

Maintainers

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

---

Top Contributors

[![alessandrotesoro](https://avatars.githubusercontent.com/u/1590958?v=4)](https://github.com/alessandrotesoro "alessandrotesoro (10 commits)")

---

Tags

admincomposerlibrarynoticespressmodowordpresswordpressadminnoticespressmodo

### Embed Badge

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

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

###  Alternatives

[wecodemore/current-admin-info

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

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

PHPackages © 2026

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