<?php

namespace Quicker\Core;

use Quicker\Utils\Singleton;
use Quicker\Core\Frontend\MinicartAjaxAction;

/**
 * Base Class
 *
 * @since 1.0.0
 */
class Core {

	use Singleton;

	/**
	 * Initialize all modules.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function init() {
		if ( ! is_admin() ) {
			// Load frontend
			\Quicker\Core\Frontend\Frontend::instance()->init();
		} else {
			\Quicker\Core\Admin\Menus::instance()->init();
			if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
				\Quicker\Core\Admin\Settings\Settings::instance()->init();
				// Also init frontend so filters like woocommerce_add_to_cart_validation are registered during AJAX.
				\Quicker\Core\Frontend\Frontend::instance()->init();
			}
		}
		// addons
		if ( class_exists( 'QuickerPro' ) ) {
			\Quicker\Core\Modules\Product_Addons\Product_Addons::instance()->init();
		}
		// Ajax submit
		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
			\Quicker\Core\Frontend\Ajax_Action::instance()->init();
		}
	}
}
