Skip to content

Commit

Permalink
Fix CS & remove exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevalk committed Dec 9, 2022
1 parent 10f0c07 commit 8663f5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
9 changes: 0 additions & 9 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,4 @@
</properties>
</rule>

<!-- Direct database queries need careful review.
Ticket: https://github.com/Yoast/comment-hacks/issues/50
-->
<rule ref="WordPress.DB.DirectDatabaseQuery">
<exclude-pattern>/admin/comment-parent\.php$</exclude-pattern>
<exclude-pattern>/inc/clean-emails\.php$</exclude-pattern>
<exclude-pattern>/inc/email-links\.php$</exclude-pattern>
</rule>

</ruleset>
17 changes: 10 additions & 7 deletions inc/email-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ public function admin_bar_comment_link(): void {

$current_user = \wp_get_current_user();

$comments = get_comments( [
'post_id' => $post->ID,
'type' => 'comment',
'status' => 'approve',
] );
$comments = get_comments(
[
'post_id' => $post->ID,
'type' => 'comment',
'status' => 'approve',
]
);
if ( count( $comments ) === 0 ) {
return;
}
$emails = [];
foreach( $comments as $comment ) {
foreach ( $comments as $comment ) {
$emails[] = $comment->comment_author_email;
}
$emails = array_unique( $emails );
Expand Down Expand Up @@ -162,7 +164,8 @@ private function replace_variables( $msg, $comment = false, $post = false ): str

if ( \is_numeric( $post ) ) {
$post = \get_post( $post );
} elseif ( \is_object( $comment ) && $comment->comment_post_ID > 0 ) {
}
elseif ( \is_object( $comment ) && $comment->comment_post_ID > 0 ) {
$post = \get_post( $comment->comment_post_ID );
}

Expand Down

0 comments on commit 8663f5b

Please sign in to comment.