PHPackages                             wp-kit/flash - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. wp-kit/flash

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

wp-kit/flash
============

A wp-kit component that handles frontend and admin flash notifications

2.0.1(6y ago)2191MITPHPPHP &gt;=7.2

Since Sep 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/wp-kit/flash)[ Packagist](https://packagist.org/packages/wp-kit/flash)[ Docs](https://github.com/wp-kit/flash)[ RSS](/packages/wp-kit-flash/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

wp-kit/flash
============

[](#wp-kitflash)

This is a wp-kit component that handles both frontend and admin flash notifications.

This component was built to run within an [`Illuminate\Container\Container`](https://github.com/illuminate/container/blob/master/Container.php) so is perfect for frameworks such as [`Themosis`](http://framework.themosis.com/), [`Assely`](https://assely.org/) and [`wp-kit/theme`](https://github.com/wp-kit/theme).

Often, Wordpress developers want to be able to use a single component the handle flashes stored in the session and their output to the client, usually after a redirect.

In Wordpress we do have the ability to forge admin notices via some hooks but there a few hoops to jump through in that you have to write quite a bit of code to handle the session storage and the output, and currently there are no hooks for front-end flashes.

Installation
------------

[](#installation)

If you're using `Themosis`, install via [`Composer`](https://getcomposer.org/) in the `Themosis` route folder, otherwise install in your `Composer` driven theme folder:

```
composer require "wp-kit/flash"
```

Setup
-----

[](#setup)

### Add Service Provider

[](#add-service-provider)

Just register the service provider and facade in your providers config:

```
//inside theme/resources/config/providers.config.php

return [
    //
    WPKit\Config\ConfigServiceProvider::class, // we need this too,
    Illuminate\Filesystem\FilesystemServiceProvider::class, // specify the driver provider
    Illuminate\Session\SessionServiceProvider::class, // we need this too
    WPKit\Flash\FlashServiceProvider::class
];
```

### Add Facade

[](#add-facade)

If you are using Themosis or another `Iluminate` driven framework, you may want to add `Facades`, simply add them to your aliases:

```
//inside theme/resource/config/theme.config.php

'aliases' => [
    //
    'AdminFlash' => WPKit\Flash\Facades\AdminFlash::class,
    'FrontendFlash' => WPKit\Flash\Facades\FrontendFlash::class
    //
]
```

### Add Config &amp; View File(s)

[](#add-config--view-files)

Although a config file is not required for `wp-kit/flash`, we do need to publish view files and a config is needed for your `SessionProvider`.

The recommended method of installing config files for `wp-kit` components is via `wp kit vendor:publish` command.

First, [install WP CLI](http://wp-cli.org/), and then install this component, `wp kit vendor:publish` will automatically be installed with `wp-kit/utils`, once installed you can run:

`wp kit vendor:publish`

For more information, please visit [`wp-kit/utils`](https://github.com/wp-kit/utils#commands).

Alternatively, you can place the [config file(s)](config) and [view file(s)](views) in your `theme/resources/config` and `theme/resources/views` directories manually.

Usage
-----

[](#usage)

> **Note:** [`AdminFlash`](https://github.com/wp-kit/flash/blob/master/src/Flash/Flashers/AdminFlash.php) automatically outputs notices in admin area using the hook [`admin_notices`](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices).

> **Important** Don't forget to use the [`Illuminate\Session\Middleware\StartSession`](https://github.com/illuminate/session/blob/master/Middleware/StartSession.php) middleware to ensure flashes persist.

```
use Themosis\Facades\Route;
use Illuminate\Session\Middleware\StartSession;

Route::group([
    'namespace' => 'Theme\Controllers',
    'middleware' => [
	StartSession::class,
	'auth.form'
    ]
], function () {
    require themosis_path('theme.resources').'routes.php';
});
```

### Using Facades

[](#using-facades)

```
// Just in case you need to include the Facade in a custom namespace

use WPKit\Flash\Facades\AdminFlash;
use WPKit\Flash\Facades\FrontendFlash;

// Frontend

FrontendFlash::success('Well done!');
FrontendFlash::warning('Hmm, not sure about that...');
FrontendFlash::error('What on earth are you doing?');

$messages = FrontendFlash::all();

$html = FrontendFlash::render();

$chained = FrontendFlash::success('Well done!')->render();

FrontendFlash::clear();

FrontendFlash::display([
	'message' => 'Ooh, living dangerously are we?'
	'class' => 'some-classname'
]);

// Admin

AdminFlash::success('Well done!');
AdminFlash::warning('Hmm, not sure about that...');
AdminFlash::error('What on earth are you doing?');

$messages = AdminFlash::all();

$html = AdminFlash::render();

$chained = AdminFlash::success('Well done!')->render();

AdminFlash::clear();

AdminFlash::display([
	'message' => 'Ooh, living dangerously are we?'
	'class' => 'some-classname'
]);
```

### Using Helper Function

[](#using-helper-function)

```
// Frontend

flash('frontend')->success('Well done!');
flash('frontend')->warning('Hmm, not sure about that...');
flash('frontend')->error('What on earth are you doing?');

$messages = flash('frontend')->all();

$html = flash('frontend')->render();

$chained = flash('frontend')->success('Well done!')->render();

flash('frontend')->clear();

flash('frontend')->display([
	'message' => 'Ooh, living dangerously are we?'
	'class' => 'some-classname'
]);

// Admin

flash('admin')->success('Well done!');
flash('admin')->warning('Hmm, not sure about that...');
flash('admin')->error('What on earth are you doing?');

$messages = flash('admin')->all();

$html = flash('admin')->render();

$chained = flash('admin')->success('Well done!')->render();

flash('admin')->clear();

flash('admin')->display([
	'message' => 'Ooh, living dangerously are we?'
	'class' => 'some-classname'
]);
```

### Looping through messages

[](#looping-through-messages)

This is just a guide of how you use use `wp-kit/flash` when looping through a load of flashes where you need to output markup around each flash:

```
// within theme/resources/views/some-view.php

	all() as $message ) : ?>

			display( $message ); ?>

```

Get Involved
------------

[](#get-involved)

To learn more about how to use `wp-kit` check out the docs:

[View the Docs](https://github.com/wp-kit/theme/tree/docs/README.md)

Any help is appreciated. The project is open-source and we encourage you to participate. You can contribute to the project in multiple ways by:

- Reporting a bug issue
- Suggesting features
- Sending a pull request with code fix or feature
- Following the project on [GitHub](https://github.com/wp-kit)
- Sharing the project around your community

For details about contributing to the framework, please check the [contribution guide](https://github.com/wp-kit/theme/tree/docs/Contributing.md).

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

[](#requirements)

Wordpress 4+

PHP 5.6+

License
-------

[](#license)

wp-kit/flash is open-sourced software licensed under the MIT License.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~862 days

Total

2

Last Release

2343d ago

PHP version history (2 changes)2.0.0PHP &gt;=5.6.4

2.0.1PHP &gt;=7.2

### Community

Maintainers

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

---

Top Contributors

[![terence1990](https://avatars.githubusercontent.com/u/8171301?v=4)](https://github.com/terence1990 "terence1990 (90 commits)")

---

Tags

wordpressnotificationsflashOOPthemosiswp-kitassely

### Embed Badge

![Health badge](/badges/wp-kit-flash/health.svg)

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

###  Alternatives

[edvinaskrucas/notification

Package for Laravel for helping to manage flash / instant notifications / messages.

530398.0k10](/packages/edvinaskrucas-notification)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[hasinhayder/tyro-login

Tyro Login - Beautiful, customizable authentication views for Laravel 12 &amp; 13

2464.9k6](/packages/hasinhayder-tyro-login)[squareboat/flash

An easy way for Laravel flash notifications.

164.9k](/packages/squareboat-flash)

PHPackages © 2026

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