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 +37 -0 1.1.6 → 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
@@ -1092,4 +1112,21 @@
1092 1112 echo '</template>';
1093 1113 }
1094 1114 }
1095 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 +}