init_hooks(); } /** * Prevent cloning. */ private function __clone() {} /** * Prevent unserializing. * * @throws Exception If trying to unserialize. */ public function __wakeup() { throw new Exception( 'Cannot unserialize singleton' ); } /** * Initialize hooks. */ private function init_hooks() { // Activation/Deactivation hooks. register_activation_hook( ACA_PLUGIN_FILE, array( $this, 'activate' ) ); register_deactivation_hook( ACA_PLUGIN_FILE, array( $this, 'deactivate' ) ); // Plugin initialization. add_action( 'plugins_loaded', array( $this, 'init' ) ); // Declare HPOS compatibility. add_action( 'before_woocommerce_init', array( $this, 'declare_hpos_compatibility' ) ); } /** * Check if WooCommerce is active. * * @return bool */ public function is_woocommerce_active() { return class_exists( 'WooCommerce' ); } /** * Display admin notice if WooCommerce is not active. */ public function woocommerce_missing_notice() { ?>

' . esc_html__( 'Advanced Customer Account', 'advanced-customer-account' ) . '', '' . esc_html__( 'WooCommerce', 'advanced-customer-account' ) . '' ); ?>

is_woocommerce_active() ) { add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) ); return; } // Load plugin text domain. load_plugin_textdomain( 'advanced-customer-account', false, dirname( ACA_PLUGIN_BASENAME ) . '/languages' ); // Load dependencies. $this->load_dependencies(); // Initialize the loader. $this->loader = new ACA_Loader(); $this->loader->init(); /** * Fires when the plugin is fully loaded. * * @since 1.0.0 */ do_action( 'aca_loaded' ); } /** * Load required dependencies. */ private function load_dependencies() { require_once ACA_PLUGIN_DIR . 'includes/class-aca-loader.php'; } /** * Plugin activation. */ public function activate() { require_once ACA_PLUGIN_DIR . 'includes/class-aca-activator.php'; ACA_Activator::activate(); } /** * Plugin deactivation. */ public function deactivate() { require_once ACA_PLUGIN_DIR . 'includes/class-aca-deactivator.php'; ACA_Deactivator::deactivate(); } /** * Declare HPOS compatibility. */ public function declare_hpos_compatibility() { if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', ACA_PLUGIN_FILE, true ); } } /** * Get the loader instance. * * @return ACA_Loader */ public function get_loader() { return $this->loader; } /** * Get plugin version. * * @return string */ public function get_version() { return ACA_VERSION; } } /** * Returns the main instance of Advanced_Customer_Account. * * @return Advanced_Customer_Account */ function aca() { return Advanced_Customer_Account::get_instance(); } // Initialize the plugin. aca();