init_hooks(); $this->init_components(); } /** * Get the single instance of the Plugin. * * @since 1.0.0 * @access public * * @return Plugin The single instance. */ public static function get_instance() { if ( is_null( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Initialize WordPress hooks. * * @since 1.0.0 * @access private * * @return void */ private function init_hooks() { // Activation hook. register_activation_hook( ACUMENPOPUP__FILE__, array( $this, 'activate' ) ); // Deactivation hook. register_deactivation_hook( ACUMENPOPUP__FILE__, array( $this, 'deactivate' ) ); } /** * Initialize all plugin components. * * @since 1.0.0 * @access private * * @return void */ private function init_components() { // Settings must be first so its hooks are registered before other components. $this->components['settings_manager'] = Core\Settings_Manager::get_instance(); // Core components. $this->components['category'] = Blocks\Category::get_instance(); $this->components['register'] = Blocks\Register::get_instance(); $this->components['assets'] = Core\Assets::get_instance(); $this->components['dynamic_style'] = Core\Dynamic_Style::get_instance(); $this->components['fonts_loader'] = Core\Fonts_Loader::get_instance(); $this->components['svg_support'] = Core\SVG_Support::get_instance(); $this->components['form_handler'] = Form\Handler::get_instance(); $this->components['tracker'] = Core\Tracker::get_instance(); // Dashboard components. $this->components['admin_menu'] = Dashboard\Admin_Menu::get_instance(); $this->components['campaigns'] = Dashboard\Campaigns::get_instance(); $this->components['ab_testing'] = Dashboard\AB_Testing::get_instance(); } /** * Plugin activation callback. * * Runs when the plugin is activated. * * @since 1.0.0 * @access public * * @return void */ public function activate() { // Set activation redirect flag. add_option( 'acumenpopup_do_activation_redirect', true ); // Flush rewrite rules on activation (safe here, not on every request). flush_rewrite_rules(); } /** * Plugin deactivation callback. * * Runs when the plugin is deactivated. * * @since 1.0.0 * @access public * * @return void */ public function deactivate() { // Flush rewrite rules on deactivation. flush_rewrite_rules(); } /** * Get a specific component instance. * * @since 1.0.0 * @access public * * @param string $component The component name. * * @return object|null The component instance or null if not found. */ public function get_component( $component ) { return isset( $this->components[ $component ] ) ? $this->components[ $component ] : null; } /** * Prevent cloning of the instance. * * @since 1.0.0 * @access public * * @return void */ public function __clone() { _doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'acumen-popup' ), '1.0.0' ); } /** * Prevent unserializing of the instance. * * @since 1.0.0 * @access public * * @return void */ public function __wakeup() { _doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing is forbidden.', 'acumen-popup' ), '1.0.0' ); } }