Skip to content

Commit

Permalink
Merge branch 'release/8.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
BracketSpaceWorker committed Dec 23, 2021
2 parents c7ea338 + 54ee726 commit 3ba972e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Customisable email and webhook notifications with powerful developer friendly API for custom triggers and notifications. Send alerts easily.
* Author: BracketSpace
* Author URI: https://bracketspace.com
* Version: 8.0.8
* Version: 8.0.9
* License: GPL3
* Text Domain: notification
* Domain Path: /languages
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: notification, bracketspace, Kubitomakita, tomaszadamowicz, insejn,
Tags: notification, notify, alert, email, mail, webhook, API, developer, framework
Requires at least: 4.9
Tested up to: 5.8
Stable tag: 8.0.8
Stable tag: 8.0.9
Requires PHP: 7.0
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Expand All @@ -14,7 +14,7 @@ Customisable email and webhook notifications with powerful developer friendly AP

Custom Notifications and Alerts without a hassle. Notify anyone about any action in your WordPress. With powerful Merge Tags, you can endlessly customize your messages. Set unlimited Notifications in your WordPress Admin via the beautiful and intuitive interface within 5 minutes.

[youtube https://www.youtube.com/watch?v=UPqVBhLGTek]
[youtube https://www.youtube.com/watch?v=gW2KHrT_a7U]

= DEFAULT WORDPRESS EMAILS OVERWRITE =

Expand Down Expand Up @@ -302,6 +302,12 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo

== Changelog ==

= 8.0.9 =

* [Fixed] Merge Tags resolver problem caused by overriding the processed trigger instance.
* [Changed] `notification/should_send` filter is now executed when the queue is processed, not before the notification is added to the queue.
* [Added] New queue methods: `remove()` and `clear()`.

= 8.0.8 =

* [Fixed] Two or more same triggers processed in the same request overwriting each other data.
Expand Down
4 changes: 4 additions & 0 deletions src/Core/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public static function schedule( Notification $notification, Triggerable $trigge
public static function process_notification( Notification $notification, Triggerable $trigger ) {
$trigger->setup_merge_tags();

if ( ! apply_filters( 'notification/should_send', true, $notification, $trigger ) ) {
return;
}

foreach ( $notification->get_enabled_carriers() as $carrier ) {
$carrier->resolve_fields( $trigger );
$carrier->prepare_data();
Expand Down
21 changes: 21 additions & 0 deletions src/Core/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,25 @@ public static function iterate( callable $callback ) {
}
}

/**
* Clears the queue entirely
*
* @since 8.0.9
* @return void
*/
public static function clear() {
self::$items = [];
}

/**
* Removes an item from the queue
*
* @since 8.0.9
* @param int $index Index of an item to remove.
* @return void
*/
public static function remove( int $index ) {
unset( self::$items[ $index ] );
}

}
2 changes: 1 addition & 1 deletion src/Core/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function resolve( $value, Triggerable $trigger ) {
// Loop over all resolvers.
foreach ( $resolvers as $resolver ) {
$value = preg_replace_callback( $resolver->get_pattern(), function ( $match ) use ( $resolver, $trigger ) {
return call_user_func( [ $resolver, 'resolve_merge_tag' ], $match, $trigger );
return call_user_func( [ $resolver, 'resolve_merge_tag' ], $match, clone $trigger );
}, $value );
}

Expand Down
6 changes: 0 additions & 6 deletions src/Core/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,13 @@ public function run( ...$context ) {

// Setup notifications and prepare the carriers.
foreach ( $this->get_notifications() as $notification ) {

if ( ! apply_filters( 'notification/should_send', true, $notification, $this->trigger ) ) {
continue;
}

/**
* If an item already exists in the queue, we are replacing it with the new version.
* This doesn't prevents the duplicates coming from two separate requests.
*/
Queue::add_replace( $notification, $this->trigger );

do_action( 'notification/processed', $notification );

}

}
Expand Down

0 comments on commit 3ba972e

Please sign in to comment.