validator = $validator; $this->notice_collection = $notice_collection; } public function add_hooks() { $user_id = get_current_user_id(); if ( ! $this->validator->is_valid( $user_id ) ) { $this->notice_collection->remove( $user_id ); return; } if ( $this->notice_collection->is_dismissed( $user_id ) ) { return; } $this->notice_collection->add( $user_id ); } }