settings = new SettingsRegistry(); $this->modules = new ModuleManager(); $this->emails = new EmailManager( $this->settings ); } /** * Get the singleton instance. * * @return self */ public static function instance(): self { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Boot the plugin on `init` (priority 0) -- see the main plugin file. * * @return void */ public function boot(): void { // Settings from 1.x, before any module reads its settings. LegacyMigration::maybe_run(); // Modules register their own settings tabs/sections/fields as they boot. $this->modules->boot(); if ( is_admin() ) { $settings_page = new SettingsPage( $this->settings ); $settings_page->boot(); PromoCards::register(); Promotions::register(); UninstallChoice::register(); ( new ImportExport( $this->settings ) )->register(); ( new Tools( $this->settings ) )->register(); ( new SupportRequest( $this->modules ) )->register(); ( new SetupRequest() )->register(); ( new Menu( $this->settings, $this->modules, $settings_page ) )->register(); } } /** * Get the settings registry. * * @return SettingsRegistry */ public function settings(): SettingsRegistry { return $this->settings; } /** * Get the module manager. * * @return ModuleManager */ public function modules(): ModuleManager { return $this->modules; } /** * Get the managed-email registry. * * @return EmailManager */ public function emails(): EmailManager { return $this->emails; } /** * Activation callback. * * @return void */ public static function activate(): void { if ( false === get_option( 'aiou_version' ) ) { add_option( 'aiou_version', AIOU_VERSION ); } // Kept across deactivations, so the review notice's one-week wait // counts from the first install. if ( false === get_option( 'aiou_installed_at' ) ) { add_option( 'aiou_installed_at', time(), '', false ); } } /** * Deactivation callback. * * Intentionally does not delete options/data; see uninstall.php for the * deliberate, user-initiated cleanup path. Does clear this plugin's own * scheduled cron events, since a deactivated plugin's hook callbacks no * longer exist to handle them -- otherwise an orphaned cron entry would * keep firing with no listener. * * @return void */ public static function deactivate(): void { wp_clear_scheduled_hook( 'aiou_empty_trash_cron' ); wp_clear_scheduled_hook( 'aiou_email_log_cleanup_cron' ); wp_clear_scheduled_hook( 'aiou_duplicate_posts_scan_cron' ); \WordTenance\AllInOneUtilities\Modules\RandomContent\Feature::deactivate(); } }