|false */ public static function formScope() { return FormManagerService::getUserAllowedFormsScope(); } /** True when the current user may access the given form. */ public static function canAccessForm($formId) { return FormManagerService::hasFormPermission($formId); } /** * The master on/off switch. Ships OFF; enabled from Settings → MCP. Stored in * a dedicated autoloaded option so the boot guard costs no extra query. */ public static function isEnabled() { $settings = get_option(self::OPTION, []); return is_array($settings) && isset($settings['enabled']) && 'yes' === $settings['enabled']; } /** * Persist the master switch. Enabling MCP opens the whole tool surface, so we * fail closed unless the caller can manage_options (defense in depth — the * REST route is gated too, but the toolkit toggle path delegates auth out). */ public static function setEnabled($enabled) { if (!current_user_can('manage_options')) { return false; } $settings = get_option(self::OPTION, []); if (!is_array($settings)) { $settings = []; } $settings['enabled'] = $enabled ? 'yes' : 'no'; update_option(self::OPTION, $settings, 'yes'); return (bool) $enabled; } /** * Drop settings keys from removed features so stale state can't linger. Writes * only when a legacy key is actually present, so it self-heals once and is a * no-op thereafter. Currently prunes 'new_tools_enabled' (the retired * advanced-tools opt-in). Runs unauthenticated: it removes dead data, never * changes the live 'enabled' switch. */ public static function pruneLegacyKeys() { $settings = get_option(self::OPTION, []); if (!is_array($settings) || !array_key_exists('new_tools_enabled', $settings)) { return; } unset($settings['new_tools_enabled']); update_option(self::OPTION, $settings, 'yes'); } }