PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 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 All 34 releases
← All changes | includes/extended-options.php +82 -52 0.9.11.1.10 View file →
@@ -1,13 +1,16 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Platform-wide extended options.
3 + * OpenStation — Platform-wide extended options.
4 4 *
5 5 * System-level toggles that enhance the WordPress admin with extra
6 - * desktop-mode capabilities. Stored in `wp_options` (not per-user) so
6 + * openstation capabilities. Stored in `wp_options` (not per-user) so
7 7 * they affect every user on the site. Admin-only to read or write.
8 8 *
9 9 * Current options:
10 + * - window_prewarm: preload windows on hover. Defaults to true.
11 + * - admin_asset_cache: share cached admin assets across windows.
12 + * Defaults to true. Both performance options apply on shell reload.
10 13 * - media_library_enhanced: when true, enqueues a small JS shim on
11 14 * every admin page that makes Media Library .attachment tiles
12 15 * draggable — users can drag images out of the library into any
13 16 * drop target (text fields, TinyMCE/Gutenberg blocks, custom
@@ -13,17 +16,46 @@
13 16 * drop target (text fields, TinyMCE/Gutenberg blocks, custom
14 17 * drop zones) without the library having to be re-built from
15 18 * scratch. **Defaults to `true`** — the enhancement is opt-OUT;
16 19 * sites that want vanilla Media Library behaviour must explicitly
17 - * toggle it off in OS Settings → Extended Options.
20 + * toggle it off in OS Settings → Features → Extended options.
21 + * - games: when true, the games framework loads — Games hub window +
22 + * desktop icon, built-in games, score/challenge REST routes, the
23 + * Heartbeat challenge channel, and the schema check. **Defaults to
24 + * `false`** — games are opt-IN; an admin turns them on in
25 + * OS Settings → Features → Extended options. While off,
26 + * `includes/games/bootstrap.php` skips every module file, so the
27 + * framework consumes no resources at all (see
28 + * `openstation_games_enabled()`).
29 + * - agents: when true, the AI Agents framework loads — synthetic
30 + * agent users, the `/desktop-mode/v1/agents` REST surface, the
31 + * Agents section in My WordPress, and the Agent chat window.
32 + * **Defaults to `false`** — agents are opt-IN. While off,
33 + * `includes/agents/bootstrap.php` skips every module file (see
34 + * `openstation_agents_enabled()`).
35 + * - network: when true, the OpenStation Network module loads — the
36 + * keypair, the identity and list routes, the registry, the Network
37 + * window, and the hop token that logs a user in on arrival at
38 + * another install. **Defaults to `false`** — the network is
39 + * opt-IN. While off, `includes/network/bootstrap.php` skips every
40 + * module file (see `openstation_network_enabled()`), and a
41 + * multisite keeps the site switcher it has on its own.
18 42 *
19 - * @package WPDesktopMode
43 + * @package OpenStation
20 44 */
21 45
22 46 defined( 'ABSPATH' ) || exit;
23 47
24 -/** wp_options key for the extended options bundle. */
25 -const DESKTOP_MODE_EXTENDED_OPTIONS_KEY = 'desktop_mode_extended_options';
48 +/**
49 + * The `wp_options` key for the extended options bundle.
50 + *
51 + * The VALUE keeps its pre-rebrand spelling on purpose: it is a
52 + * persisted or externally-visible identifier, so renaming it would
53 + * orphan data already written by live installs (or break a live
54 + * URL). The mismatch between this constant's name and its value is
55 + * deliberate — it is NOT a half-finished rename.
56 + */
57 +const OPENSTATION_EXTENDED_OPTIONS_KEY = 'desktop_mode_extended_options';
26 58
27 59 // ---------------------------------------------------------------------------
28 60 // Get / save
29 61 // ---------------------------------------------------------------------------
@@ -30,17 +62,20 @@
30 62
31 63 /**
32 64 * Returns the extended options with defaults filled in.
33 65 *
34 - * @since 0.14.0
35 - *
36 - * @return array{ media_library_enhanced: bool }
66 + * @return array{ media_library_enhanced: bool, games: bool, agents: bool, network: bool, window_prewarm: bool, admin_asset_cache: bool }
37 67 */
38 -function desktop_mode_get_extended_options() {
68 +function openstation_get_extended_options() {
39 69 $defaults = array(
40 70 'media_library_enhanced' => true,
71 + 'window_prewarm' => true,
72 + 'admin_asset_cache' => true,
73 + 'games' => false,
74 + 'agents' => false,
75 + 'network' => false,
41 76 );
42 - $raw = get_option( DESKTOP_MODE_EXTENDED_OPTIONS_KEY, array() );
77 + $raw = get_option( OPENSTATION_EXTENDED_OPTIONS_KEY, array() );
43 78 if ( ! is_array( $raw ) ) {
44 79 return $defaults;
45 80 }
46 81 // Fall back to the default only when the key is ABSENT — so an
@@ -46,31 +81,36 @@
46 81 // Fall back to the default only when the key is ABSENT — so an
47 82 // admin who explicitly saved `false` stays opted-out even though
48 83 // the shipped default is now `true`. `! empty()` would wrongly
49 84 // coerce an explicit `false` back to the default.
50 - return array(
51 - 'media_library_enhanced' => array_key_exists( 'media_library_enhanced', $raw )
52 - ? (bool) $raw['media_library_enhanced']
53 - : $defaults['media_library_enhanced'],
54 - );
85 + $clean = array();
86 + foreach ( $defaults as $key => $default ) {
87 + $clean[ $key ] = array_key_exists( $key, $raw )
88 + ? (bool) $raw[ $key ]
89 + : $default;
90 + }
91 + return $clean;
55 92 }
56 93
57 94 /**
58 95 * Persists extended options to `wp_options`.
59 96 *
60 - * @since 0.14.0
61 - *
62 97 * @param mixed $raw Incoming payload.
63 98 * @return bool
64 99 */
65 -function desktop_mode_save_extended_options( $raw ) {
100 +function openstation_save_extended_options( $raw ) {
66 101 if ( ! is_array( $raw ) ) {
67 102 return false;
68 103 }
69 - $clean = array(
70 - 'media_library_enhanced' => ! empty( $raw['media_library_enhanced'] ),
71 - );
72 - return update_option( DESKTOP_MODE_EXTENDED_OPTIONS_KEY, $clean, false );
104 + // Merge over the current values so a payload that omits a key (an
105 + // older client, a partial save) can't silently reset it.
106 + $clean = openstation_get_extended_options();
107 + foreach ( $clean as $key => $current ) {
108 + if ( array_key_exists( $key, $raw ) ) {
109 + $clean[ $key ] = ! empty( $raw[ $key ] );
110 + }
111 + }
112 + return update_option( OPENSTATION_EXTENDED_OPTIONS_KEY, $clean, false );
73 113 }
74 114
75 115 // ---------------------------------------------------------------------------
76 116 // REST endpoint — admin only
@@ -77,12 +117,10 @@
77 117 // ---------------------------------------------------------------------------
78 118
79 119 /**
80 120 * Registers the extended options REST route.
81 - *
82 - * @since 0.14.0
83 121 */
84 -function desktop_mode_register_extended_options_rest_routes() {
122 +function openstation_register_extended_options_rest_routes() {
85 123 register_rest_route(
86 124 'desktop-mode/v1',
87 125 '/extended-options',
88 126 array(
@@ -87,15 +125,15 @@
87 125 '/extended-options',
88 126 array(
89 127 array(
90 128 'methods' => WP_REST_Server::READABLE,
91 - 'callback' => 'desktop_mode_rest_get_extended_options',
92 - 'permission_callback' => 'desktop_mode_rest_extended_options_permission',
129 + 'callback' => 'openstation_rest_get_extended_options',
130 + 'permission_callback' => 'openstation_rest_extended_options_permission',
93 131 ),
94 132 array(
95 133 'methods' => WP_REST_Server::CREATABLE,
96 - 'callback' => 'desktop_mode_rest_save_extended_options',
97 - 'permission_callback' => 'desktop_mode_rest_extended_options_permission',
134 + 'callback' => 'openstation_rest_save_extended_options',
135 + 'permission_callback' => 'openstation_rest_extended_options_permission',
98 136 'args' => array(
99 137 'options' => array(
100 138 'required' => true,
101 139 'type' => 'object',
@@ -104,21 +142,19 @@
104 142 ),
105 143 )
106 144 );
107 145 }
108 -add_action( 'rest_api_init', 'desktop_mode_register_extended_options_rest_routes' );
146 +add_action( 'rest_api_init', 'openstation_register_extended_options_rest_routes' );
109 147
110 148 /**
111 149 * Permission: admins only.
112 150 *
113 - * @since 0.14.0
114 - *
115 151 * @return bool|WP_Error
116 152 */
117 -function desktop_mode_rest_extended_options_permission() {
153 +function openstation_rest_extended_options_permission() {
118 154 if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
119 155 return new WP_Error(
120 - 'desktop_mode_extended_forbidden',
156 + 'openstation_extended_forbidden',
121 157 'Only administrators can manage extended options.',
122 158 array( 'status' => 403 )
123 159 );
124 160 }
@@ -127,28 +163,24 @@
127 163
128 164 /**
129 165 * GET /desktop-mode/v1/extended-options
130 166 *
131 - * @since 0.14.0
132 - *
133 167 * @return WP_REST_Response
134 168 */
135 -function desktop_mode_rest_get_extended_options() {
136 - return rest_ensure_response( desktop_mode_get_extended_options() );
169 +function openstation_rest_get_extended_options() {
170 + return rest_ensure_response( openstation_get_extended_options() );
137 171 }
138 172
139 173 /**
140 174 * POST /desktop-mode/v1/extended-options
141 175 *
142 - * @since 0.14.0
143 - *
144 176 * @param WP_REST_Request $request
145 177 * @return WP_REST_Response
146 178 */
147 -function desktop_mode_rest_save_extended_options( WP_REST_Request $request ) {
179 +function openstation_rest_save_extended_options( WP_REST_Request $request ) {
148 180 $payload = $request->get_param( 'options' );
149 - desktop_mode_save_extended_options( $payload );
150 - return rest_ensure_response( desktop_mode_get_extended_options() );
181 + openstation_save_extended_options( $payload );
182 + return rest_ensure_response( openstation_get_extended_options() );
151 183 }
152 184
153 185 // ---------------------------------------------------------------------------
154 186 // Media Library enhancement enqueue
@@ -158,26 +190,24 @@
158 190 * Enqueues the media-library enhancement shim when the admin has
159 191 * toggled it on. The script is a no-op on pages where wp.media isn't
160 192 * loaded (it checks at runtime), so there's no harm in enqueuing
161 193 * globally in the admin.
162 - *
163 - * @since 0.14.0
164 194 */
165 -function desktop_mode_enqueue_media_library_enhancement() {
195 +function openstation_enqueue_media_library_enhancement() {
166 196 if ( ! is_admin() || ! is_user_logged_in() ) {
167 197 return;
168 198 }
169 199
170 - $options = desktop_mode_get_extended_options();
200 + $options = openstation_get_extended_options();
171 201 if ( empty( $options['media_library_enhanced'] ) ) {
172 202 return;
173 203 }
174 204
175 205 wp_enqueue_script(
176 - 'desktop-mode-media-library-enhanced',
177 - DESKTOP_MODE_URL . 'assets/js/media-library-enhanced.js',
206 + 'os-media-library-enhanced',
207 + OPENSTATION_URL . 'assets/js/media-library-enhanced.js',
178 208 array(),
179 - DESKTOP_MODE_VERSION,
209 + OPENSTATION_VERSION,
180 210 true
181 211 );
182 212 }
183 -add_action( 'admin_enqueue_scripts', 'desktop_mode_enqueue_media_library_enhancement', 20 );
213 +add_action( 'admin_enqueue_scripts', 'openstation_enqueue_media_library_enhancement', 20 );