<?php
/**
 * Fired during plugin activation.
 *
 * @package    MaplePress
 * @subpackage MaplePress/includes
 */

class MaplePress_Activator {

	/**
	 * Activation tasks.
	 *
	 * Creates default options and flushes rewrite rules.
	 */
	public static function activate() {
		// Set default options.
		// Allow developers to override API URL via wp-config.php constant
		$default_api_url = defined( 'MAPLEPRESS_API_URL' ) ? MAPLEPRESS_API_URL : '';

		$default_options = array(
			'api_url'          => $default_api_url, // Empty by default - user must configure
			'api_key'          => '',
			'site_id'          => '',
			'tenant_id'        => '',
			'domain'           => '',
			'plan_tier'        => '',
			'is_verified'      => false,
			'enabled'          => false,
			'needs_setup'      => true, // Flag to show setup notice
		);

		add_option( 'maplepress_settings', $default_options );

		// Set activation redirect flag
		set_transient( 'maplepress_activation_redirect', true, 30 );

		// Flush rewrite rules.
		flush_rewrite_rules();
	}
}
