PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 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 All 36 releases
← All changes | includes/registries/wallpapers.php +33 -19 1.1.0 → 1.1.12 View file →
@@ -77,8 +77,15 @@
77 77 * Settings when the wallpaper is the
78 78 * active selection — what it is, where
79 79 * its data comes from, the story behind
80 80 * it. Optional.
81 + * @type string $tone 'light' | 'dark'. Whether the desk
82 + * paints its icons and labels in
83 + * Starlight or in Void. Optional;
84 + * unset reads as 'dark'. Declare
85 + * 'light' if a user would call your
86 + * surface pale. See
87 + * docs/desktop-themes.md.
81 88 * @type string[] $capabilities Gate: ALL caps must match. Any
82 89 * missed cap returns
83 90 * `WP_Error openstation_capability_denied`.
84 91 * }
@@ -99,8 +106,9 @@
99 106 'type' => 'canvas',
100 107 'value' => '',
101 108 'script' => '',
102 109 'description' => '',
110 + 'tone' => '',
103 111 'capabilities' => array(),
104 112 );
105 113 $args = wp_parse_args( $args, $defaults );
106 114
@@ -170,8 +178,11 @@
170 178 'script' => (string) $args['script'],
171 179 // Plain text by contract — the shell renders it as text, never
172 180 // as HTML, so strip tags here rather than trusting every caller.
173 181 'description' => sanitize_textarea_field( (string) $args['description'] ),
182 + // Anything else stores empty and reads as 'dark', so a typo
183 + // lands on the old look rather than on invisible icons.
184 + 'tone' => in_array( $args['tone'], array( 'light', 'dark' ), true ) ? (string) $args['tone'] : '',
174 185 );
175 186 openstation_desktop_wallpaper_registry( $id, $entry );
176 187
177 188 /**
@@ -244,8 +255,9 @@
244 255 'preview' => isset( $entry['preview'] ) ? (string) $entry['preview'] : '',
245 256 'type' => isset( $entry['type'] ) ? (string) $entry['type'] : 'canvas',
246 257 'value' => isset( $entry['value'] ) ? (string) $entry['value'] : '',
247 258 'description' => isset( $entry['description'] ) ? (string) $entry['description'] : '',
259 + 'tone' => isset( $entry['tone'] ) ? (string) $entry['tone'] : '',
248 260 'scriptUrl' => $payload['url'],
249 261 'scriptHandle' => $handle,
250 262 'scriptBefore' => $payload['before'],
251 263 'scriptAfter' => $payload['after'],
@@ -250,8 +262,11 @@
250 262 'scriptBefore' => $payload['before'],
251 263 'scriptAfter' => $payload['after'],
252 264 'scriptL10n' => $payload['l10n'],
253 265 'scriptTranslations' => $payload['translations'],
266 + // The handle's dependency closure, replayed before the bundle
267 + // on its lazy load — see `openstation_resolve_script_dependencies()`.
268 + 'scriptDeps' => openstation_resolve_script_dependencies( $handle ),
254 269 );
255 270 }
256 271 return $out;
257 272 }
@@ -256,24 +271,23 @@
256 271 return $out;
257 272 }
258 273
259 274
260 -/**
261 - * Enqueue plugin-registered wallpaper scripts on the shell page
262 - * so wallpapers active at boot time have their defs available
263 - * without any dynamic-load roundtrip.
275 +/*
276 + * Wallpaper scripts are NOT enqueued here, and that is deliberate.
277 + *
278 + * A canvas wallpaper's bundle IS the wallpaper — Living Tree is 58 KB
279 + * of PixiJS scene, Snow is 42 KB — and this file used to
280 + * `wp_enqueue_script()` every registered one on every admin page, so
281 + * that every user downloaded and parsed every wallpaper in the
282 + * install including the ones they were not wearing. The metadata in
283 + * the boot payload (label, preview swatch, description) is enough for
284 + * the shell to register a stub and paint a picker tile without any of
285 + * it.
286 + *
287 + * The bundle arrives when something needs the callbacks: the shell
288 + * hydrates the user's ACTIVE wallpaper during the boot sync, and the
289 + * wallpaper picker hydrates the rest when it opens. See
290 + * `src/wallpapers/lazy.ts`. `scriptUrl` in the payload (built above)
291 + * is what makes that possible; nothing else on the PHP side is
292 + * involved.
264 293 */
265 -function openstation_enqueue_desktop_wallpaper_scripts() {
266 - if ( ! openstation_is_enabled() || openstation_is_chromeless_request() || openstation_is_classic_request() ) {
267 - return;
268 - }
269 - $registry = openstation_desktop_wallpaper_registry();
270 - if ( ! is_array( $registry ) ) {
271 - return;
272 - }
273 - foreach ( $registry as $entry ) {
274 - if ( ! empty( $entry['script'] ) ) {
275 - wp_enqueue_script( $entry['script'] );
276 - }
277 - }
278 -}
279 -add_action( 'admin_enqueue_scripts', 'openstation_enqueue_desktop_wallpaper_scripts', 20 );