<?php
/**
 * Manager for Campaign Tracker functionality.
 *
 * @package     EDD\Pro\CampaignTracker
 * @copyright   Copyright (c) 2025, Sandhills Development, LLC
 * @license     https://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       3.6.3
 */

namespace EDD\Pro\CampaignTracker;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

use EDD\EventManagement\MiniManager;

/**
 * Campaign Tracker Manager class.
 *
 * @since 3.6.3
 */
class Manager extends MiniManager {

	/**
	 * Get the events to subscribe to.
	 *
	 * @since 3.6.3
	 * @return array
	 */
	public static function get_subscribed_events() {
		// Don't load if the feature is disabled.
		if ( ! edd_get_option( 'campaign_tracker', false ) ) {
			return array();
		}

		return parent::get_subscribed_events();
	}

	/**
	 * Get the event classes.
	 *
	 * @since 3.6.3
	 * @return array
	 */
	protected function get_event_classes(): array {
		$classes = array(
			new Campaigns\Logger(),
			new Emails\EmailTags(),
			new Upgrades\Migration(),
			new Upgrades\CampaignMetaMigration(),
		);

		if ( is_admin() ) {
			$classes[] = new Admin\Orders\Details\Campaign();
			$classes[] = new Admin\Reports\Loader();
			$classes[] = new Admin\Reports\Filter();
			$classes[] = new Admin\Exports\Loader();
		}

		// Only load CLI commands when WP-CLI is running.
		if ( defined( 'WP_CLI' ) && WP_CLI ) {
			$classes[] = new CLI\CampaignTracker();
		}

		return $classes;
	}
}
