<?php

/**
 * Fired during plugin activation.
 *
 * @link       https://example.com
 * @since      0.1.0
 *
 * @package    PinnerPress
 */

// Include default options
require_once plugin_dir_path(__FILE__) . 'pinnerpress-default-options.php';

// Include analytics class
require_once plugin_dir_path(__FILE__) . 'class-pinnerpress-analytics.php';

/**
 * Fired during plugin activation.
 *
 * This class defines all code necessary to run during the plugin's activation.
 *
 * @since      0.1.0
 * @package    PinnerPress
 */
if (!class_exists('PinnerPress_Activator')) {
class PinnerPress_Activator {

    /**
     * Execute actions during plugin activation.
     *
     * @since    0.1.0
     */
    public static function activate() {
        // Set default values for plugin settings only if not already set
        pinnerpress_set_default_options();
        
        // Create analytics tables and run any pending migrations.
        // Uses ensure_tables_exist() (not create_table()) so that migrations
        // also run on reactivation with existing legacy data.
        $analytics = new PinnerPress_Analytics();
        $analytics->ensure_tables_exist();
        
        // Set default analytics settings
        if (get_option('pinnerpress_analytics_enabled') === false) {
            add_option('pinnerpress_analytics_enabled', '1');
        }
        if (get_option('pinnerpress_analytics_ignore_logged_in') === false) {
            add_option('pinnerpress_analytics_ignore_logged_in', '1');
        }
        
        // Remove forced update_option() calls so existing settings are not overridden
    }
} }
