mirror of
https://github.com/duckdev/wp-flash-notices.git
synced 2025-11-24 07:05:45 +08:00
Compare commits
No commits in common. "master" and "v1.0.0" have entirely different histories.
3 changed files with 5 additions and 29 deletions
10
README.md
10
README.md
|
|
@ -80,12 +80,4 @@ By default all notices are shown within single site admin screens. If you have M
|
||||||
```php
|
```php
|
||||||
// Register new info notice to the queue.
|
// Register new info notice to the queue.
|
||||||
$notices->add( 'custom-success', 'This is a custom dismissible notice.', 'success', true, true );
|
$notices->add( 'custom-success', 'This is a custom dismissible notice.', 'success', true, true );
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Frontend Compatibility
|
|
||||||
If you'd like to print the notices in the front-end, then use the below action to your template.
|
|
||||||
|
|
||||||
```php
|
|
||||||
do_action( 'front_notices' );
|
|
||||||
```
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "duckdev/wp-flash-notices",
|
"name": "duckdev/wp-flash-notices",
|
||||||
"description": "WordPress admin notices as flash notice using transient API to display after page reload.",
|
"description": "WordPress admin notices as flash notice using transient API to display after page reload.",
|
||||||
"version": "1.0.1",
|
|
||||||
"license": "GPL-2.0+",
|
"license": "GPL-2.0+",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -64,27 +64,12 @@ class WP_Flash_Notices {
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __construct( $transient = 'duckdev_wp_flash_notices' ) {
|
public function __construct( $transient = 'jj_wp_flash_notices' ) {
|
||||||
// Make sure you set this unique, otherwise all notices will mixup.
|
// Make sure you set this unique, otherwise all notices will mixup.
|
||||||
$this->transient = $transient;
|
$this->transient = $transient;
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter hook to add new notice types.
|
|
||||||
*
|
|
||||||
* @param array $types Notice types (default wp notices).
|
|
||||||
* @param string $transient Transient name.
|
|
||||||
*
|
|
||||||
* @since 1.0.1
|
|
||||||
*/
|
|
||||||
$this->types = apply_filters(
|
|
||||||
'wp_flash_notices_notice_types',
|
|
||||||
$this->types,
|
|
||||||
$this->transient
|
|
||||||
);
|
|
||||||
|
|
||||||
// Render notices using WP action.
|
// Render notices using WP action.
|
||||||
add_action( 'admin_notices', [ $this, 'render' ] );
|
add_action( 'admin_notices', [ $this, 'render' ] );
|
||||||
add_action( 'front_notices', [ $this, 'render' ] );
|
|
||||||
add_action( 'network_admin_notices', [ $this, 'render' ] );
|
add_action( 'network_admin_notices', [ $this, 'render' ] );
|
||||||
|
|
||||||
// Save all queued notices to transient.
|
// Save all queued notices to transient.
|
||||||
|
|
@ -250,15 +235,15 @@ class WP_Flash_Notices {
|
||||||
/**
|
/**
|
||||||
* Filter hook to modify the fetched notices array.
|
* Filter hook to modify the fetched notices array.
|
||||||
*
|
*
|
||||||
|
* @param string $transient Transient name to identify the plugin.
|
||||||
* @param array $notices Notice list.
|
* @param array $notices Notice list.
|
||||||
* @param string $transient Transient name to identify the plugin.
|
|
||||||
* @param bool $network Is network notice?.
|
* @param bool $network Is network notice?.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
return apply_filters( 'wp_flash_notices_fetch',
|
return apply_filters( 'wp_flash_notices_fetch',
|
||||||
$notices,
|
|
||||||
$this->transient,
|
$this->transient,
|
||||||
|
$notices,
|
||||||
$network
|
$network
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -394,4 +379,4 @@ class WP_Flash_Notices {
|
||||||
$this->clear( $network );
|
$this->clear( $network );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue