boot(); } return self::$instance; } /** * Register every service. * * @return void */ private function boot() { ( new OAuth() )->register(); ( new CatalogSync() )->register(); ( new Storefront() )->register(); ( new ButtonBlock() )->register(); ( new Cart() )->register(); ( new Attribution() )->register(); ( new Privacy() )->register(); if ( is_admin() ) { ( new SettingsPage() )->register(); ( new ProductPanel() )->register(); } } /** * Activation: nothing remote happens until the merchant connects. * * @return void */ public static function activate() { if ( false === get_option( Support\Settings::OPTION ) ) { add_option( Support\Settings::OPTION, Support\Settings::defaults(), '', true ); } } /** * Deactivation: stop background jobs (the connection is kept for reactivation). * * @return void */ public static function deactivate() { if ( function_exists( 'as_unschedule_all_actions' ) ) { CatalogSync::unschedule(); as_unschedule_all_actions( Attribution::ACTION, null, Attribution::GROUP ); as_unschedule_all_actions( Attribution::ACTION_REFND, null, Attribution::GROUP ); } } }