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/assets.php +414 -162 0.8.71.1.10 View file →
@@ -1,27 +1,63 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode asset registration.
3 + * OpenStation asset registration.
4 4 *
5 - * Registers all desktop-mode CSS and JS handles with WordPress so they can
5 + * Registers all openstation CSS and JS handles with WordPress so they can
6 6 * be enqueued from anywhere in the plugin (or by third parties).
7 7 *
8 - * @package WPDesktopMode
8 + * @package OpenStation
9 9 */
10 10
11 11 defined( 'ABSPATH' ) || exit;
12 12
13 13 /**
14 - * Registers the desktop mode CSS and JS handles.
14 + * Cache-buster for a stylesheet that `@import`s sub-sheets: the max
15 + * `filemtime` across the file AND everything it (transitively) imports.
16 + * Sub-sheet URLs carry no `?ver=` of their own, so the parent's stamp is
17 + * the only cache key the browser ever sees for the subtree — it must
18 + * move when any member changes.
15 19 *
16 - * @since 0.1.0
20 + * @param string $relative Stylesheet path relative to the plugin dir.
21 + * @param string $fallback Version to use when the file is missing.
22 + * @return string Version string.
17 23 */
18 -function desktop_mode_register_assets() {
19 - $version = DESKTOP_MODE_VERSION;
20 - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
24 +function openstation_css_subtree_version( $relative, $fallback ) {
25 + $root = OPENSTATION_DIR . $relative;
26 + if ( ! file_exists( $root ) ) {
27 + return (string) $fallback;
28 + }
29 + $max = (int) filemtime( $root );
30 + $queue = array( $root );
31 + $seen = array( $root => true );
32 + while ( ! empty( $queue ) ) {
33 + $file = array_pop( $queue );
34 + $css = (string) file_get_contents( $file );
35 + if ( ! preg_match_all( '/@import\s+url\(\s*["\']?([^"\')\s]+)["\']?\s*\)/i', $css, $matches ) ) {
36 + continue;
37 + }
38 + foreach ( $matches[1] as $import ) {
39 + $path = dirname( $file ) . '/' . $import;
40 + if ( ! file_exists( $path ) || isset( $seen[ $path ] ) ) {
41 + continue;
42 + }
43 + $seen[ $path ] = true;
44 + $max = max( $max, (int) filemtime( $path ) );
45 + $queue[] = $path;
46 + }
47 + }
48 + return (string) $max;
49 +}
21 50
51 +/**
52 + * Registers the OpenStation CSS and JS handles.
53 + */
54 +function openstation_register_assets() {
55 + $version = OPENSTATION_VERSION;
56 + $suffix = openstation_asset_suffix();
57 +
22 58 // `filemtime`-stamped version for built bundles. The plugin-wide
23 - // `DESKTOP_MODE_VERSION` is bumped per release, but the bundles
59 + // `OPENSTATION_VERSION` is bumped per release, but the bundles
24 60 // iterate faster — without a per-file mtime stamp, two clients
25 61 // loading the same `?ver=…` URL can be served different bytes
26 62 // (whichever build was on disk at upload time). Stamping with the
27 63 // file's modification time guarantees the URL changes whenever the
@@ -28,52 +64,184 @@
28 64 // file does, so "is my fix deployed?" is answerable from the
29 65 // network tab. Falls back to `$version` when the file is missing
30 66 // (test envs that import this file before the build runs).
31 67 $built_version = static function ( $relative ) use ( $version ) {
32 - $path = DESKTOP_MODE_DIR . $relative;
68 + $path = OPENSTATION_DIR . $relative;
33 69 return file_exists( $path ) ? (string) filemtime( $path ) : $version;
34 70 };
35 71
36 72 // Styles.
73 + // `filemtime`-stamped, NOT the plugin-wide `$version`. This file
74 + // is the token catalogue every other sheet resolves `var()`s
75 + // against, and it changes whenever the palette does — which is a
76 + // lot more often than the plugin version is bumped. With a static
77 + // stamp the browser holds the old palette until a hard reload,
78 + // and the symptom is maddening: a themed shell where some
79 + // surfaces update and others don't.
37 80 wp_register_style(
38 - 'desktop-mode-variables',
39 - DESKTOP_MODE_URL . 'assets/css/variables.css',
81 + 'os-variables',
82 + OPENSTATION_URL . 'assets/css/variables.css',
40 83 array(),
41 - $version
84 + $built_version( 'assets/css/variables.css' )
42 85 );
86 + // `filemtime`-stamped so the `<link rel="stylesheet">` URL matches the
87 + // `<link rel="preload" as="style">` hint emitted by
88 + // `openstation_print_preload_hints()` (which stamps with filemtime).
89 + // Registering this with the plain `$version` instead produced two
90 + // different `?ver=` query strings for the same file, so the browser
91 + // never matched the preload to the stylesheet and logged "preloaded
92 + // but not used within a few seconds from the window's load event".
43 93 wp_register_style(
44 - 'desktop-mode',
45 - DESKTOP_MODE_URL . 'assets/css/desktop.css',
46 - array( 'desktop-mode-variables' ),
47 - $version
94 + 'openstation',
95 + OPENSTATION_URL . 'assets/css/desktop.css',
96 + array( 'os-variables' ),
97 + $built_version( 'assets/css/desktop.css' )
48 98 );
49 - // `filemtime`-stamped — window-chrome iteration (drop overlays,
50 - // new drag affordances, third-party-plugin compat) lands faster
51 - // than plugin version bumps. Without an mtime stamp the browser
52 - // keeps `?ver=<plugin-version>` valid for the whole release cycle
53 - // and the user keeps seeing yesterday's CSS even after a hard
54 - // reload. Stamps the parent `windows.css` only; the @imports inside
55 - // (`window-chrome.css`, `window-states.css`, …) inherit the cache
56 - // directive from the parent fetch, so a busted `windows.css` busts
57 - // the whole subtree.
99 +
100 + /*
101 + * Window styles — one handle per sheet, chained by dependency.
102 + *
103 + * These used to be `@import url( … )`ed from `windows.css` under
104 + * the single `os-windows` handle. That was a standing
105 + * cache bug: an `@import` URL carries no `?ver=`, so a changed
106 + * sub-sheet had no URL for the browser to invalidate. Stamping the
107 + * PARENT with the subtree's max mtime (which is what
108 + * `openstation_css_subtree_version()` was for) made the browser
109 + * re-fetch `windows.css` and then request each sub-sheet at an
110 + * unchanged URL — free to be served from its heuristic cache. The
111 + * result was edits not landing until a hard refresh, and rules
112 + * being relocated into `windows.css` purely to dodge it.
113 + *
114 + * Now every sheet is separately registered with its own
115 + * `filemtime` stamp, so each has a real cache key.
116 + *
117 + * THE DEPENDENCY CHAIN IS LOAD-BEARING. WordPress prints
118 + * dependencies before dependents, so chaining each sheet to the
119 + * previous one reproduces the order the `@import` block had, and
120 + * `os-windows` (which depends on the last link) still
121 + * prints after them and still wins ties:
122 + *
123 + * window-chrome → window-states → effects → window-links
124 + * → windows
125 + *
126 + * `window-overview` is deliberately NOT in this chain — it is
127 + * registered below, after `os-windows`, so it can load deferred.
128 + * Adding a sheet here means splicing it into the chain, not
129 + * appending an unrelated dependency: order is the contract.
130 + * (The Preferences window's sheet is not here at all: it rides
131 + * the `apps/os-settings/` app as a first-open companion style.)
132 + */
133 + $window_sheets = array(
134 + 'os-window-chrome' => 'assets/css/window-chrome.css',
135 + 'os-window-states' => 'assets/css/window-states.css',
136 + 'os-effects' => 'assets/css/effects.css',
137 + 'os-window-links' => 'assets/css/window-links.css',
138 + );
139 + $previous = array( 'os-variables', 'dashicons' );
140 + foreach ( $window_sheets as $handle => $relative ) {
141 + wp_register_style(
142 + $handle,
143 + OPENSTATION_URL . $relative,
144 + $previous,
145 + $built_version( $relative )
146 + );
147 + $previous = array( $handle );
148 + }
149 +
150 + // Entry point. Depends on the tail of the chain above, so
151 + // enqueuing this one handle still pulls in every critical window
152 + // sheet — the behaviour callers had when they were `@import`s.
58 153 wp_register_style(
59 - 'desktop-mode-windows',
60 - DESKTOP_MODE_URL . 'assets/css/windows.css',
61 - array( 'desktop-mode-variables', 'dashicons' ),
154 + 'os-windows',
155 + OPENSTATION_URL . 'assets/css/windows.css',
156 + $previous,
62 157 $built_version( 'assets/css/windows.css' )
63 158 );
159 + // Loads DEFERRED (see `openstation_defer_non_critical_styles()`):
160 + // the UI it styles — the window overview — is lazy-loaded JS that
161 + // can never be on screen at first paint, so its CSS has no
162 + // business blocking render. It depends on `os-windows` so it
163 + // prints after it, preserving the cascade position it had as an
164 + // `@import`.
64 165 wp_register_style(
65 - 'desktop-mode-dock',
66 - DESKTOP_MODE_URL . 'assets/css/dock.css',
67 - array( 'desktop-mode-variables', 'dashicons' ),
68 - $version
166 + 'os-window-overview',
167 + OPENSTATION_URL . 'assets/css/window-overview.css',
168 + array( 'os-windows' ),
169 + $built_version( 'assets/css/window-overview.css' )
69 170 );
171 + // Solo mode — one window, no desk around it. Loads last so it can
172 + // hide surfaces the sheets above declared, and only enqueues on a
173 + // solo request, so a normal shell never pays for it.
70 174 wp_register_style(
71 - 'desktop-mode-dock-peek',
72 - DESKTOP_MODE_URL . 'assets/css/dock-peek.css',
73 - array( 'desktop-mode-dock' ),
74 - $version
175 + 'os-solo',
176 + OPENSTATION_URL . 'assets/css/solo.css',
177 + array( 'os-windows' ),
178 + $built_version( 'assets/css/solo.css' )
75 179 );
180 + wp_register_style(
181 + 'os-dock',
182 + OPENSTATION_URL . 'assets/css/dock.css',
183 + array( 'os-variables', 'dashicons' ),
184 + $built_version( 'assets/css/dock.css' )
185 + );
186 + wp_register_style(
187 + 'os-dock-peek',
188 + OPENSTATION_URL . 'assets/css/dock-peek.css',
189 + array( 'os-dock' ),
190 + $built_version( 'assets/css/dock-peek.css' )
191 + );
192 + // The phone layer. Every rule is scoped to
193 + // `html[data-os-mode="mobile"]`, so the sheet is inert on a
194 + // desktop and the first paint on a phone is already right (the
195 + // head stamp writes the attribute before any stylesheet applies).
196 + // Depends on the dock and window sheets because it overrides them.
197 + wp_register_style(
198 + 'os-mobile',
199 + OPENSTATION_URL . 'assets/css/mobile.css',
200 + array( 'os-variables', 'dashicons', 'os-dock', 'os-windows' ),
201 + $built_version( 'assets/css/mobile.css' )
202 + );
203 + // The notch — the shell's top-centre voice and the site
204 + // assistant's front door. Scoped to `.os-notch`.
205 + wp_register_style(
206 + 'os-notch',
207 + OPENSTATION_URL . 'assets/css/notch.css',
208 + array( 'os-variables' ),
209 + $built_version( 'assets/css/notch.css' )
210 + );
211 + // The workspace wizard. Scoped to `.os-workspace-wizard`, so it is
212 + // inert until the user opens it from the overview bar's `+` or a
213 + // tile's Edit. Those controls are styled with the rest of the bar
214 + // in `window-overview.css`.
215 + wp_register_style(
216 + 'os-workspaces',
217 + OPENSTATION_URL . 'assets/css/workspaces.css',
218 + array( 'os-variables', 'dashicons' ),
219 + $built_version( 'assets/css/workspaces.css' )
220 + );
221 + // Keyboard-shortcuts window. Scoped to `.os-shortcuts`, so it is
222 + // inert until the System menu opens the window, and unconditional
223 + // for the same reason the layout sheet is: the window can be
224 + // opened at any moment and a deferred sheet would paint it raw.
225 + wp_register_style(
226 + 'os-shortcuts',
227 + OPENSTATION_URL . 'assets/css/shortcuts.css',
228 + array( 'os-variables' ),
229 + $built_version( 'assets/css/shortcuts.css' )
230 + );
231 + // The OpenStation desktop layout — the core/plugin seam on the rail
232 + // plus the constellation hover-submenu flyout. Both surfaces are
233 + // scoped (`[data-os-layout="openstation"]` / `.os-constellation`),
234 + // so the sheet is inert in every other layout and is loaded
235 + // unconditionally rather than gated on the user's current pick:
236 + // the layout is switchable live from OpenStation Preferences, and a
237 + // conditional enqueue would leave the first switch unstyled.
238 + wp_register_style(
239 + 'os-openstation-layout',
240 + OPENSTATION_URL . 'assets/css/openstation-layout.css',
241 + array( 'os-dock' ),
242 + $built_version( 'assets/css/openstation-layout.css' )
243 + );
76 244 // `filemtime`-stamped — the chromeless overrides iterate faster
77 245 // than the plugin-wide version bumps (per-page compat shims and
78 246 // page-title-action exceptions land in patches), and a stale
79 247 // cached copy means the user sees yesterday's rules. Without the
@@ -79,79 +247,107 @@
79 247 // cached copy means the user sees yesterday's rules. Without the
80 248 // stamp, the browser keeps `?ver=0.8.1` valid for the whole
81 249 // release cycle.
82 250 wp_register_style(
83 - 'desktop-mode-chromeless',
84 - DESKTOP_MODE_URL . 'assets/css/chromeless.css',
85 - array( 'desktop-mode' ),
251 + 'os-chromeless',
252 + OPENSTATION_URL . 'assets/css/chromeless.css',
253 + array( 'openstation' ),
86 254 $built_version( 'assets/css/chromeless.css' )
87 255 );
88 256
257 + // `filemtime`-stamped — the AI assistant surface (error states,
258 + // inline affordances) iterates faster than plugin version bumps.
259 + // Without an mtime stamp the browser keeps `?ver=<plugin-version>`
260 + // valid for the whole release cycle and the user keeps seeing
261 + // yesterday's CSS even after a hard reload.
89 262 wp_register_style(
90 263 'desktop-mode-ai-assistant',
91 - DESKTOP_MODE_URL . 'assets/css/ai-assistant.css',
92 - array( 'desktop-mode-variables' ),
93 - $version
264 + OPENSTATION_URL . 'assets/css/ai-assistant.css',
265 + array( 'os-variables' ),
266 + $built_version( 'assets/css/ai-assistant.css' )
94 267 );
95 268
96 269 wp_register_style(
97 270 'desktop-mode-bug-report',
98 - DESKTOP_MODE_URL . 'assets/css/bug-report.css',
99 - array( 'desktop-mode-variables' ),
100 - $version
271 + OPENSTATION_URL . 'assets/css/bug-report.css',
272 + array( 'os-variables' ),
273 + $built_version( 'assets/css/bug-report.css' )
101 274 );
102 275
103 276 // `filemtime` instead of the plugin-wide `$version` for the
104 277 // recycle-bin CSS — this file iterates faster than the bundle
105 278 // and we never want a stale CSS cache to mask a real fix.
106 - $recycle_bin_css = DESKTOP_MODE_DIR . 'assets/css/recycle-bin.css';
279 + $recycle_bin_css = OPENSTATION_DIR . 'assets/css/recycle-bin.css';
107 280 wp_register_style(
108 281 'desktop-mode-recycle-bin',
109 - DESKTOP_MODE_URL . 'assets/css/recycle-bin.css',
110 - array( 'desktop-mode-variables', 'dashicons' ),
282 + OPENSTATION_URL . 'assets/css/recycle-bin.css',
283 + array( 'os-variables', 'dashicons' ),
111 284 file_exists( $recycle_bin_css ) ? (string) filemtime( $recycle_bin_css ) : $version
112 285 );
113 286
114 - // `filemtime` for the native Posts window CSS — same rationale as
115 - // the recycle-bin CSS: bundle iterates faster than the plugin
116 - // version and stale caches are worse than the cost of a 304.
117 - $posts_window_css = DESKTOP_MODE_DIR . 'assets/css/posts-window.css';
287 + // Files-on-the-Desktop tile + layer styles. `filemtime` for the
288 + // same reason as the recycle-bin CSS: this file
289 + // iterates faster than the plugin version, and a stale cache
290 + // would mask a real fix.
291 + $desktop_files_css = OPENSTATION_DIR . 'assets/css/desktop-files.css';
118 292 wp_register_style(
119 - 'desktop-mode-posts-window',
120 - DESKTOP_MODE_URL . 'assets/css/posts-window.css',
121 - array( 'desktop-mode-variables', 'dashicons' ),
122 - file_exists( $posts_window_css ) ? (string) filemtime( $posts_window_css ) : $version
293 + 'os-files',
294 + OPENSTATION_URL . 'assets/css/desktop-files.css',
295 + array( 'os-variables', 'dashicons' ),
296 + file_exists( $desktop_files_css ) ? (string) filemtime( $desktop_files_css ) : $version
123 297 );
124 298
125 - // Native Plugins window CSS — same `filemtime`-cache-bust posture
126 - // as the Posts/Recycle Bin styles.
127 - $plugins_window_css = DESKTOP_MODE_DIR . 'assets/css/plugins-window.css';
299 + // Games hub window (launcher grid, scoreboard, challenges) +
300 + // per-game styles. Same `filemtime` cache-bust posture as the
301 + // other fast-iterating feature stylesheets.
302 + $games_css = OPENSTATION_DIR . 'assets/css/games.css';
128 303 wp_register_style(
129 - 'desktop-mode-plugins-window',
130 - DESKTOP_MODE_URL . 'assets/css/plugins-window.css',
131 - array( 'desktop-mode-variables', 'dashicons' ),
132 - file_exists( $plugins_window_css ) ? (string) filemtime( $plugins_window_css ) : $version
304 + 'desktop-mode-games',
305 + OPENSTATION_URL . 'assets/css/games.css',
306 + array( 'os-variables', 'dashicons' ),
307 + file_exists( $games_css ) ? (string) filemtime( $games_css ) : $version
133 308 );
309 + $game_inkfall_css = OPENSTATION_DIR . 'assets/css/game-inkfall.css';
310 + wp_register_style(
311 + 'os-game-inkfall',
312 + OPENSTATION_URL . 'assets/css/game-inkfall.css',
313 + array( 'os-variables' ),
314 + file_exists( $game_inkfall_css ) ? (string) filemtime( $game_inkfall_css ) : $version
315 + );
316 + $game_alphabet_soup_css = OPENSTATION_DIR . 'assets/css/game-alphabet-soup.css';
317 + wp_register_style(
318 + 'os-game-alphabet-soup',
319 + OPENSTATION_URL . 'assets/css/game-alphabet-soup.css',
320 + array( 'os-variables' ),
321 + file_exists( $game_alphabet_soup_css ) ? (string) filemtime( $game_alphabet_soup_css ) : $version
322 + );
134 323
135 - // Native Comments window CSS — same `filemtime` posture.
136 - $comments_window_css = DESKTOP_MODE_DIR . 'assets/css/comments-window.css';
324 + // Pinned-notes layer styles (paper, pushpin, pastel tokens, pin
325 + // animations). Same `filemtime` cache-bust posture as the other
326 + // fast-iterating feature stylesheets above. Depends on `os-files`
327 + // because a pinned note dresses the canonical `.os-file-tile`
328 + // chrome — anything that restyles a tile has to print after the
329 + // file that declares one.
330 + $notes_css = OPENSTATION_DIR . 'assets/css/notes.css';
137 331 wp_register_style(
138 - 'desktop-mode-comments-window',
139 - DESKTOP_MODE_URL . 'assets/css/comments-window.css',
140 - array( 'desktop-mode-variables', 'dashicons' ),
141 - file_exists( $comments_window_css ) ? (string) filemtime( $comments_window_css ) : $version
332 + 'os-notes',
333 + OPENSTATION_URL . 'assets/css/notes.css',
334 + array( 'os-variables', 'dashicons', 'os-files' ),
335 + file_exists( $notes_css ) ? (string) filemtime( $notes_css ) : $version
142 336 );
143 337
144 - // Files-on-the-Desktop tile + layer styles. `filemtime` for the
145 - // same reason as the recycle-bin / posts-window CSS: this file
146 - // iterates faster than the plugin version, and a stale cache
147 - // would mask a real fix.
148 - $desktop_files_css = DESKTOP_MODE_DIR . 'assets/css/desktop-files.css';
338 + // Announcement-dialog styles (scrim, hero card, buttons). Registered
339 + // always, enqueued only for a user who is actually owed the
340 + // announcement — see the gate in `openstation_enqueue_assets()`. It
341 + // is not lazy-loaded on top of that: on the one boot where it does
342 + // go out, the dialog opens from the main bundle a second later, and
343 + // a fetch racing that would show an unstyled card.
344 + $announce_css = OPENSTATION_DIR . 'assets/css/announce.css';
149 345 wp_register_style(
150 - 'desktop-mode-files',
151 - DESKTOP_MODE_URL . 'assets/css/desktop-files.css',
152 - array( 'desktop-mode-variables', 'dashicons' ),
153 - file_exists( $desktop_files_css ) ? (string) filemtime( $desktop_files_css ) : $version
346 + 'os-announce',
347 + OPENSTATION_URL . 'assets/css/announce.css',
348 + array( 'os-variables' ),
349 + file_exists( $announce_css ) ? (string) filemtime( $announce_css ) : $version
154 350 );
155 351
156 352 // Scripts.
157 353 //
@@ -162,10 +358,10 @@
162 358 // lookups. Both handles are core-shipped but only pre-enqueued
163 359 // when Gutenberg-adjacent deps pull them in, so we list them
164 360 // explicitly to guarantee load order.
165 361 wp_register_script(
166 - 'desktop-mode',
167 - DESKTOP_MODE_URL . 'assets/js/desktop' . $suffix . '.js',
362 + 'openstation',
363 + OPENSTATION_URL . 'assets/js/desktop' . $suffix . '.js',
168 364 // `heartbeat` + `jquery` — the recycle-bin badge module
169 365 // (loaded as part of this bundle) opts into the WordPress
170 366 // Heartbeat API so the count tile / desktop-icon badge
171 367 // stays in sync even when the bin window is closed.
@@ -170,13 +366,24 @@
170 366 // Heartbeat API so the count tile / desktop-icon badge
171 367 // stays in sync even when the bin window is closed.
172 368 array( 'wp-hooks', 'wp-i18n', 'heartbeat', 'jquery' ),
173 369 $built_version( 'assets/js/desktop' . $suffix . '.js' ),
174 - true
370 + // Footer + defer: the shell boots on DOMContentLoaded anyway,
371 + // so deferring frees the parser instead of blocking at the
372 + // footer print point. Both inline payloads attached to this
373 + // handle (`__openStationMenuCommands`, the jazz-quote version
374 + // stamp) are `'before'`-position, which WP keeps as blocking
375 + // inline ahead of a deferred tag — order is preserved. On WP
376 + // < 6.3 the array collapses to a truthy `$in_footer`, same as
377 + // before.
378 + array(
379 + 'in_footer' => true,
380 + 'strategy' => 'defer',
381 + )
175 382 );
176 383
177 - // `desktop-mode-iframe-bridge` — opt-in iframe-side bridge that
178 - // provides `wp.desktop.iframe.publish/subscribe/onConnection/
384 + // `os-iframe-bridge` — opt-in iframe-side bridge that
385 + // provides `wp.os.iframe.publish/subscribe/onConnection/
179 386 // requestConnection` to any same-origin iframe that enqueues it.
180 387 // Same code is also injected inline by the chromeless bridge
181 388 // (so chromeless wp-admin pages don't need a separate enqueue)
182 389 // and auto-injected when a native window opts in via
@@ -182,19 +389,60 @@
182 389 // and auto-injected when a native window opts in via
183 390 // `iframeContent: { bridge: true }`. Plugins targeting their
184 391 // own iframe pages just enqueue this handle.
185 392 wp_register_script(
186 - 'desktop-mode-iframe-bridge',
187 - DESKTOP_MODE_URL . 'assets/js/iframe-bridge' . $suffix . '.js',
393 + 'os-iframe-bridge',
394 + OPENSTATION_URL . 'assets/js/iframe-bridge' . $suffix . '.js',
188 395 array(),
189 396 $built_version( 'assets/js/iframe-bridge' . $suffix . '.js' ),
190 397 true
191 398 );
192 399
193 - // `desktop-mode-gutenberg-drop-receiver` — iframe-side bundle
400 + // `os-deactivation-feedback` — the dialog that asks one optional
401 + // question when an admin deactivates OpenStation. Enqueued on
402 + // `plugins.php` (classic, chromeless and network admin) by
403 + // `includes/feedback/deactivation.php`, and lazy-loaded by the
404 + // native Plugins app from its config block. Plain DOM on purpose:
405 + // the classic screen has no `<os-*>` kit.
406 + wp_register_script(
407 + 'os-deactivation-feedback',
408 + OPENSTATION_URL . 'assets/js/deactivation-feedback' . $suffix . '.js',
409 + array( 'wp-i18n' ),
410 + $built_version( 'assets/js/deactivation-feedback' . $suffix . '.js' ),
411 + true
412 + );
413 + wp_set_script_translations(
414 + 'os-deactivation-feedback',
415 + 'desktop-mode',
416 + OPENSTATION_DIR . 'languages'
417 + );
418 + $feedback_css = OPENSTATION_DIR . 'assets/css/deactivation-feedback.css';
419 + wp_register_style(
420 + 'os-deactivation-feedback',
421 + OPENSTATION_URL . 'assets/css/deactivation-feedback.css',
422 + array(),
423 + file_exists( $feedback_css ) ? (string) filemtime( $feedback_css ) : $version
424 + );
425 +
426 + // `os-chromeless-bridge` — the iframe side of every window,
427 + // enqueued on `admin_footer` by
428 + // `openstation_chromeless_bridge_script()` with its per-request
429 + // data attached as a `before` inline block. Registered here (not
430 + // there) so the handle exists before the enqueue and so the asset
431 + // guard's OPENSTATION_URL snapshot protects it like every other
432 + // bundle of ours.
433 + wp_register_script(
434 + 'os-chromeless-bridge',
435 + OPENSTATION_URL . 'assets/js/chromeless-bridge' . $suffix . '.js',
436 + array(),
437 + $built_version( 'assets/js/chromeless-bridge' . $suffix . '.js' ),
438 + true
439 + );
440 +
441 + // `os-gutenberg-drop-receiver` — iframe-side bundle
194 442 // enqueued only on the Block Editor screens (`post.php` /
195 - // `post-new.php`) for desktop-mode users. Listens for
196 - // `desktop-mode-drop` postMessages from the parent shell (see
443 + // `post-new.php`) for openstation users. Listens for
444 + // `os-drop` postMessages from the parent shell (see
197 445 // `src/drag/iframe-drop-targets.ts`) and inserts the matching
198 446 // Gutenberg block via `wp.data.dispatch('core/block-editor')`.
199 447 // Depends on `wp-blocks` + `wp-data` so the editor stores are
200 448 // guaranteed enqueued before the receiver runs its first message
@@ -199,120 +447,124 @@
199 447 // Depends on `wp-blocks` + `wp-data` so the editor stores are
200 448 // guaranteed enqueued before the receiver runs its first message
201 449 // handler.
202 450 wp_register_script(
203 - 'desktop-mode-gutenberg-drop-receiver',
204 - DESKTOP_MODE_URL . 'assets/js/gutenberg-drop-receiver' . $suffix . '.js',
451 + 'os-gutenberg-drop-receiver',
452 + OPENSTATION_URL . 'assets/js/gutenberg-drop-receiver' . $suffix . '.js',
205 453 array( 'wp-blocks', 'wp-data' ),
206 454 $built_version( 'assets/js/gutenberg-drop-receiver' . $suffix . '.js' ),
207 455 true
208 456 );
209 457
210 - // `desktop-mode-recycle-bin` — small bundle for the Recycle Bin
211 - // native window. Lazy-loaded by the native-window sync the first
212 - // time the bin opens; registers a render callback on
213 - // `window.desktopModeNativeWindows['desktop-mode-recycle-bin']`.
214 - $recycle_bin_js = DESKTOP_MODE_DIR . 'assets/js/recycle-bin' . $suffix . '.js';
458 + // The Recycle Bin window is an App Framework app (`apps/trash/`);
459 + // its client view rides the app-bundle pipeline, so no dedicated
460 + // script handle. The `desktop-mode-recycle-bin` STYLE handle above
461 + // stays — the drag-to-trash drop-target highlight must be present
462 + // at boot (dropping on the closed bin's dock tile), not window-open.
463 +
464 + // `desktop-mode-games` — bundle for the Games hub native window
465 + // (launcher grid, scoreboard, challenges client). Lazy-loaded by
466 + // the native-window sync the first time the hub opens; registers a
467 + // render callback on
468 + // `window.openStationNativeWindows['desktop-mode-games']`.
469 + // `heartbeat` + `jquery` — the challenges client rides the
470 + // WordPress Heartbeat bus for live delivery.
471 + $games_js = OPENSTATION_DIR . 'assets/js/games' . $suffix . '.js';
215 472 wp_register_script(
216 - 'desktop-mode-recycle-bin',
217 - DESKTOP_MODE_URL . 'assets/js/recycle-bin' . $suffix . '.js',
218 - // `heartbeat` + `jquery` — the bin opts in to the WordPress
219 - // Heartbeat API while its window is open as the catch-all
220 - // real-time channel for deletes that don't render an admin
221 - // footer (REST/AJAX/other tabs/WP-CLI). See
222 - // `src/recycle-bin/realtime.ts` for the subscriber.
473 + 'desktop-mode-games',
474 + OPENSTATION_URL . 'assets/js/games' . $suffix . '.js',
223 475 array( 'wp-i18n', 'heartbeat', 'jquery' ),
224 - file_exists( $recycle_bin_js ) ? (string) filemtime( $recycle_bin_js ) : $version,
476 + file_exists( $games_js ) ? (string) filemtime( $games_js ) : $version,
225 477 true
226 478 );
227 479 wp_set_script_translations(
228 - 'desktop-mode-recycle-bin',
480 + 'desktop-mode-games',
229 481 'desktop-mode',
230 - DESKTOP_MODE_DIR . 'languages'
482 + OPENSTATION_DIR . 'languages'
231 483 );
232 484
233 - // `desktop-mode-posts-window` — small bundle for the native Posts
234 - // window. Lazy-loaded by the native-window sync the first time the
235 - // window opens (via the dock-click swap when the user opts in);
236 - // registers a render callback on
237 - // `window.desktopModeNativeWindows['desktop-mode-posts']`.
238 - $posts_window_js = DESKTOP_MODE_DIR . 'assets/js/posts-window' . $suffix . '.js';
485 + // `os-game-inkfall` — the Inkfall game bundle. Loaded
486 + // lazily by the games framework on first launch; publishes the
487 + // game def on `window.openStationGames.inkfall`.
488 + $game_inkfall_js = OPENSTATION_DIR . 'assets/js/game-inkfall' . $suffix . '.js';
239 489 wp_register_script(
240 - 'desktop-mode-posts-window',
241 - DESKTOP_MODE_URL . 'assets/js/posts-window' . $suffix . '.js',
490 + 'os-game-inkfall',
491 + OPENSTATION_URL . 'assets/js/game-inkfall' . $suffix . '.js',
242 492 array( 'wp-i18n' ),
243 - file_exists( $posts_window_js ) ? (string) filemtime( $posts_window_js ) : $version,
493 + file_exists( $game_inkfall_js ) ? (string) filemtime( $game_inkfall_js ) : $version,
244 494 true
245 495 );
246 496 wp_set_script_translations(
247 - 'desktop-mode-posts-window',
497 + 'os-game-inkfall',
248 498 'desktop-mode',
249 - DESKTOP_MODE_DIR . 'languages'
499 + OPENSTATION_DIR . 'languages'
250 500 );
251 501
252 - // `desktop-mode-plugins-window` — small bundle for the native
253 - // Plugins window. Lazy-loaded by the native-window sync the first
254 - // time the window opens (via the dock-click swap when the user
255 - // opts in); registers a render callback on
256 - // `window.desktopModeNativeWindows['desktop-mode-plugins']`.
257 - $plugins_window_js = DESKTOP_MODE_DIR . 'assets/js/plugins-window' . $suffix . '.js';
502 + // `os-game-alphabet-soup` — the Alphabet Soup game
503 + // bundle. Loaded lazily by the games framework on first launch;
504 + // publishes the game def on
505 + // `window.openStationGames['alphabet-soup']`.
506 + $game_alphabet_soup_js = OPENSTATION_DIR . 'assets/js/game-alphabet-soup' . $suffix . '.js';
258 507 wp_register_script(
259 - 'desktop-mode-plugins-window',
260 - DESKTOP_MODE_URL . 'assets/js/plugins-window' . $suffix . '.js',
508 + 'os-game-alphabet-soup',
509 + OPENSTATION_URL . 'assets/js/game-alphabet-soup' . $suffix . '.js',
261 510 array( 'wp-i18n' ),
262 - file_exists( $plugins_window_js ) ? (string) filemtime( $plugins_window_js ) : $version,
511 + file_exists( $game_alphabet_soup_js ) ? (string) filemtime( $game_alphabet_soup_js ) : $version,
263 512 true
264 513 );
265 514 wp_set_script_translations(
266 - 'desktop-mode-plugins-window',
515 + 'os-game-alphabet-soup',
267 516 'desktop-mode',
268 - DESKTOP_MODE_DIR . 'languages'
517 + OPENSTATION_DIR . 'languages'
269 518 );
270 519
271 - // `desktop-mode-comments-window` — small bundle for the native
272 - // Comments window. Lazy-loaded by the native-window sync the first
273 - // time the window opens (via the dock-click swap when the user
274 - // opts in); registers a render callback on
275 - // `window.desktopModeNativeWindows['desktop-mode-comments']`.
276 - $comments_window_js = DESKTOP_MODE_DIR . 'assets/js/comments-window' . $suffix . '.js';
277 - wp_register_script(
278 - 'desktop-mode-comments-window',
279 - DESKTOP_MODE_URL . 'assets/js/comments-window' . $suffix . '.js',
280 - array( 'wp-i18n' ),
281 - file_exists( $comments_window_js ) ? (string) filemtime( $comments_window_js ) : $version,
282 - true
283 - );
284 - wp_set_script_translations(
285 - 'desktop-mode-comments-window',
286 - 'desktop-mode',
287 - DESKTOP_MODE_DIR . 'languages'
288 - );
289 -
290 - // `desktop-mode-animated-logo-wallpaper` — built-in PixiJS canvas
291 - // wallpaper, moved out of `desktop.min.js` in 0.8.4. The wallpaper
520 + // `os-animated-logo-wallpaper` — built-in PixiJS canvas
521 + // wallpaper, moved out of `desktop.min.js`. The wallpaper
292 522 // `server-sync` loads this handle when the user selects the
293 523 // `wp-animated-logo` wallpaper (or opens OS Settings → Wallpaper
294 524 // and the picker pulls every registered canvas def in). The
295 525 // bundle's only side effect is publishing the `WallpaperDef` on
296 - // `window.desktopModeWallpapers['wp-animated-logo']`.
297 - $animated_logo_js = DESKTOP_MODE_DIR . 'assets/js/animated-logo-wallpaper' . $suffix . '.js';
526 + // `window.openStationWallpapers['wp-animated-logo']`.
527 + $animated_logo_js = OPENSTATION_DIR . 'assets/js/animated-logo-wallpaper' . $suffix . '.js';
298 528 wp_register_script(
299 - 'desktop-mode-animated-logo-wallpaper',
300 - DESKTOP_MODE_URL . 'assets/js/animated-logo-wallpaper' . $suffix . '.js',
529 + 'os-animated-logo-wallpaper',
530 + OPENSTATION_URL . 'assets/js/animated-logo-wallpaper' . $suffix . '.js',
301 531 array( 'wp-hooks' ),
302 532 file_exists( $animated_logo_js ) ? (string) filemtime( $animated_logo_js ) : $version,
303 533 true
304 534 );
305 535
536 + // `os-snow-wallpaper` — built-in PixiJS canvas
537 + // wallpaper: snowfall that accumulates on window tops and melts
538 + // away. Same lazy-load path as the animated logo: the wallpaper
539 + // `server-sync` injects this handle when the user selects the
540 + // `wp-snow` wallpaper (or opens OS Settings → Wallpaper and the
541 + // picker pulls the def in). The bundle's only side effect is
542 + // publishing the `WallpaperDef` on
543 + // `window.openStationWallpapers['wp-snow']`.
544 + $snow_js = OPENSTATION_DIR . 'assets/js/snow-wallpaper' . $suffix . '.js';
545 + wp_register_script(
546 + 'os-snow-wallpaper',
547 + OPENSTATION_URL . 'assets/js/snow-wallpaper' . $suffix . '.js',
548 + array( 'wp-hooks', 'wp-i18n' ),
549 + file_exists( $snow_js ) ? (string) filemtime( $snow_js ) : $version,
550 + true
551 + );
552 + wp_set_script_translations(
553 + 'os-snow-wallpaper',
554 + 'desktop-mode',
555 + OPENSTATION_DIR . 'languages'
556 + );
557 +
306 558 // `desktop-mode-ai-assistant` — AI Copilot spotlight overlay,
307 - // moved out of `desktop.min.js` in 0.8.4. The main bundle ships a
308 - // stub matching the public `wp.desktop.ai` contract; the stub
559 + // moved out of `desktop.min.js`. The main bundle ships a
560 + // stub matching the public `wp.os.ai` contract; the stub
309 561 // `<script>`-injects this handle the first time the user opens
310 562 // the assistant (Cmd+K or admin-bar button).
311 - $ai_assistant_js = DESKTOP_MODE_DIR . 'assets/js/ai-assistant' . $suffix . '.js';
563 + $ai_assistant_js = OPENSTATION_DIR . 'assets/js/ai-assistant' . $suffix . '.js';
312 564 wp_register_script(
313 565 'desktop-mode-ai-assistant',
314 - DESKTOP_MODE_URL . 'assets/js/ai-assistant' . $suffix . '.js',
566 + OPENSTATION_URL . 'assets/js/ai-assistant' . $suffix . '.js',
315 567 array( 'wp-hooks', 'wp-i18n' ),
316 568 file_exists( $ai_assistant_js ) ? (string) filemtime( $ai_assistant_js ) : $version,
317 569 true
318 570 );
@@ -318,19 +570,19 @@
318 570 );
319 571 wp_set_script_translations(
320 572 'desktop-mode-ai-assistant',
321 573 'desktop-mode',
322 - DESKTOP_MODE_DIR . 'languages'
574 + OPENSTATION_DIR . 'languages'
323 575 );
324 576
325 577 // Wire the translation bundle to this script handle. WP looks
326 - // for `languages/desktop-mode-{locale}-desktop-mode.json` and
578 + // for `languages/os-{locale}-os.json` and
327 579 // injects its `locale_data` into `wp.i18n` just before the
328 580 // script runs — so every `__()` call resolves to the right
329 581 // language without any runtime fetch.
330 582 wp_set_script_translations(
583 + 'openstation',
331 584 'desktop-mode',
332 - 'desktop-mode',
333 - DESKTOP_MODE_DIR . 'languages'
585 + OPENSTATION_DIR . 'languages'
334 586 );
335 587 }
336 -add_action( 'init', 'desktop_mode_register_assets' );
588 +add_action( 'init', 'openstation_register_assets' );