/** * @return bool */ protected function is_flood() { if (get_comment_count($this->prompt_post->id()) < $this->trigger_count) { return false; } if ($this->prompt_post->get_flood_control_comment_id()) { return false; } $last_hour_comment_count = get_comments(array('count' => true, 'post_id' => $this->prompt_post->id(), 'status' => 'approve', 'date_query' => array(array('column' => 'comment_date', 'after' => '1 hour ago')))); if ($last_hour_comment_count <= $this->trigger_count) { return false; } return true; }
protected static function set_context($comment) { if (self::$post_id == $comment->comment_post_ID) { return; } self::$post_id = $comment->comment_post_ID; $prompt_post = new Prompt_Post(self::$post_id); $flood_comment_id = $prompt_post->get_flood_control_comment_id(); if ($flood_comment_id) { self::$flood_comment = get_comment($flood_comment_id); } }