<?php
namespace PixelioCartAbandonRecoveryMore\Admin\Controllers;

use PixelioCartAbandonRecoveryMore\Admin\Wrapper\Pixelio_Cart_Abandon_Recovery_More_Wordpress_Wrapper;

if (!defined('ABSPATH')) exit;

/**
 * Rivio AI Cart Recovery & Marketing Email Automation Admin Controller.
 *
 * This class handles all admin-related functionality for the Pixelio Cart Abandon
 * Recovery plugin, including menu registration, page rendering, asset enqueues,
 * admin notices, update checks, and plugin action/meta links.
 *
 * @package PixelioCartAbandonRecoveryMore\Admin\Controllers
 * @since 1.0.0
 */
class Pixelio_Cart_Abandon_Recovery_More_Activation_Controller
{



	private Pixelio_Cart_Abandon_Recovery_More_Wordpress_Wrapper $pixelio_wordpress_wrapper;


	/**
	 * Constructor.
	 *
	 * Initializes hooks, menu pages, filters, admin notices, and update checks.
	 */
	public function __construct($pixelio_wordpress_wrapper)
	{
		$this->pixelio_wordpress_wrapper = $pixelio_wordpress_wrapper;
		if ($this->pixelio_should_redirect_after_activation()) {
			$this->pixelio_perform_activation_redirect();
		}
	}

	private function pixelio_should_redirect_after_activation(): bool
	{
		return (bool)$this->pixelio_wordpress_wrapper
			->pixelio_get_option('pixelio_do_activation_redirect', false);
	}

	private function pixelio_perform_activation_redirect(): void
	{
		$this->pixelio_wordpress_wrapper
			->pixelio_delete_option('pixelio_do_activation_redirect');

		// Safe check pendant l’activation, pas de données utilisateurs traitées
		if (!isset($_GET['activate-multi'])) {
			$this->pixelio_wordpress_wrapper
				->pixelio_wp_safe_redirect(
					$this->pixelio_wordpress_wrapper
						->pixelio_admin_url('admin.php?page=rivio-ai-cart-recovery-marketing-email-automation')
				);
			exit;
		}
	}

}

