PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.9
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.9
1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 0.8.6 All 33 releases
desktop-mode / includes / games / bootstrap.php

bootstrap.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.9, at includes/games/bootstrap.php

81 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation — Games bootstrap.
4 *
5 * Loads the game system: schema (scores + challenges tables), the
6 * framework config (shared dictionary URL), the server-side
7 * game registry, the score/challenge store, the play-time store,
8 * REST routes, the Heartbeat challenge channel, the Games window +
9 * desktop icon, and the built-in game registrations (Inkfall,
10 * Alphabet Soup).
11 *
12 * The whole module is gated on the site-wide `games` extended option
13 * (OS Settings → Features → Extended options, admins only), which is
14 * OFF by default — games are opt-in. While the option is off, none of
15 * the module files load — no tables check on `init`, no REST routes,
16 * no Heartbeat channel, no window/icon — so the games framework costs
17 * nothing beyond the option read below.
18 * For third-party plugins the disabled state is indistinguishable from
19 * OpenStation not being active: `openstation_register_game()` is
20 * undefined, which the documented `function_exists()` guard already
21 * handles (see docs/examples/register-game.md).
22 *
23 * Loading is deferred to `plugins_loaded` (priority 5) so any regular
24 * plugin can hook the `openstation_games_enabled` filter in time to
25 * influence the decision.
26 *
27 * New `require_once` lines belong in the loader below so the rest of
28 * the codebase keeps loading the feature through one entry point.
29 *
30 * @package OpenStation
31 */
32
33 defined( 'ABSPATH' ) || exit;
34
35 /**
36 * Whether the games framework is enabled site-wide.
37 *
38 * Backed by the `games` key of the extended options bundle
39 * (`openstation_get_extended_options()`), default off — opt-in.
40 *
41 * @return bool
42 */
43 function openstation_games_enabled() {
44 $options = openstation_get_extended_options();
45 $enabled = ! empty( $options['games'] );
46
47 /**
48 * Filters whether the games framework is enabled site-wide.
49 *
50 * Runs on `plugins_loaded` (priority 5) to decide whether the
51 * games module loads at all, and again at runtime wherever the
52 * enabled state is consulted (payload build, shell config).
53 *
54 * @param bool $enabled Whether the games framework is enabled.
55 */
56 return (bool) apply_filters( 'openstation_games_enabled', $enabled );
57 }
58
59 /**
60 * Loads the games module when the framework is enabled.
61 *
62 * @access private
63 */
64 function openstation_games_load() {
65 if ( ! openstation_games_enabled() ) {
66 return;
67 }
68
69 require_once OPENSTATION_DIR . 'includes/games/schema.php';
70 require_once OPENSTATION_DIR . 'includes/games/config.php';
71 require_once OPENSTATION_DIR . 'includes/games/registry.php';
72 require_once OPENSTATION_DIR . 'includes/games/store.php';
73 require_once OPENSTATION_DIR . 'includes/games/playtime.php';
74 require_once OPENSTATION_DIR . 'includes/games/rest.php';
75 require_once OPENSTATION_DIR . 'includes/games/heartbeat.php';
76 require_once OPENSTATION_DIR . 'includes/games/window.php';
77 require_once OPENSTATION_DIR . 'includes/games/inkfall.php';
78 require_once OPENSTATION_DIR . 'includes/games/alphabet-soup.php';
79 }
80 add_action( 'plugins_loaded', 'openstation_games_load', 5 );
81