Skip to content

Commit f15d955

Browse files
jdevalkclaude
andauthored
fix: handle empty comment_type in email formatting (#177)
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 <noreply@anthropic.com>
1 parent fc4ea75 commit f15d955

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

inc/clean-emails.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private function add_comment_basics(): void {
181181
* @return void
182182
*/
183183
private function add_author_line(): void {
184-
if ( $this->comment->comment_type === 'comment' ) {
184+
if ( $this->comment->comment_type !== 'pingback' && $this->comment->comment_type !== 'trackback' ) {
185185
/* translators: %1$s is replaced with the comment author's name, %2$s is replaced with the comment author's email */
186186
$this->message .= \sprintf( \esc_html__( 'Author: %1$s (%2$s)', 'yoast-comment-hacks' ), \esc_html( $this->comment->comment_author ), '<a href="' . \esc_url( 'mailto:' . $this->comment->comment_author_email ) . '">' . \esc_html( $this->comment->comment_author_email ) . '</a>' ) . '<br />';
187187
}
@@ -197,7 +197,7 @@ private function add_author_line(): void {
197197
* @return void
198198
*/
199199
private function add_content_line(): void {
200-
if ( $this->comment->comment_type === 'comment' ) {
200+
if ( $this->comment->comment_type !== 'pingback' && $this->comment->comment_type !== 'trackback' ) {
201201
$this->message .= \esc_html__( 'Comment:', 'yoast-comment-hacks' );
202202
}
203203
else {

0 commit comments

Comments
 (0)