cryptoId = $cryptoId; $repo = new AGC_Carousel_Repo(); $this->buffer = $repo->get_buffer($cryptoId); $this->currentIndex = $repo->get_index($cryptoId); } public function get_next_address() { AGC_Util::log(__FILE__, __LINE__, 'Getting next carousel address!'); $nextAddress = $this->buffer[$this->currentIndex]; while (!AGC_Cryptocurrencies::is_valid_wallet_address($this->cryptoId, $nextAddress)) { $this->increment_current_index(); $nextAddress = $this->buffer[$this->currentIndex]; } $this->increment_current_index(); $repo = new AGC_Carousel_Repo(); $repo->set_index($this->cryptoId, $this->currentIndex); return $nextAddress; } private function increment_current_index() { AGC_Util::log(__FILE__, __LINE__, 'Incrementing current index: ' . $this->currentIndex); if ($this->currentIndex >= 0 && $this->currentIndex <= 3) { $this->currentIndex = $this->currentIndex + 1; } elseif ($this->currentIndex == 4) { $this->currentIndex = 0; } else { AGC_Util::log(__FILE__, __LINE__, 'Invalid current index! Something went wrong, please contact plugin support.'); } } } ?>