PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.11
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.11
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 0.8.8 All 35 releases
← All changes | includes/registries/native-windows.php +41 -2 1.1.3 → 1.1.11 View file →
@@ -148,8 +148,15 @@
148 148 * A PROPOSED default only: the user's
149 149 * OpenStation Preferences → Navigation
150 150 * pick wins, and so does a right-click
151 151 * "Keep in dock".
152 + * @type string $admin 'site' | 'network' | 'any'. Default
153 + * 'site': offered on every site's
154 + * shell and never on the network
155 + * admin's, which is right for a window
156 + * that reads the current site's REST
157 + * API. 'network' is the network
158 + * admin's shell only; 'any' is both.
152 159 * @type string $nav_kind 'app' | 'control'. Default 'app'.
153 160 * What the window IS, which decides
154 161 * where its launcher defaults to (apps
155 162 * to the desktop, controls to the
@@ -247,8 +254,9 @@
247 254 'height' => 400,
248 255 'min_width' => 280,
249 256 'min_height' => 220,
250 257 'placement' => 'dock',
258 + 'admin' => 'site',
251 259 'nav_kind' => 'app',
252 260 'dock_order' => 0,
253 261 'placeable' => false,
254 262 'capabilities' => array(),
@@ -254,11 +262,17 @@
254 262 'capabilities' => array(),
255 263 'autofocus' => false,
256 264 'main_tab_label' => '',
257 265 'main_tab_padding' => '',
266 + // Admin pages this window answers for, `array( id, page )` per
267 + // entry. See `App::menu()` and `openstation_apps_menu_pages()`.
268 + 'menu_pages' => array(),
258 269 'config' => array(),
259 270 );
260 271 $args = wp_parse_args( $args, $defaults );
272 + if ( ! in_array( $args['admin'], array( 'site', 'network', 'any' ), true ) ) {
273 + $args['admin'] = 'site';
274 + }
261 275
262 276 // Capability gate — ALL listed caps must match. Fail closed.
263 277 foreach ( (array) $args['capabilities'] as $cap ) {
264 278 if ( ! current_user_can( (string) $cap ) ) {
@@ -342,8 +356,10 @@
342 356 'min_width' => (int) $args['min_width'],
343 357 'min_height' => (int) $args['min_height'],
344 358 'placement' => $placement,
345 359 'nav_kind' => $nav_kind,
360 + // Which admin's shell offers it; see the `admin` arg.
361 + 'admin' => $args['admin'],
346 362 // Sort key among system tiles, ascending. `0` (the default)
347 363 // puts a plugin's tile ahead of the shell's own trailing
348 364 // cluster — Mio 10, Overview 20, System 30 — which is where a
349 365 // launcher belongs. Trash uses 40 to sit at the very end.
@@ -357,8 +373,12 @@
357 373 // Bundle-bound config delivered through the same path as
358 374 // `wp_localize_script` `extra['data']` — see the `config` doc
359 375 // in this function's `$args` block and `openstation_resolve_script_payload()`
360 376 // for how it lands on the wire.
377 + // Admin pages this window answers for, `array( id, page )` per
378 + // entry — dropped here once, which is why the shell saw an
379 + // empty list and claimed none of them.
380 + 'menu_pages' => is_array( $args['menu_pages'] ) ? array_values( $args['menu_pages'] ) : array(),
361 381 'config' => is_array( $args['config'] ) ? $args['config'] : array(),
362 382 );
363 383 openstation_native_window_registry( $id, $entry );
364 384
@@ -517,8 +537,9 @@
517 537 'bordered' => true,
518 538 'compact' => true,
519 539 'loading' => true,
520 540 'loading-rows' => true,
541 + 'empty' => true,
521 542 'columns' => true,
522 543 'rows' => true,
523 544 'sortable' => true,
524 545 'expandable' => true,
@@ -523,8 +544,9 @@
523 544 'sortable' => true,
524 545 'expandable' => true,
525 546 'preset' => true,
526 547 'label' => true,
548 + 'heading' => true,
527 549 'description' => true,
528 550 'orientation' => true,
529 551 'level' => true,
530 552 'collapsed' => true,
@@ -962,9 +984,9 @@
962 984 * builds that payload at 10, and data attached after it would ship a
963 985 * bundle with no config.
964 986 */
965 987 function openstation_enqueue_native_window_scripts() {
966 - if ( ! openstation_is_enabled() || openstation_is_chromeless_request() || openstation_is_classic_request() ) {
988 + if ( ! openstation_is_shell_request() ) {
967 989 return;
968 990 }
969 991 $registry = openstation_native_window_registry();
970 992 if ( ! is_array( $registry ) ) {
@@ -1062,9 +1084,9 @@
1062 1084 * these via `document.getElementById( `os-native-window-${id}` )`
1063 1085 * and clones them into each opened window's body.
1064 1086 */
1065 1087 function openstation_render_native_window_templates() {
1066 - if ( ! openstation_is_enabled() || openstation_is_chromeless_request() || openstation_is_classic_request() ) {
1088 + if ( ! openstation_is_shell_request() ) {
1067 1089 return;
1068 1090 }
1069 1091 $registry = openstation_native_window_registry();
1070 1092 if ( ! is_array( $registry ) ) {
@@ -1090,4 +1112,21 @@
1090 1112 echo '</template>';
1091 1113 }
1092 1114 }
1093 1115 add_action( 'admin_footer', 'openstation_render_native_window_templates', 20 );
1116 +
1117 +/**
1118 + * Whether a registered window is offered on the admin this request is
1119 + * in: the network admin's shell offers `network` and `any` windows,
1120 + * every site's shell offers `site` and `any`. See the `admin` arg of
1121 + * {@see openstation_register_window()}.
1122 + *
1123 + * @param array<string,mixed> $entry Registry entry.
1124 + * @return bool
1125 + */
1126 +function openstation_native_window_offered_here( $entry ) {
1127 + $admin = isset( $entry['admin'] ) ? (string) $entry['admin'] : 'site';
1128 + if ( 'any' === $admin ) {
1129 + return true;
1130 + }
1131 + return is_network_admin() ? 'network' === $admin : 'site' === $admin;
1132 +}