From 51d76412ea514212b5b01cb13922ed44b445bc39 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 6 Jan 2022 14:38:49 +0100 Subject: [PATCH 1/9] change carrier get recipients field to include resolved data CU-1zfvkmn --- readme.txt | 4 ++++ src/Abstracts/Carrier.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 5afa09ee6..3969b2299 100644 --- a/readme.txt +++ b/readme.txt @@ -302,6 +302,10 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo == Changelog == += [Next] = + +* [Changed] Carrier's recipients field is not returned with resolved data if available. + = 8.0.9 = * [Fixed] Merge Tags resolver problem caused by overriding the processed trigger instance. diff --git a/src/Abstracts/Carrier.php b/src/Abstracts/Carrier.php index 9e740b970..ef57f145e 100644 --- a/src/Abstracts/Carrier.php +++ b/src/Abstracts/Carrier.php @@ -262,7 +262,11 @@ public function get_recipients_field() { $field = $closure(); // Setup the field data if it's available. - $this->set_field_data( $field, $this->recipients_data ); + if ( ! empty( $this->recipients_resolved_data ) ) { + $this->set_field_data( $field, $this->recipients_resolved_data ); + } else { + $this->set_field_data( $field, $this->recipients_data ); + } return $field; } From 66c35fae97e090f6947a166660640e03e60a788f Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 6 Jan 2022 14:57:10 +0100 Subject: [PATCH 2/9] fix user logout context CU-1z4d3zk see 394 --- readme.txt | 1 + src/Defaults/Trigger/User/UserLogout.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/readme.txt b/readme.txt index 3969b2299..7590e5ad1 100644 --- a/readme.txt +++ b/readme.txt @@ -304,6 +304,7 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo = [Next] = +* [Fixed] User logout trigger. In WordPress 5.5 the context is set properly. * [Changed] Carrier's recipients field is not returned with resolved data if available. = 8.0.9 = diff --git a/src/Defaults/Trigger/User/UserLogout.php b/src/Defaults/Trigger/User/UserLogout.php index 0cdc4e8d4..109771e21 100644 --- a/src/Defaults/Trigger/User/UserLogout.php +++ b/src/Defaults/Trigger/User/UserLogout.php @@ -35,7 +35,7 @@ public function __construct() { parent::__construct( 'user/logout', __( 'User logout', 'notification' ) ); - $this->add_action( 'wp_logout', 10, 0 ); + $this->add_action( 'wp_logout', 10, 1 ); $this->set_description( __( 'Fires when user log out from WordPress', 'notification' ) ); @@ -44,17 +44,20 @@ public function __construct() { /** * Sets trigger's context * + * @param int $user_id User ID. * @return void */ - public function context() { + public function context( $user_id = 0 ) { + // Fix for WordPress <5.5 where the param is not available. + if ( 0 === $user_id ) { + $user_id = get_current_user_id(); + } - $this->user_id = get_current_user_id(); - $this->user_object = get_userdata( $this->user_id ); - $this->user_meta = get_user_meta( $this->user_id ); + $this->user_object = get_userdata( $user_id ); + $this->user_meta = get_user_meta( $user_id ); $this->user_registered_datetime = strtotime( $this->user_object->user_registered ); $this->user_logout_datetime = time(); - } /** From e0baf5a0f695f9275bffed913e265f8805698473 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Mon, 10 Jan 2022 19:15:02 +0100 Subject: [PATCH 3/9] fix typo --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 7590e5ad1..005059bda 100644 --- a/readme.txt +++ b/readme.txt @@ -305,7 +305,7 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo = [Next] = * [Fixed] User logout trigger. In WordPress 5.5 the context is set properly. -* [Changed] Carrier's recipients field is not returned with resolved data if available. +* [Changed] Carrier's recipients field is now returned with resolved data if available. = 8.0.9 = From 096026eee29b4765c96d2eb783852692f5a548f4 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 26 Jan 2022 21:59:58 +0100 Subject: [PATCH 4/9] change binder to clone the trigger for each action CU-23kctvd --- readme.txt | 1 + src/Core/Binder.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 005059bda..8b555c1b7 100644 --- a/readme.txt +++ b/readme.txt @@ -305,6 +305,7 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo = [Next] = * [Fixed] User logout trigger. In WordPress 5.5 the context is set properly. +* [Fixed] Issue with persistent Trigger state if two or more actions assigned to the same trigger were called. * [Changed] Carrier's recipients field is now returned with resolved data if available. = 8.0.9 = diff --git a/src/Core/Binder.php b/src/Core/Binder.php index 5f375e7e8..cb48ffefe 100644 --- a/src/Core/Binder.php +++ b/src/Core/Binder.php @@ -31,7 +31,7 @@ public static function bind( $triggers ) { foreach ( $trigger->get_actions() as $action ) { add_action( $action['tag'], - [ new Runner( $trigger ), 'run' ], + [ new Runner( clone $trigger ), 'run' ], $action['priority'], $action['accepted_args'] ); From 4c43e013372f0b5e3951b7959963864cce7450e4 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 26 Jan 2022 22:05:16 +0100 Subject: [PATCH 5/9] fix phpstan --- phpstan-baseline.neon | 15 --------------- src/Core/Binder.php | 2 ++ 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0b827463d..6af983fca 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -985,21 +985,6 @@ parameters: count: 2 path: src/Cli/DumpHooks.php - - - message: "#^Call to method get_actions\\(\\) on an unknown class BracketSpace\\\\Notification\\\\Core\\\\Triggerable\\.$#" - count: 1 - path: src/Core/Binder.php - - - - message: "#^Parameter \\#1 \\$trigger of class BracketSpace\\\\Notification\\\\Core\\\\Runner constructor expects BracketSpace\\\\Notification\\\\Interfaces\\\\Triggerable, BracketSpace\\\\Notification\\\\Core\\\\Triggerable given\\.$#" - count: 1 - path: src/Core/Binder.php - - - - message: "#^Parameter \\$triggers of method BracketSpace\\\\Notification\\\\Core\\\\Binder\\:\\:bind\\(\\) has invalid typehint type BracketSpace\\\\Notification\\\\Core\\\\Triggerable\\.$#" - count: 2 - path: src/Core/Binder.php - - message: "#^Method BracketSpace\\\\Notification\\\\Core\\\\Cron\\:\\:register_intervals\\(\\) has parameter \\$intervals with no value type specified in iterable type array\\.$#" count: 1 diff --git a/src/Core/Binder.php b/src/Core/Binder.php index cb48ffefe..c2b4a8aaa 100644 --- a/src/Core/Binder.php +++ b/src/Core/Binder.php @@ -7,6 +7,8 @@ namespace BracketSpace\Notification\Core; +use BracketSpace\Notification\Interfaces\Triggerable; + /** * Binder class */ From ba55fd97fef837bfc5edc74ff0d9782d67b5c5b4 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 27 Jan 2022 10:54:21 +0100 Subject: [PATCH 6/9] add post published privately trigger --- readme.txt | 1 + .../Trigger/Post/PostPublishedPrivately.php | 192 ++++++++++++++++++ src/Repository/TriggerRepository.php | 1 + 3 files changed, 194 insertions(+) create mode 100644 src/Defaults/Trigger/Post/PostPublishedPrivately.php diff --git a/readme.txt b/readme.txt index 8b555c1b7..638793dce 100644 --- a/readme.txt +++ b/readme.txt @@ -307,6 +307,7 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo * [Fixed] User logout trigger. In WordPress 5.5 the context is set properly. * [Fixed] Issue with persistent Trigger state if two or more actions assigned to the same trigger were called. * [Changed] Carrier's recipients field is now returned with resolved data if available. +* [Added] Post Published privately trigger. = 8.0.9 = diff --git a/src/Defaults/Trigger/Post/PostPublishedPrivately.php b/src/Defaults/Trigger/Post/PostPublishedPrivately.php new file mode 100644 index 000000000..ec51c3411 --- /dev/null +++ b/src/Defaults/Trigger/Post/PostPublishedPrivately.php @@ -0,0 +1,192 @@ + $post_type, + 'slug' => 'post/' . $post_type . '/published-privately', + ] ); + + $this->add_action( 'transition_post_status', 10, 3 ); + } + + /** + * Lazy loads the name + * + * @return string name + */ + public function get_name() : string { + // translators: singular post name. + return sprintf( __( '%s published privately', 'notification' ), WpObjectHelper::get_post_type_name( $this->post_type ) ); + } + + /** + * Lazy loads the description + * + * @return string description + */ + public function get_description() : string { + return sprintf( + // translators: 1. singular post name, 2. post type slug. + __( 'Fires when %1$s (%2$s) is published privately', 'notification' ), + WpObjectHelper::get_post_type_name( $this->post_type ), + $this->post_type + ); + } + + /** + * Sets trigger's context + * + * @param string $new_status New post status. + * @param string $old_status Old post status. + * @param object $post Post object. + * @return mixed void or false if no notifications should be sent + */ + public function context( $new_status, $old_status, $post ) { + + if ( $post->post_type !== $this->post_type ) { + return false; + } + + if ( self::$publish_status === $old_status || self::$publish_status !== $new_status ) { + return false; + } + + $this->{ $this->post_type } = $post; + + $this->author = get_userdata( $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->publishing_user = get_userdata( get_current_user_id() ); + + $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); + $this->{ $this->post_type . '_publication_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); + $this->{ $this->post_type . '_modification_datetime' } = strtotime( $this->{ $this->post_type }->post_modified_gmt ); + + } + + /** + * Registers attached merge tags + * + * @return void + */ + public function merge_tags() { + + $post_type_name = WpObjectHelper::get_post_type_name( $this->post_type ); + + parent::merge_tags(); + + // Publishing user. + $this->add_merge_tag( new MergeTag\User\UserID( [ + 'slug' => sprintf( '%s_publishing_user_ID', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user ID', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\User\UserLogin( [ + 'slug' => sprintf( '%s_publishing_user_login', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user login', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\User\UserEmail( [ + 'slug' => sprintf( '%s_publishing_user_email', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user email', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\User\UserNicename( [ + 'slug' => sprintf( '%s_publishing_user_nicename', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user nicename', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\User\UserDisplayName( [ + 'slug' => sprintf( '%s_publishing_user_display_name', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user display name', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\User\UserFirstName( [ + 'slug' => sprintf( '%s_publishing_user_firstname', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user first name', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\User\UserLastName( [ + 'slug' => sprintf( '%s_publishing_user_lastname', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user last name', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\User\Avatar( [ + 'slug' => sprintf( '%s_publishing_user_avatar', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user avatar', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\User\UserRole( [ + 'slug' => sprintf( '%s_publishing_user_role', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publishing user role', 'notification' ), $post_type_name ), + 'property_name' => 'publishing_user', + 'group' => __( 'Publishing user', 'notification' ), + ] ) ); + + $this->add_merge_tag( new MergeTag\DateTime\DateTime( [ + 'slug' => sprintf( '%s_publication_datetime', $this->post_type ), + // translators: singular post name. + 'name' => sprintf( __( '%s publication date and time', 'notification' ), $post_type_name ), + ] ) ); + + } + +} diff --git a/src/Repository/TriggerRepository.php b/src/Repository/TriggerRepository.php index 2be12bb5b..6e158e63b 100644 --- a/src/Repository/TriggerRepository.php +++ b/src/Repository/TriggerRepository.php @@ -59,6 +59,7 @@ public static function register_post_triggers() { Register::trigger( new Trigger\Post\PostAdded( $post_type ) ); Register::trigger( new Trigger\Post\PostDrafted( $post_type ) ); Register::trigger( new Trigger\Post\PostPublished( $post_type ) ); + Register::trigger( new Trigger\Post\PostPublishedPrivately( $post_type ) ); Register::trigger( new Trigger\Post\PostUpdated( $post_type ) ); Register::trigger( new Trigger\Post\PostPending( $post_type ) ); Register::trigger( new Trigger\Post\PostScheduled( $post_type ) ); From 304ae77dbc926599b9a384f4fc03b936574407d1 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 27 Jan 2022 10:54:57 +0100 Subject: [PATCH 7/9] sort post triggers alphabetically --- src/Repository/TriggerRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Repository/TriggerRepository.php b/src/Repository/TriggerRepository.php index 6e158e63b..adf5d4437 100644 --- a/src/Repository/TriggerRepository.php +++ b/src/Repository/TriggerRepository.php @@ -57,14 +57,14 @@ public static function register_post_triggers() { if ( $post_types ) { foreach ( $post_types as $post_type ) { Register::trigger( new Trigger\Post\PostAdded( $post_type ) ); + Register::trigger( new Trigger\Post\PostApproved( $post_type ) ); Register::trigger( new Trigger\Post\PostDrafted( $post_type ) ); + Register::trigger( new Trigger\Post\PostPending( $post_type ) ); Register::trigger( new Trigger\Post\PostPublished( $post_type ) ); Register::trigger( new Trigger\Post\PostPublishedPrivately( $post_type ) ); - Register::trigger( new Trigger\Post\PostUpdated( $post_type ) ); - Register::trigger( new Trigger\Post\PostPending( $post_type ) ); Register::trigger( new Trigger\Post\PostScheduled( $post_type ) ); Register::trigger( new Trigger\Post\PostTrashed( $post_type ) ); - Register::trigger( new Trigger\Post\PostApproved( $post_type ) ); + Register::trigger( new Trigger\Post\PostUpdated( $post_type ) ); } } } From 29c27b12dec08fdfb7d2ec6368a9d0df380a8a7b Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 27 Jan 2022 11:02:04 +0100 Subject: [PATCH 8/9] fix phpstan issues --- phpstan-baseline.neon | 115 ------------------ src/Defaults/Trigger/Post/PostAdded.php | 6 +- src/Defaults/Trigger/Post/PostApproved.php | 6 +- src/Defaults/Trigger/Post/PostDrafted.php | 6 +- src/Defaults/Trigger/Post/PostPending.php | 4 +- src/Defaults/Trigger/Post/PostPublished.php | 6 +- .../Trigger/Post/PostPublishedPrivately.php | 14 +-- src/Defaults/Trigger/Post/PostScheduled.php | 6 +- src/Defaults/Trigger/Post/PostTrashed.php | 6 +- src/Defaults/Trigger/Post/PostTrigger.php | 4 +- src/Defaults/Trigger/Post/PostUpdated.php | 4 +- 11 files changed, 31 insertions(+), 146 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6af983fca..96da47b7b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1895,21 +1895,6 @@ parameters: count: 1 path: src/Defaults/Trigger/Post/PostAdded.php - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostAdded\\:\\:\\$publishing_user \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostAdded.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$author \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostAdded.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$last_editor \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostAdded.php - - message: "#^Access to an undefined property object\\:\\:\\$ID\\.$#" count: 1 @@ -1935,21 +1920,6 @@ parameters: count: 1 path: src/Defaults/Trigger/Post/PostApproved.php - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostApproved\\:\\:\\$approving_user \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostApproved.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$author \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostApproved.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$last_editor \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostApproved.php - - message: "#^Access to an undefined property object\\:\\:\\$ID\\.$#" count: 1 @@ -1975,21 +1945,6 @@ parameters: count: 1 path: src/Defaults/Trigger/Post/PostDrafted.php - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostDrafted\\:\\:\\$publishing_user \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostDrafted.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$author \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostDrafted.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$last_editor \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostDrafted.php - - message: "#^Access to an undefined property object\\:\\:\\$ID\\.$#" count: 1 @@ -2015,16 +1970,6 @@ parameters: count: 1 path: src/Defaults/Trigger/Post/PostPending.php - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$author \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostPending.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$last_editor \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostPending.php - - message: "#^Access to an undefined property object\\:\\:\\$ID\\.$#" count: 1 @@ -2050,21 +1995,6 @@ parameters: count: 1 path: src/Defaults/Trigger/Post/PostPublished.php - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostPublished\\:\\:\\$publishing_user \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostPublished.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$author \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostPublished.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$last_editor \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostPublished.php - - message: "#^Access to an undefined property object\\:\\:\\$ID\\.$#" count: 1 @@ -2090,21 +2020,6 @@ parameters: count: 1 path: src/Defaults/Trigger/Post/PostScheduled.php - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostScheduled\\:\\:\\$scheduling_user \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostScheduled.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$author \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostScheduled.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$last_editor \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostScheduled.php - - message: "#^Access to an undefined property object\\:\\:\\$ID\\.$#" count: 1 @@ -2130,21 +2045,6 @@ parameters: count: 1 path: src/Defaults/Trigger/Post/PostTrashed.php - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrashed\\:\\:\\$trashing_user \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostTrashed.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$author \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostTrashed.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$last_editor \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostTrashed.php - - message: "#^Cannot access property \\$name on string\\|WP_Taxonomy\\.$#" count: 1 @@ -2155,21 +2055,6 @@ parameters: count: 1 path: src/Defaults/Trigger/Post/PostTrigger.php - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$author \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostUpdated.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostTrigger\\:\\:\\$last_editor \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostUpdated.php - - - - message: "#^Property BracketSpace\\\\Notification\\\\Defaults\\\\Trigger\\\\Post\\\\PostUpdated\\:\\:\\$updating_user \\(WP_User\\) does not accept WP_User\\|false\\.$#" - count: 1 - path: src/Defaults/Trigger/Post/PostUpdated.php - - message: "#^Cannot access property \\$user_id on WP_User_Request\\|false\\.$#" count: 1 diff --git a/src/Defaults/Trigger/Post/PostAdded.php b/src/Defaults/Trigger/Post/PostAdded.php index b4a8b949f..178e89cf7 100644 --- a/src/Defaults/Trigger/Post/PostAdded.php +++ b/src/Defaults/Trigger/Post/PostAdded.php @@ -18,7 +18,7 @@ class PostAdded extends PostTrigger { /** * Post publishing user object * - * @var \WP_User + * @var \WP_User|false */ public $publishing_user; @@ -90,8 +90,8 @@ public function context( $post_id, $post, $update ) { // WP_Post object. $this->{ $this->post_type } = $post; - $this->author = get_userdata( $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->publishing_user = get_userdata( get_current_user_id() ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); diff --git a/src/Defaults/Trigger/Post/PostApproved.php b/src/Defaults/Trigger/Post/PostApproved.php index a9209b241..5be0c2af1 100644 --- a/src/Defaults/Trigger/Post/PostApproved.php +++ b/src/Defaults/Trigger/Post/PostApproved.php @@ -18,7 +18,7 @@ class PostApproved extends PostTrigger { /** * Post approving user object * - * @var \WP_User + * @var \WP_User|false */ public $approving_user; @@ -74,8 +74,8 @@ public function context( $post ) { $this->{ $this->post_type } = $post; - $this->author = get_userdata( $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->approving_user = get_userdata( get_current_user_id() ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); diff --git a/src/Defaults/Trigger/Post/PostDrafted.php b/src/Defaults/Trigger/Post/PostDrafted.php index 85710b26f..9b7f71f06 100644 --- a/src/Defaults/Trigger/Post/PostDrafted.php +++ b/src/Defaults/Trigger/Post/PostDrafted.php @@ -18,7 +18,7 @@ class PostDrafted extends PostTrigger { /** * Post publishing user object * - * @var \WP_User + * @var \WP_User|false */ public $publishing_user; @@ -84,8 +84,8 @@ public function context( $new_status, $old_status, $post ) { $this->{ $this->post_type } = $post; - $this->author = get_userdata( $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->publishing_user = get_userdata( get_current_user_id() ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); diff --git a/src/Defaults/Trigger/Post/PostPending.php b/src/Defaults/Trigger/Post/PostPending.php index cdf081f33..72829b6fc 100644 --- a/src/Defaults/Trigger/Post/PostPending.php +++ b/src/Defaults/Trigger/Post/PostPending.php @@ -74,8 +74,8 @@ public function context( $new_status, $old_status, $post ) { $this->{ $this->post_type } = $post; - $this->author = get_userdata( $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); $this->{ $this->post_type . '_modification_datetime' } = strtotime( $this->{ $this->post_type }->post_modified_gmt ); diff --git a/src/Defaults/Trigger/Post/PostPublished.php b/src/Defaults/Trigger/Post/PostPublished.php index a33601129..d0de6ac17 100644 --- a/src/Defaults/Trigger/Post/PostPublished.php +++ b/src/Defaults/Trigger/Post/PostPublished.php @@ -25,7 +25,7 @@ class PostPublished extends PostTrigger { /** * Post publishing user object * - * @var \WP_User + * @var \WP_User|false */ public $publishing_user; @@ -87,8 +87,8 @@ public function context( $new_status, $old_status, $post ) { $this->{ $this->post_type } = $post; - $this->author = get_userdata( $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->publishing_user = get_userdata( get_current_user_id() ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); diff --git a/src/Defaults/Trigger/Post/PostPublishedPrivately.php b/src/Defaults/Trigger/Post/PostPublishedPrivately.php index ec51c3411..94802eae5 100644 --- a/src/Defaults/Trigger/Post/PostPublishedPrivately.php +++ b/src/Defaults/Trigger/Post/PostPublishedPrivately.php @@ -25,7 +25,7 @@ class PostPublishedPrivately extends PostTrigger { /** * Post publishing user object * - * @var \WP_User + * @var \WP_User|false */ public $publishing_user; @@ -70,10 +70,10 @@ public function get_description() : string { /** * Sets trigger's context * - * @param string $new_status New post status. - * @param string $old_status Old post status. - * @param object $post Post object. - * @return mixed void or false if no notifications should be sent + * @param string $new_status New post status. + * @param string $old_status Old post status. + * @param \WP_Post $post Post object. + * @return false|void */ public function context( $new_status, $old_status, $post ) { @@ -87,8 +87,8 @@ public function context( $new_status, $old_status, $post ) { $this->{ $this->post_type } = $post; - $this->author = get_userdata( $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->publishing_user = get_userdata( get_current_user_id() ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); diff --git a/src/Defaults/Trigger/Post/PostScheduled.php b/src/Defaults/Trigger/Post/PostScheduled.php index ad7280a1e..1ea936011 100644 --- a/src/Defaults/Trigger/Post/PostScheduled.php +++ b/src/Defaults/Trigger/Post/PostScheduled.php @@ -18,7 +18,7 @@ class PostScheduled extends PostTrigger { /** * Post scheduling user object * - * @var \WP_User + * @var \WP_User|false */ public $scheduling_user; @@ -82,8 +82,8 @@ public function context( $new_status, $old_status, $post ) { $scheduling_user_id = get_current_user_id(); - $this->author = get_userdata( $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->scheduling_user = get_userdata( $scheduling_user_id ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); diff --git a/src/Defaults/Trigger/Post/PostTrashed.php b/src/Defaults/Trigger/Post/PostTrashed.php index c49f69659..28dfed343 100644 --- a/src/Defaults/Trigger/Post/PostTrashed.php +++ b/src/Defaults/Trigger/Post/PostTrashed.php @@ -18,7 +18,7 @@ class PostTrashed extends PostTrigger { /** * Post trashing user object * - * @var \WP_User + * @var \WP_User|false */ public $trashing_user; @@ -75,8 +75,8 @@ public function context( $post_id, $post ) { $this->{ $this->post_type } = $post; - $this->author = get_userdata( $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->trashing_user = get_userdata( get_current_user_id() ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); diff --git a/src/Defaults/Trigger/Post/PostTrigger.php b/src/Defaults/Trigger/Post/PostTrigger.php index 57bdc0082..e6e2faa46 100644 --- a/src/Defaults/Trigger/Post/PostTrigger.php +++ b/src/Defaults/Trigger/Post/PostTrigger.php @@ -26,14 +26,14 @@ abstract class PostTrigger extends Abstracts\Trigger { /** * Post author user object * - * @var \WP_User + * @var \WP_User|false */ public $author; /** * Post last editor user object * - * @var \WP_User + * @var \WP_User|false */ public $last_editor; diff --git a/src/Defaults/Trigger/Post/PostUpdated.php b/src/Defaults/Trigger/Post/PostUpdated.php index e84dad9ad..e89182962 100644 --- a/src/Defaults/Trigger/Post/PostUpdated.php +++ b/src/Defaults/Trigger/Post/PostUpdated.php @@ -18,7 +18,7 @@ class PostUpdated extends PostTrigger { /** * Post updating user object * - * @var \WP_User + * @var \WP_User|false */ public $updating_user; @@ -91,7 +91,7 @@ public function context( $post_id, $post, $post_before ) { $updating_user_id = get_current_user_id(); $this->author = get_userdata( (int) $this->{ $this->post_type }->post_author ); - $this->last_editor = get_userdata( get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); + $this->last_editor = get_userdata( (int) get_post_meta( $this->{ $this->post_type }->ID, '_edit_last', true ) ); $this->updating_user = get_userdata( $updating_user_id ); $this->{ $this->post_type . '_creation_datetime' } = strtotime( $this->{ $this->post_type }->post_date_gmt ); From 17c8c3b52d7618b3c73b38af48d58d866c2807a0 Mon Sep 17 00:00:00 2001 From: BracketSpaceWorker Date: Thu, 27 Jan 2022 10:10:51 +0000 Subject: [PATCH 9/9] Version bump --- notification.php | 2 +- readme.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/notification.php b/notification.php index 210358cef..9470abcf0 100644 --- a/notification.php +++ b/notification.php @@ -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.9 + * Version: 8.0.10 * License: GPL3 * Text Domain: notification * Domain Path: /languages diff --git a/readme.txt b/readme.txt index 638793dce..98390f216 100644 --- a/readme.txt +++ b/readme.txt @@ -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.9 +Stable tag: 8.0.10 Requires PHP: 7.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -302,7 +302,7 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo == Changelog == -= [Next] = += 8.0.10 = * [Fixed] User logout trigger. In WordPress 5.5 the context is set properly. * [Fixed] Issue with persistent Trigger state if two or more actions assigned to the same trigger were called.