<?php
/**
 * Plugin Name: HVAC Community Events (Staging)
 * Plugin URI: https://upskillhvac.com
 * Description: Custom plugin for HVAC trainer event management system - Staging Version
 * Version: 1.0.0
 * Author: Upskill HVAC
 * Author URI: https://upskillhvac.com
 * License: GPL-2.0+
 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain: hvac-community-events
 */

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

// Define plugin constants
define('HVAC_CE_VERSION', '1.0.0');
define('HVAC_CE_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('HVAC_CE_PLUGIN_URL', plugin_dir_url(__FILE__));

/**
 * Minimal activation function for staging environment
 */
function hvac_ce_staging_activate() {
    // Log activation
    error_log('[HVAC CE Staging] Activation started');
    
    // Create a test option
    add_option('hvac_ce_staging_activated', 'yes');
    
    // Create a simple role
    add_role(
        'hvac_trainer_staging',
        'HVAC Trainer (Staging)',
        [
            'read' => true,
            'upload_files' => true,
            'hvac_staging_access' => true
        ]
    );
    
    error_log('[HVAC CE Staging] Activation completed');
}
register_activation_hook(__FILE__, 'hvac_ce_staging_activate');

/**
 * Deactivation function
 */
function hvac_ce_staging_deactivate() {
    // Remove the test option and role
    delete_option('hvac_ce_staging_activated');
    remove_role('hvac_trainer_staging');
    
    error_log('[HVAC CE Staging] Plugin deactivated');
}
register_deactivation_hook(__FILE__, 'hvac_ce_staging_deactivate');

/**
 * Initialize the plugin
 */
function hvac_ce_staging_init() {
    // Add an admin notice
    if (is_admin()) {
        add_action('admin_notices', 'hvac_ce_staging_admin_notice');
    }
}
add_action('plugins_loaded', 'hvac_ce_staging_init');

/**
 * Display admin notice about successful activation
 */
function hvac_ce_staging_admin_notice() {
    if (get_option('hvac_ce_staging_activated') === 'yes') {
        ?>
        <div class="notice notice-success is-dismissible">
            <p><?php _e('HVAC Community Events (Staging) plugin activated successfully!', 'hvac-community-events'); ?></p>
            <p><?php _e('This is a minimal version for testing purposes.', 'hvac-community-events'); ?></p>
        </div>
        <?php
    }
}

// Dummy shortcode functions to prevent errors
function hvac_ce_dummy_shortcode() {
    return '<p>This is a placeholder for the HVAC Community Events functionality.</p>';
}

// Register shortcodes
add_shortcode('hvac_trainer_dashboard', 'hvac_ce_dummy_shortcode');
add_shortcode('hvac_community_login', 'hvac_ce_dummy_shortcode');
add_shortcode('hvac_trainer_registration', 'hvac_ce_dummy_shortcode');
add_shortcode('hvac_trainer_profile', 'hvac_ce_dummy_shortcode');
add_shortcode('hvac_event_summary', 'hvac_ce_dummy_shortcode');
add_shortcode('hvac_email_attendees', 'hvac_ce_dummy_shortcode');