diff --git a/admin/admin.php b/admin/admin.php index c2ee737..6671a9e 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -406,7 +406,7 @@ public function options_validate( array $input ): array { * @return bool */ private function sanitize_bool( $value ): bool { - return ( $value || ! empty( $value ) ); + return (bool) $value; } /** diff --git a/admin/comment-parent.php b/admin/comment-parent.php index 04541de..c4ef619 100644 --- a/admin/comment-parent.php +++ b/admin/comment-parent.php @@ -38,18 +38,16 @@ public function comment_parent_box( $comment ) { // phpcs:ignore Generic.CodeAna * @return void */ public function load_comment_parent_box() { - if ( \function_exists( 'add_meta_box' ) ) { - \add_meta_box( - 'comment_parent', - \esc_html__( 'Comment Parent', 'yoast-comment-hacks' ), - [ - $this, - 'comment_parent_box', - ], - 'comment', - 'normal' - ); - } + \add_meta_box( + 'comment_parent', + \esc_html__( 'Comment Parent', 'yoast-comment-hacks' ), + [ + $this, + 'comment_parent_box', + ], + 'comment', + 'normal' + ); } /** @@ -70,11 +68,10 @@ public function update_comment_parent() { return; // There might be another reason for a comment to be updated. } - if ( \function_exists( 'wp_doing_ajax' ) && \wp_doing_ajax() ) { + if ( \wp_doing_ajax() ) { \check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); } - - if ( ! \function_exists( 'wp_doing_ajax' ) || ! \wp_doing_ajax() ) { + else { \check_admin_referer( 'update-comment_' . $comment_id ); } diff --git a/inc/clean-emails.php b/inc/clean-emails.php index 0b60b51..9c251d2 100644 --- a/inc/clean-emails.php +++ b/inc/clean-emails.php @@ -304,14 +304,12 @@ private function comment_notification_actions(): void { * @return void */ private function comment_action_links( array $actions ): void { - $links = ''; + $links = []; foreach ( $actions as $action => $label ) { - $links .= $this->comment_action_link( $label, $action ) . ' | '; + $links[] = $this->comment_action_link( $label, $action ); } - $links = \rtrim( $links, '| ' ); - - $this->message .= $links; + $this->message .= \implode( ' | ', $links ); } /** diff --git a/inc/hacks.php b/inc/hacks.php index 631c51c..20df2c9 100644 --- a/inc/hacks.php +++ b/inc/hacks.php @@ -165,7 +165,7 @@ public function modify_comment_edit_link_block( $block_content, $block ) { public function get_remove_comment_url_link( $comment_id ) { $comment = \get_comment( $comment_id ); - if ( isset( $comment ) && $comment instanceof WP_Comment && ! empty( $comment->comment_author_url ) ) { + if ( $comment instanceof WP_Comment && ! empty( $comment->comment_author_url ) ) { return \sprintf( '%s', \esc_attr( (string) $comment_id ), diff --git a/inc/notifications.php b/inc/notifications.php index 77ac734..5f79703 100644 --- a/inc/notifications.php +++ b/inc/notifications.php @@ -55,18 +55,13 @@ public function filter_notification_recipients( $recipients, $comment_id ): arra public function filter_notification_headers( $message_headers, $comment_id ): string { $comment = \get_comment( $comment_id ); - if ( $comment->comment_author !== '' && $comment->comment_author_email !== '' ) { - $name = \esc_html( $comment->comment_author ); - $message_headers .= "\nReply-To: $name <$comment->comment_author_email>\n"; - + if ( $comment->comment_author_email === '' ) { return $message_headers; } - if ( $comment->comment_author_email !== '' ) { - $message_headers .= "\nReply-To: $comment->comment_author_email <$comment->comment_author_email>\n"; + $name = ( $comment->comment_author !== '' ) ? \esc_html( $comment->comment_author ) : $comment->comment_author_email; - return $message_headers; - } + $message_headers .= "\nReply-To: $name <$comment->comment_author_email>\n"; return $message_headers; } diff --git a/inc/progress-planner/comment-policy.php b/inc/progress-planner/comment-policy.php index 1f78838..54d0491 100644 --- a/inc/progress-planner/comment-policy.php +++ b/inc/progress-planner/comment-policy.php @@ -83,11 +83,7 @@ public function get_description() { * @return bool */ public function should_add_task() { - if ( ! (int) $this->options['comment_policy_page'] || ! (int) $this->options['comment_policy'] ) { - return true; - } - - return false; + return ! (int) $this->options['comment_policy_page'] || ! (int) $this->options['comment_policy']; } /** diff --git a/inc/progress-planner/comment-redirect.php b/inc/progress-planner/comment-redirect.php index 0cfb46c..2f4741f 100644 --- a/inc/progress-planner/comment-redirect.php +++ b/inc/progress-planner/comment-redirect.php @@ -82,11 +82,7 @@ public function get_description() { * @return bool */ public function should_add_task() { - if ( ! $this->options['redirect_page'] ) { - return true; - } - - return false; + return ! $this->options['redirect_page']; } /**