*/ private static $components = array(); /** * Hooks every component. Runs on plugins_loaded. */ public static function boot(): void { if ( ! empty( self::$components ) ) { return; } $connection = new Connection(); $stand = new Stand( $connection ); $frontend = new Frontend(); self::$components = array( Frontend::class => $frontend, Blocks::class => new Blocks( $frontend ), Shortcodes::class => new Shortcodes( $frontend ), Menus::class => new Menus(), Connection::class => $connection, Stand::class => $stand, Rest::class => new Rest( $connection, $stand ), Admin::class => new Admin( $connection, $stand ), Editor::class => new Editor( $connection ), Dashboard_Widget::class => new Dashboard_Widget( $connection, $stand ), Site_Health::class => new Site_Health( $connection, $stand ), Privacy::class => new Privacy(), Knowledge_Sync::class => new Knowledge_Sync( $connection, $stand ), Optimizers::class => new Optimizers(), Abilities::class => new Abilities( $connection, $stand ), ); foreach ( self::$components as $component ) { if ( method_exists( $component, 'register' ) ) { $component->register(); } } } /** * Returns a booted component. * * @param string $class_name Component class name. * @return object|null */ public static function get( string $class_name ) { return self::$components[ $class_name ] ?? null; } /** * Activation: remember to show Welcome once, on single activation only. * * @param bool $network_wide Whether the plugin is being network-activated. */ public static function activate( $network_wide = false ): void { if ( $network_wide ) { return; } // Bulk activation posts several plugins at once; WordPress then shouldn't be redirected. // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only check of the core bulk action. if ( isset( $_POST['checked'] ) && is_array( $_POST['checked'] ) && count( $_POST['checked'] ) > 1 ) { return; } set_transient( 'stand_chat_activation_redirect', get_current_user_id(), 60 ); } /** * Deactivation: the widget stops printing because the plugin no longer runs. * Nothing is deleted; uninstall.php removes stored data. */ public static function deactivate(): void { delete_transient( 'stand_chat_activation_redirect' ); Cache::flush(); } }