<?php
/**
 * @package         FireBox
 * @version         3.1.8 Free
 * 
 * @author          FirePlugins <info@fireplugins.com>
 * @link            https://www.fireplugins.com
 * @copyright       Copyright © 2026 FirePlugins All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/

namespace FireBox\Core\Admin;

if (!defined('ABSPATH'))
{
	exit; // Exit if accessed directly.
}

if (!class_exists('Activation'))
{
	require_once FBOX_PLUGIN_DIR . '/Inc/Framework/Inc/Admin/Includes/Activation.php';
}

class PluginActivation extends \Activation
{
	/**
	 * Runs once we activate the plugin.
	 * Set plugin data
	 * 
	 * @return  void
	 */
	public function start()
	{
		$this->pluginActivation();

		require_once FBOX_PLUGIN_DIR . 'Inc/Framework/Inc/Helpers/Directory.php';
		require_once FBOX_PLUGIN_DIR . 'Inc/Framework/Inc/Helpers/WPHelper.php';
		\FireBox\Core\Helpers\Activation::createLibraryDirectories();
		
		// Set plugin version
		update_option('firebox_version', FBOX_VERSION);

		

			// set default plugin settings
			if (!get_option('firebox_settings'))
			{
				$settings = [
					'showcopyright' => '1',
					'show_admin_bar_menu_item' => '1',
					'debug' => '0',
					'statsdays' => '730',
					'geo_license_key' => '',
					'keep_data_on_uninstall' => '1',
					'usage_tracking' => '0',
					'enable_phpscripts' => '0',
					'license_key' => '',
				];

				foreach (\FireBox\Core\Helpers\Integrations::getSettingsKeys() as $integration_key)
				{
					$settings[$integration_key] = '';
				}

				update_option('firebox_settings', $settings);
			}

		// initialize capabilities
		new Capabilities();

		// Redirect to dashboard on first activation for onboarding
		$this->redirectToDashboard();
	}

	/**
	 * Redirect to FireBox dashboard on first plugin activation
	 * Initialize onboarding flow
	 * 
	 * @return  void
	 */
	private function redirectToDashboard()
	{
		// Set option to mark that we should redirect after activation
		update_option('firebox_activation_redirect', true);
	}
}
