From 5d40c3cc96fea7651ff6b1f04564e8271c2806b6 Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Thu, 5 Feb 2026 12:05:04 +0100 Subject: [PATCH] fix: handle empty comment_type in email formatting WordPress stores regular comments with comment_type as either empty string or 'comment'. The strict === 'comment' check missed empty strings, causing regular comments to be formatted as pingbacks/trackbacks in notification emails. Now checks against known non-comment types instead. Co-Authored-By: Claude Opus 4.5 --- inc/clean-emails.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/clean-emails.php b/inc/clean-emails.php index ae6b996..077b217 100644 --- a/inc/clean-emails.php +++ b/inc/clean-emails.php @@ -176,7 +176,7 @@ private function add_comment_basics(): void { * @return void */ private function add_author_line(): void { - if ( $this->comment->comment_type === 'comment' ) { + if ( $this->comment->comment_type !== 'pingback' && $this->comment->comment_type !== 'trackback' ) { /* translators: %1$s is replaced with the comment author's name, %2$s is replaced with the comment author's email */ $this->message .= \sprintf( \esc_html__( 'Author: %1$s (%2$s)', 'yoast-comment-hacks' ), \esc_html( $this->comment->comment_author ), '' . \esc_html( $this->comment->comment_author_email ) . '' ) . '
'; } @@ -192,7 +192,7 @@ private function add_author_line(): void { * @return void */ private function add_content_line(): void { - if ( $this->comment->comment_type === 'comment' ) { + if ( $this->comment->comment_type !== 'pingback' && $this->comment->comment_type !== 'trackback' ) { $this->message .= \esc_html__( 'Comment:', 'yoast-comment-hacks' ); } else {