<?php
if (!defined('ABSPATH')) exit; // Exit if accessed directly
/**
 * The core plugin class.
 *
 * This is used to define internationalization, admin-specific hooks, and
 * public-facing site hooks.
 *
 * @package    Event_Monster
 * @subpackage Event_Monster/includes
 */
class Event_Monster_Free_Main
{

    /**
     * The unique identifier of this plugin.
     * @var string
     */
    protected $plugin_name;

    /**
     * The current version of the plugin.
     * @var string
     */
    protected $version;

    /**
     * Define the core functionality of the plugin.
     */
    public function __construct()
    {
        if (defined('EM_FREE_VERSION')) {
            $this->version = EM_FREE_VERSION;
        } else {
            $this->version = '4.1.0';
        }
        $this->plugin_name = 'event-monster';

        $this->load_dependencies();
        $this->define_shortcodes();
        $this->define_post_types();
        $this->define_admin_hooks();
        $this->define_public_hooks();
    }

    /**
     * Load the required dependencies for this plugin.
     *
     * Include the files that define the classes that power the plugin.
     */
    private function load_dependencies()
    {

        // The class responsible for managing all scripts and styles.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-assets.php';

        // The class responsible for defining all actions that occur in the admin area.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-admin.php';
        // Note: Tickets, Coupons, and Payments list tables are Pro-only features.
        require_once EM_FREE_PLUGIN_DIR . 'includes/admin/class-event-monster-visitors-list-table.php';

        // The class for handling custom post type meta boxes.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-metabox.php';

        // The class for handling layout settings.
        require_once EM_FREE_PLUGIN_DIR . 'admin/event-layout-settings.php';

       

        // The class for handling all AJAX requests.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-ajax.php';

        // The class for handling all email sending.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-emails.php';

        // The class responsible for defining all shortcodes.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-shortcodes.php';

        // The class responsible for defining all public-facing functionality.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-public.php';

        // The class for generic helper functions.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-helpers.php';

        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-cpt.php';

        // The class for handling major update notifications.
        require_once EM_FREE_PLUGIN_DIR . 'includes/class-event-monster-update-notice.php';

    }


    /**
     * Register all shortcodes for the plugin.
     */
    private function define_shortcodes()
    { 
        new Event_Monster_Free_Shortcodes();
    }

    /**
     * Instantiate the CPT class to register post types and taxonomies.
     */
    private function define_post_types()
    { // <-- Add This
        new Event_Monster_Free_CPT();
    }

    /**
     * Register all of the hooks related to the admin area functionality.
     */
    private function define_admin_hooks()
    {
        // Instantiate the Admin class, which registers all the menu pages and hooks.
        new Event_Monster_Free_Admin($this->get_plugin_name(), $this->get_version());

        // Instantiate the Metabox class.
        new Event_Monster_Free_Metabox();

        // Instantiate the Layout Settings class.
        new EM_Free_Layout_Settings();

        // Instantiate the Email class.
        new Event_Monster_Free_Emails();

        // Instantiate the Update Notice class.
        new Event_Monster_Free_Update_Notice();
    }

    /**
     * Register all of the hooks related to the public-facing functionality.
     */
    private function define_public_hooks()
    {
        // Instantiate the Public class
        new Event_Monster_Free_Public($this->get_version());

        // NOTE: Shortcodes are already instantiated in define_shortcodes()
        // Do NOT instantiate again here to avoid duplicate shortcode registration

        // Instantiate the AJAX handler
        Event_Monster_Free_Ajax::instance(); // Using the static instance method we created
    }

    /**
     * A simple run method to kick things off.
     * In this structure, the constructors do all the work of adding hooks,
     * so this method is very simple.
     */
    public function run()
    {
        // Instantiate the Assets class to register and enqueue scripts/styles
        new Event_Monster_Free_Assets($this->get_version());

        // Initialize calendar functionality
        new Event_Monster_Free_Calendar();
    }

    /**
     * The name of the plugin.
     * @return string The name of the plugin.
     */
    public function get_plugin_name()
    {
        return $this->plugin_name;
    }

    /**
     * The version of the plugin.
     * @return string The version of the plugin.
     */
    public function get_version()
    {
        return $this->version;
    }
}