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/native-windows.php +32 -2 1.1.41.1.10 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(),
@@ -257,8 +265,11 @@
257 265 'main_tab_padding' => '',
258 266 'config' => array(),
259 267 );
260 268 $args = wp_parse_args( $args, $defaults );
269 + if ( ! in_array( $args['admin'], array( 'site', 'network', 'any' ), true ) ) {
270 + $args['admin'] = 'site';
271 + }
261 272
262 273 // Capability gate — ALL listed caps must match. Fail closed.
263 274 foreach ( (array) $args['capabilities'] as $cap ) {
264 275 if ( ! current_user_can( (string) $cap ) ) {
@@ -342,8 +353,10 @@
342 353 'min_width' => (int) $args['min_width'],
343 354 'min_height' => (int) $args['min_height'],
344 355 'placement' => $placement,
345 356 'nav_kind' => $nav_kind,
357 + // Which admin's shell offers it; see the `admin` arg.
358 + 'admin' => $args['admin'],
346 359 // Sort key among system tiles, ascending. `0` (the default)
347 360 // puts a plugin's tile ahead of the shell's own trailing
348 361 // cluster — Mio 10, Overview 20, System 30 — which is where a
349 362 // launcher belongs. Trash uses 40 to sit at the very end.
@@ -964,9 +977,9 @@
964 977 * builds that payload at 10, and data attached after it would ship a
965 978 * bundle with no config.
966 979 */
967 980 function openstation_enqueue_native_window_scripts() {
968 - if ( ! openstation_is_enabled() || openstation_is_chromeless_request() || openstation_is_classic_request() ) {
981 + if ( ! openstation_is_shell_request() ) {
969 982 return;
970 983 }
971 984 $registry = openstation_native_window_registry();
972 985 if ( ! is_array( $registry ) ) {
@@ -1064,9 +1077,9 @@
1064 1077 * these via `document.getElementById( `os-native-window-${id}` )`
1065 1078 * and clones them into each opened window's body.
1066 1079 */
1067 1080 function openstation_render_native_window_templates() {
1068 - if ( ! openstation_is_enabled() || openstation_is_chromeless_request() || openstation_is_classic_request() ) {
1081 + if ( ! openstation_is_shell_request() ) {
1069 1082 return;
1070 1083 }
1071 1084 $registry = openstation_native_window_registry();
1072 1085 if ( ! is_array( $registry ) ) {
@@ -1092,4 +1105,21 @@
1092 1105 echo '</template>';
1093 1106 }
1094 1107 }
1095 1108 add_action( 'admin_footer', 'openstation_render_native_window_templates', 20 );
1109 +
1110 +/**
1111 + * Whether a registered window is offered on the admin this request is
1112 + * in: the network admin's shell offers `network` and `any` windows,
1113 + * every site's shell offers `site` and `any`. See the `admin` arg of
1114 + * {@see openstation_register_window()}.
1115 + *
1116 + * @param array<string,mixed> $entry Registry entry.
1117 + * @return bool
1118 + */
1119 +function openstation_native_window_offered_here( $entry ) {
1120 + $admin = isset( $entry['admin'] ) ? (string) $entry['admin'] : 'site';
1121 + if ( 'any' === $admin ) {
1122 + return true;
1123 + }
1124 + return is_network_admin() ? 'network' === $admin : 'site' === $admin;
1125 +}