From 4abd9b727fcbc4c443d4231325b3215446664ade Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 16 Jul 2024 16:35:09 +0300 Subject: [PATCH] fix: notice spamming for `No posts are available` --- includes/admin/models/class-rop-queue-model.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/admin/models/class-rop-queue-model.php b/includes/admin/models/class-rop-queue-model.php index bb0b8e0db..9da8d95f8 100644 --- a/includes/admin/models/class-rop-queue-model.php +++ b/includes/admin/models/class-rop-queue-model.php @@ -216,7 +216,13 @@ public function get_queue() { $post_pool = $this->selector->select( $account_id ); if ( empty( $post_pool ) ) { - $this->logger->alert_error( 'No posts are available to share for your account. Try activating the Share more than once option or changing the minimum and maximum post age setting to widen the pool of available posts.' ); + + $last_log_displayed = get_transient( 'rop_no_posts_log_displayed' ); + $display_interval = 12 * HOUR_IN_SECONDS; + if ( ! $last_log_displayed || ( time() - $last_log_displayed ) > $display_interval ) { + $this->logger->alert_error( 'No posts are available to share for your account. Try activating the Share more than once option or changing the minimum and maximum post age setting to widen the pool of available posts.' ); + set_transient( 'rop_no_posts_log_displayed', time(), $display_interval ); + } continue; }