<?php
/**
 * Initialization Action.
 *
 * @package PRECO
 */

namespace PRECO\Includes;

use PRECO\Includes\Admin\Admin;
use PRECO\Includes\Admin\Notice;
use PRECO\Includes\Admin\Rest\AiRest;
use PRECO\Includes\Admin\Rest\GlobalStylesRest;
use PRECO\Includes\Admin\Rest\RecommendationsRest;
use PRECO\Includes\Admin\Rest\PopupUpsellRest;
use PRECO\Includes\Admin\Rest\OrderBumpRest;
use PRECO\Includes\Admin\Rest\PreviewRest;
use PRECO\Includes\Admin\Rest\OnboardingRest;
use PRECO\Includes\Admin\RecommendationsCacheAdmin;
use PRECO\Includes\Admin\EventsCleanup\UserEventsCleanupScheduler;
use PRECO\Includes\Admin\OurPlugins;
use PRECO\Includes\Deactive\Deactive;
use PRECO\Includes\Analytics\Analytics;
use PRECO\Includes\Analytics\AnalyticsRest;
use PRECO\Includes\Frontend\UserEvents\UserEventsRest;
use PRECO\Includes\Frontend\Core\Frontend;

defined( 'ABSPATH' ) || exit;

/**
 * Initialization class.
 */
class Initialization {

	/**
	 * Setup class.
	 *
	 * @since v.1.0.0
	 */
	public function __construct() {
		$this->requires();
		add_filter( 'body_class', array( $this, 'add_body_class' ), 1 );
	}

	/**
	 * Necessary Requires Class
	 *
	 * @since v.1.0.0
	 * @return void
	 */
	public function requires() {
		new Preco();
		new Admin();
		new Notice();
		new OurPlugins();
		new Deactive();
		new RecommendationsRest();
		new PopupUpsellRest();
		new OrderBumpRest();
		new PreviewRest();
		new OnboardingRest();
		new GlobalStylesRest();
		new AiRest();
		new UserEventsRest();
		new UserEventsCleanupScheduler();
		new Analytics();
		new AnalyticsRest();
		( new RecommendationsCacheAdmin() )->register_hooks();
		new Frontend();
	}

	/**
	 * Add a body class on the frontend.
	 *
	 * @since 1.0.4
	 *
	 * @param array $classes Existing body classes.
	 * @return array Modified body classes.
	 */
	public function add_body_class( $classes ) {
		$classes[] = 'preco-front-page';
		return $classes;
	}
}
