diff --git a/changelog/fix-email-url-issue b/changelog/fix-email-url-issue new file mode 100644 index 0000000000..c4398fd234 --- /dev/null +++ b/changelog/fix-email-url-issue @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix incorrect URL for edited emails diff --git a/includes/internal/emails/class-email-sender.php b/includes/internal/emails/class-email-sender.php index e4232404a3..29ee889523 100644 --- a/includes/internal/emails/class-email-sender.php +++ b/includes/internal/emails/class-email-sender.php @@ -236,7 +236,8 @@ public function get_email_body( WP_Post $email_post, array $placeholders = [] ): */ private function replace_placeholders( string $content, array $placeholders ): string { foreach ( $placeholders as $placeholder => $value ) { - $content = str_replace( '[' . $placeholder . ']', $value, $content ); + // Strip out URL protocol if necessary. Partial solution for https://github.com/Automattic/sensei/issues/7621. + $content = preg_replace( '~(https?://)?\[' . $placeholder . '\]~', $value, $content ); } return $content;