Skip to content

Make the games framework an opt-in Extended option (off by default) - #412

Merged
AllTerrainDeveloper merged 2 commits into
trunkfrom
add/games-disable-setting
Jul 24, 2026
Merged

Make the games framework an opt-in Extended option (off by default)#412
AllTerrainDeveloper merged 2 commits into
trunkfrom
add/games-disable-setting

Conversation

@AllTerrainDeveloper

@AllTerrainDeveloper AllTerrainDeveloper commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

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.

image

How

  • New games key in the desktop_mode_extended_options site option (default false), saved through the existing manage_options-gated REST endpoint and rendered as a new checkbox in the Extended options section.
  • includes/games/bootstrap.php now defers module loading to plugins_loaded (priority 5) and skips all ten module files while disabled: no schema check on init/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.
  • New desktop_mode_games_enabled filter over the option — hookable from any plugin's main file since the load decision runs at plugins_loaded.
  • Shell config carries gamesEnabled; when false the shell skips bootGamesChallenges(), so the browser stops contributing the games key to every Heartbeat tick.
  • Third-party safety: while games are off, desktop_mode_register_game() is undefined — identical to Desktop Mode being inactive, which the documented function_exists() guard already covers. The payload builder is also gated for mid-request flips.
  • Merge-safe saves: desktop_mode_save_extended_options() now merges over stored values, so a payload omitting a key (stale client) can't silently reset it.
  • Data survives: score/challenge tables and play-time meta are untouched; enable → disable → re-enable restores everything.

Docs

hooks-reference.md (new filter entry), javascript-reference.md (gamesEnabled), architecture.md (games paragraph), examples/register-game.md (opt-in note).

Testing

  • New 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.
  • Full PHPUnit suite green (1339 tests), npm run lint / typecheck / test:js (2191 tests) green, php -l clean on all changed PHP.
  • Manual QA: fresh site → no Games dock item/icon/window, /wp-json/desktop-mode/v1/games/challenges 404s, 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

Open WordPress Playground Preview

AllTerrainDeveloper and others added 2 commits July 24, 2026 11:43
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
@AllTerrainDeveloper AllTerrainDeveloper changed the title Add a site-wide OS Settings toggle to fully disable the games framework Make the games framework an opt-in Extended option (off by default) Jul 24, 2026
@AllTerrainDeveloper
AllTerrainDeveloper merged commit 1797eef into trunk Jul 24, 2026
5 checks passed
@AllTerrainDeveloper
AllTerrainDeveloper deleted the add/games-disable-setting branch July 24, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant