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/registries/widgets.php +27 -19 1.0.01.1.10 View file →
@@ -216,8 +216,15 @@
216 216 'maxHeight' => $entry['max_height'],
217 217 'defaultWidth' => $entry['default_width'],
218 218 'defaultHeight' => $entry['default_height'],
219 219 'scriptUrl' => $script_payload['url'],
220 + // The packages this widget declares, in load order.
221 + // WordPress resolves a script's dependencies when it
222 + // enqueues it; a widget bundle is delivered lazily and
223 + // never goes through that, so a widget declaring
224 + // `wp-api-fetch` found `wp.apiFetch` undefined at mount.
225 + // See docs/migration-wp-package-globals.md.
226 + 'scriptDeps' => openstation_resolve_script_dependencies( $entry['script'] ),
220 227 'scriptHandle' => $entry['script'],
221 228 'scriptBefore' => $script_payload['before'],
222 229 'scriptAfter' => $script_payload['after'],
223 230 'scriptL10n' => $script_payload['l10n'],
@@ -226,24 +233,25 @@
226 233 }
227 234 return $out;
228 235 }
229 236
230 -/**
231 - * Enqueue plugin-registered widget scripts on the shell page so
232 - * widgets active at boot time have their mount callbacks
233 - * available without any dynamic-load roundtrip.
237 +/*
238 + * Widget scripts are NOT enqueued here, and that is deliberate.
239 + *
240 + * Everything the widget picker shows — label, description, icon,
241 + * size constraints — is metadata declared right here in PHP and
242 + * shipped in the boot payload. The only thing a plugin's bundle
243 + * contributes is the `mount` callback, so the shell assembles the
244 + * whole def from the payload and loads the script the first time
245 + * the widget is actually mounted.
246 + *
247 + * A widget the user has never enabled therefore costs a row in the
248 + * picker and nothing else. This file used to `wp_enqueue_script()`
249 + * every registered one on every admin page, which meant the nine
250 + * built-in widget bundles — Drafts at 46 KB, Focus Timer at 41 KB,
251 + * Notes at 31 KB, and the rest — were downloaded and parsed by
252 + * every user whether or not a single widget was on their desktop.
253 + *
254 + * See `src/widgets/server-sync.ts`. `scriptUrl` in the payload
255 + * (built above) is what makes that possible; nothing else on the
256 + * PHP side is involved.
234 257 */
235 -function openstation_enqueue_desktop_widget_scripts() {
236 - if ( ! openstation_is_enabled() || openstation_is_chromeless_request() || openstation_is_classic_request() ) {
237 - return;
238 - }
239 - $registry = openstation_desktop_widget_registry();
240 - if ( ! is_array( $registry ) ) {
241 - return;
242 - }
243 - foreach ( $registry as $entry ) {
244 - if ( ! empty( $entry['script'] ) ) {
245 - wp_enqueue_script( $entry['script'] );
246 - }
247 - }
248 -}
249 -add_action( 'admin_enqueue_scripts', 'openstation_enqueue_desktop_widget_scripts', 20 );