From 72fef9cd71f4c5d0ad798aba281f2253b49d58a8 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 3 Oct 2024 19:36:21 -0400 Subject: [PATCH] eliminate code smells --- classes/ActionScheduler_WPCommentCleaner.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/classes/ActionScheduler_WPCommentCleaner.php b/classes/ActionScheduler_WPCommentCleaner.php index 9e2b0f87c..53015e458 100644 --- a/classes/ActionScheduler_WPCommentCleaner.php +++ b/classes/ActionScheduler_WPCommentCleaner.php @@ -66,7 +66,13 @@ public static function has_logs() { * Attached to the migration complete hook 'action_scheduler/migration_complete'. */ public static function maybe_schedule_cleanup() { - if ( (bool) get_comments( array( 'type' => ActionScheduler_wpCommentLogger::TYPE, 'number' => 1, 'fields' => 'ids' ) ) ) { + $args = array( + 'type' => ActionScheduler_wpCommentLogger::TYPE, + 'number' => 1, + 'fields' => 'ids', + ); + + if ( (bool) get_comments( $args ) ) { update_option( self::$has_logs_option_key, 'yes' ); if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) { @@ -80,7 +86,15 @@ public static function maybe_schedule_cleanup() { */ public static function delete_all_action_comments() { global $wpdb; - $wpdb->delete( $wpdb->comments, array( 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT ) ); + + $wpdb->delete( + $wpdb->comments, + array( + 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, + 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT, + ) + ); + delete_option( self::$has_logs_option_key ); }