<?php

namespace WC_Affiliate\Bootstrap;

defined( 'ABSPATH' ) || exit;

/**
 * Plugin Initializer Class
 *
 * Handles plugin initialization including loading controllers, setting up hooks,
 * and initializing various plugin components for both admin and dashboard areas.
 *
 * @since   1.0.0
 * @package WC_Affiliate\Bootstrap
 */
class Initializer {

	/**
	 * Initialize the plugin's components.
	 */
	public static function initialize() {
		$initializer = new self();

		$initializer->load_admin_controllers();
		$initializer->load_public_controllers();
		$initializer->load_common_controllers();
	}

	/**
	 * Initialize controllers for wp-admin.
	 */
	protected function load_admin_controllers() {
		if ( is_admin() ) {
			new \WC_Affiliate\Controllers\Admin\Init();
			new \WC_Affiliate\Controllers\Admin\Menu();
		}
	}

	/**
	 * Initialize controllers for dashboard-facing parts of the site.
	 */
	protected function load_public_controllers() {
		if ( ! is_admin() ) {
			new \WC_Affiliate\Controllers\Front\Init();
			new \WC_Affiliate\Controllers\Front\Shortcode();
		}
	}

	/**
	 * Initialize controllers that operate on both admin and dashboard.
	 */
	protected function load_common_controllers() {
		new \WC_Affiliate\Controllers\Common\API();
		new \WC_Affiliate\Controllers\Common\Asset();
		new \WC_Affiliate\Controllers\Common\Email();
		new \WC_Affiliate\Controllers\Common\Init();
		new \WC_Affiliate\Controllers\Common\Process();
	}
}
