From a19b2a34cf85e9c9e65d898fce45706623004522 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Thu, 17 Jun 2021 12:36:25 -0300 Subject: [PATCH 1/3] Introduces a new hook after an email is sent Closes #24641 --- includes/emails/class-wc-email.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/emails/class-wc-email.php b/includes/emails/class-wc-email.php index 91c0582d9ba..14e9c493161 100644 --- a/includes/emails/class-wc-email.php +++ b/includes/emails/class-wc-email.php @@ -658,6 +658,16 @@ class WC_Email extends WC_Settings_API { remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); + $id = $this->id ? $this->id : 'default'; + /** + * Action hook fired when an email is sent. + * + * @since 5.5.0 + * @param bool $return Whether the email was sent successfully. + * @param WC_Email $this WC_Email instance. + */ + do_action( 'woocommerce_email_' . $id . '_sent', $return, $this ); + return $return; } From 88af805f31c6b9fee1fe65d5771cb81c47bd6bbb Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 18 Jun 2021 11:14:11 -0300 Subject: [PATCH 2/3] Introduces woocommerce_email_sent hook --- includes/emails/class-wc-email.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/emails/class-wc-email.php b/includes/emails/class-wc-email.php index 14e9c493161..30716e8b4c0 100644 --- a/includes/emails/class-wc-email.php +++ b/includes/emails/class-wc-email.php @@ -658,15 +658,15 @@ class WC_Email extends WC_Settings_API { remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); - $id = $this->id ? $this->id : 'default'; /** * Action hook fired when an email is sent. * * @since 5.5.0 - * @param bool $return Whether the email was sent successfully. - * @param WC_Email $this WC_Email instance. + * @param bool $return Whether the email was sent successfully. + * @param int $id Email ID. + * @param WC_Email $this WC_Email instance. */ - do_action( 'woocommerce_email_' . $id . '_sent', $return, $this ); + do_action( 'woocommerce_email_sent', $return, $this->id, $this ); return $return; } From 5128a45936cbd4ad9f3e48770dfbc5ba8ce60c90 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Tue, 22 Jun 2021 15:37:18 -0300 Subject: [PATCH 3/3] Apply suggestions from code review --- includes/emails/class-wc-email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/emails/class-wc-email.php b/includes/emails/class-wc-email.php index 30716e8b4c0..babe3cf8e0a 100644 --- a/includes/emails/class-wc-email.php +++ b/includes/emails/class-wc-email.php @@ -661,7 +661,7 @@ class WC_Email extends WC_Settings_API { /** * Action hook fired when an email is sent. * - * @since 5.5.0 + * @since 5.6.0 * @param bool $return Whether the email was sent successfully. * @param int $id Email ID. * @param WC_Email $this WC_Email instance.