Make the games framework an opt-in Extended option (off by default) - #412
Merged
Conversation
A new `games` key in the extended options bundle (OS Settings → Features → Extended options, admins only, default on) gates the whole games module. When off, `includes/games/bootstrap.php` — now deferred to `plugins_loaded` (priority 5) so the new `desktop_mode_games_enabled` filter is hookable from any plugin — loads none of the module files: no schema check, no `/games/*` REST routes, no Heartbeat challenge channel, no Games window/icon, no games CSS. The shell config carries `gamesEnabled` so the client also skips the challenges Heartbeat contribution. Score/challenge tables and play-time meta persist across a disable/re-enable round trip. Extended-options saves now merge over stored values, so a payload that omits a key (stale client) can't silently reset it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WCknM6zk6JS14pdLUiqdRR
The kill switch now ships disabled — an admin opts in via OS Settings → Features → Extended options. The PHPUnit bootstrap force-enables the framework via the `desktop_mode_games_enabled` filter so the games test classes keep the module loaded; the kill-switch tests strip that filter locally to exercise the shipped default. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WCknM6zk6JS14pdLUiqdRR
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Turns the games framework into an opt-in feature, gated by a new toggle in OS Settings → Features → Extended options (admin-only). Off by default — while disabled, the framework consumes zero resources, server and client. An admin flips it on to get the Games app for every user; flipping it back off removes every trace at runtime while keeping saved scores and play time.
How
gameskey in thedesktop_mode_extended_optionssite option (defaultfalse), saved through the existingmanage_options-gated REST endpoint and rendered as a new checkbox in the Extended options section.includes/games/bootstrap.phpnow defers module loading toplugins_loaded(priority 5) and skips all ten module files while disabled: no schema check oninit/admin_init/rest_api_init, no/games/*REST routes, no Heartbeat challenge filter, no Games window/icon/dock registration, no games CSS enqueues. Only cost when off: one option read.desktop_mode_games_enabledfilter over the option — hookable from any plugin's main file since the load decision runs atplugins_loaded.gamesEnabled; whenfalsethe shell skipsbootGamesChallenges(), so the browser stops contributing the games key to every Heartbeat tick.desktop_mode_register_game()is undefined — identical to Desktop Mode being inactive, which the documentedfunction_exists()guard already covers. The payload builder is also gated for mid-request flips.desktop_mode_save_extended_options()now merges over stored values, so a payload omitting a key (stale client) can't silently reset it.Docs
hooks-reference.md(new filter entry),javascript-reference.md(gamesEnabled),architecture.md(games paragraph),examples/register-game.md(opt-in note).Testing
tests/phpunit/tests/gamesEnabledOption.php: default-off, explicit opt-in persistence, merge-safe saves, filter override both ways, payload gate. The PHPUnit bootstrap force-enables the framework via the filter so the existing games test classes keep the module loaded; the kill-switch tests strip it locally.npm run lint/typecheck/test:js(2191 tests) green,php -lclean on all changed PHP./wp-json/desktop-mode/v1/games/challenges404s,desktopModeConfig.gamesEnabled === false; toggle on + reload → Games appear for all users; toggle off again → gone, scores intact.🤖 Generated with Claude Code
https://claude.ai/code/session_01WCknM6zk6JS14pdLUiqdRR