true, 'text_rewrite' => true, 'summaries' => true, 'seo' => false, 'images' => false, 'generator' => true, 'usage' => true, ]; /** * Current module state merged from defaults and the saved option. * * @var array */ private array $state; /** * Load saved module state from the database. * * @since 1.0.0 */ public function __construct() { $saved = get_option( self::OPTION_KEY, [] ); $this->state = array_merge( self::DEFAULTS, (array) $saved ); } /** * Check whether a module is currently enabled. * * @since 1.0.0 * @param string $module Module slug (e.g. 'chat', 'seo'). * @return bool */ public function is_enabled( string $module ): bool { return (bool) ( $this->state[ $module ] ?? false ); } /** * Return the full module state map. * * @since 1.0.0 * @return array */ public function get_all(): array { return $this->state; } /** * Enable or disable a module and persist the new state. * * @since 1.0.0 * @param string $module Module slug. * @param bool $enabled Whether the module should be enabled. * @return void */ public function set( string $module, bool $enabled ): void { $this->state[ $module ] = $enabled; update_option( self::OPTION_KEY, $this->state ); } }