<?php

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

/**
 * Bidda Loader Class
 * 
 * This class is responsible for loading all the components of the Bidda plugin
 */
class Bidda_Loader {
    
    /**
     * The array of actions registered with WordPress
     */
    protected $actions;
    
    /**
     * The array of filters registered with WordPress
     */
    protected $filters;
    
    /**
     * Initialize the collections used to maintain the actions and filters
     */
    public function __construct() {
        $this->actions = array();
        $this->filters = array();
    }
    
    /**
     * Run the loader to execute all of the hooks with WordPress
     */
    public function run() {
        $this->load_dependencies();
        $this->define_admin_hooks();
        $this->define_public_hooks();
    }
    
    /**
     * Load the required dependencies for this plugin
     */
    private function load_dependencies() {
        // Include required files
        require_once BIDDA_PLUGIN_DIR . 'includes/class-bidda-admin.php';
        require_once BIDDA_PLUGIN_DIR . 'includes/class-bidda-public.php';
        require_once BIDDA_PLUGIN_DIR . 'includes/class-bidda-database.php';
        require_once BIDDA_PLUGIN_DIR . 'includes/class-bidda-shortcodes.php';
    }
    
    /**
     * Register all of the hooks related to the admin area functionality
     */
    private function define_admin_hooks() {
        $plugin_admin = new Bidda_Admin();
        
        // Add admin menu
        add_action('admin_menu', array($plugin_admin, 'add_admin_menu'));
        
        // Add settings link to plugin page
        add_filter('plugin_action_links_' . plugin_basename(BIDDA_PLUGIN_DIR . 'bidda-school-management.php'), 
                  array($plugin_admin, 'add_settings_link'));
    }
    
    /**
     * Register all of the hooks related to the public-facing functionality
     */
    private function define_public_hooks() {
        $plugin_public = new Bidda_Public();
        
        // Register shortcodes
        add_action('init', array($plugin_public, 'register_shortcodes'));
        
        // Enqueue styles and scripts
        add_action('wp_enqueue_scripts', array($plugin_public, 'enqueue_styles'));
        add_action('wp_enqueue_scripts', array($plugin_public, 'enqueue_scripts'));
    }
}