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/window-notices.php +28 -28 0.9.81.1.10 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * Window notices — declarative top-of-window banners.
4 4 *
5 - * Plugins call `desktop_mode_register_window_notice()` to surface a
5 + * Plugins call `openstation_register_window_notice()` to surface a
6 6 * tone-coded banner at the top of every window matching a `match`
7 7 * predicate (or every window by default). The shell renders the
8 - * notice via the `<wpd-notice>` web component inside the window's
8 + * notice via the `<os-notice>` web component inside the window's
9 9 * `after-titlebar` slot, and records the user's dismissal in
10 10 * `localStorage` so the same notice never reappears.
11 11 *
12 12 * Notices are pure declarative data — no JS handle is needed.
@@ -13,9 +13,9 @@
13 13 *
14 14 * Example:
15 15 *
16 16 * ```php
17 - * desktop_mode_register_window_notice( array(
17 + * openstation_register_window_notice( array(
18 18 * 'id' => 'my-plugin/welcome',
19 19 * 'tone' => 'info',
20 20 * 'message' => '<strong>Welcome!</strong> Read the <a href="…">docs</a>.',
21 21 * 'match' => array( 'window' => 'edit-php' ), // optional
@@ -21,20 +21,20 @@
21 21 * 'match' => array( 'window' => 'edit-php' ), // optional
22 22 * ) );
23 23 * ```
24 24 *
25 - * @package DesktopMode
25 + * @package OpenStation
26 26 */
27 27
28 28 defined( 'ABSPATH' ) || exit;
29 29
30 30 /**
31 - * Allowed tones — mirror the `<wpd-notice>` component's `tone`
31 + * Allowed tones — mirror the `<os-notice>` component's `tone`
32 32 * attribute.
33 33 *
34 34 * @return string[]
35 35 */
36 -function desktop_mode_window_notice_tones() {
36 +function openstation_window_notice_tones() {
37 37 return array( 'info', 'success', 'warning', 'error', 'danger', 'neutral' );
38 38 }
39 39
40 40 /**
@@ -48,9 +48,9 @@
48 48 * links + basic formatting are allowed
49 49 * but `<script>` and other unsafe
50 50 * markup are stripped.
51 51 * @type string $tone Optional. One of
52 - * {@see desktop_mode_window_notice_tones()}.
52 + * {@see openstation_window_notice_tones()}.
53 53 * Default `info`.
54 54 * @type bool $dismissible Optional. Show a close button.
55 55 * Default `true`.
56 56 * @type string $icon Optional. Dashicons class for a
@@ -85,9 +85,9 @@
85 85 * only on the Posts window when its
86 86 * URL also contains `wc-admin` — not
87 87 * on every Posts window AND every
88 88 * wc-admin-URL window. Use two
89 - * separate `desktop_mode_register_window_notice()`
89 + * separate `openstation_register_window_notice()`
90 90 * calls for OR-across-selector-types.
91 91 *
92 92 * When omitted, the notice paints on
93 93 * every window.
@@ -97,9 +97,9 @@
97 97 * }
98 98 * @return true|WP_Error `true` on success; `WP_Error` on validation
99 99 * failure.
100 100 */
101 -function desktop_mode_register_window_notice( $args = array() ) {
101 +function openstation_register_window_notice( $args = array() ) {
102 102 $defaults = array(
103 103 'id' => '',
104 104 'message' => '',
105 105 'tone' => 'info',
@@ -107,20 +107,20 @@
107 107 'icon' => '',
108 108 'match' => array(),
109 109 'order' => 100,
110 110 );
111 - $args = wp_parse_args( $args, $defaults );
111 + $args = wp_parse_args( $args, $defaults );
112 112
113 113 $id = (string) $args['id'];
114 114 if ( '' === $id ) {
115 - return desktop_mode_registration_error(
116 - 'desktop_mode_missing_id',
115 + return openstation_registration_error(
116 + 'openstation_missing_id',
117 117 __( 'Window notice registration requires a non-empty `id`.', 'desktop-mode' )
118 118 );
119 119 }
120 120 if ( ! preg_match( '/^[a-z0-9_\\/-]+$/i', $id ) ) {
121 - return desktop_mode_registration_error(
122 - 'desktop_mode_invalid_id',
121 + return openstation_registration_error(
122 + 'openstation_invalid_id',
123 123 __( 'Window notice `id` must be alphanumeric with hyphens, underscores, or slashes.', 'desktop-mode' ),
124 124 array( 'id' => $id )
125 125 );
126 126 }
@@ -125,10 +125,10 @@
125 125 );
126 126 }
127 127
128 128 if ( '' === (string) $args['message'] ) {
129 - return desktop_mode_registration_error(
130 - 'desktop_mode_missing_message',
129 + return openstation_registration_error(
130 + 'openstation_missing_message',
131 131 __( 'Window notice registration requires a non-empty `message`.', 'desktop-mode' ),
132 132 array( 'id' => $id )
133 133 );
134 134 }
@@ -133,11 +133,11 @@
133 133 );
134 134 }
135 135
136 136 $tone = (string) $args['tone'];
137 - if ( ! in_array( $tone, desktop_mode_window_notice_tones(), true ) ) {
138 - return desktop_mode_registration_error(
139 - 'desktop_mode_invalid_tone',
137 + if ( ! in_array( $tone, openstation_window_notice_tones(), true ) ) {
138 + return openstation_registration_error(
139 + 'openstation_invalid_tone',
140 140 __( 'Window notice `tone` must be one of the documented values.', 'desktop-mode' ),
141 141 array(
142 142 'id' => $id,
143 143 'tone' => $tone,
@@ -162,9 +162,9 @@
162 162 'match' => is_array( $args['match'] ) ? $args['match'] : array(),
163 163 'order' => (int) $args['order'],
164 164 );
165 165
166 - desktop_mode_window_notice_registry( $entry['id'], $entry );
166 + openstation_window_notice_registry( $entry['id'], $entry );
167 167
168 168 /**
169 169 * Fires after a window notice is successfully registered.
170 170 *
@@ -170,9 +170,9 @@
170 170 *
171 171 * @param string $id The notice id.
172 172 * @param array $entry The stored registry entry.
173 173 */
174 - do_action( 'desktop_mode_window_notice_registered', $entry['id'], $entry );
174 + do_action( 'openstation_window_notice_registered', $entry['id'], $entry );
175 175
176 176 return true;
177 177 }
178 178
@@ -184,9 +184,9 @@
184 184 * @param string $id Id to read or write.
185 185 * @param array|null $entry Entry to store, or `null` to read.
186 186 * @return array|null
187 187 */
188 -function desktop_mode_window_notice_registry( $id = '', $entry = null ) {
188 +function openstation_window_notice_registry( $id = '', $entry = null ) {
189 189 static $store = array();
190 190
191 191 if ( '__flush__' === (string) $id ) {
192 192 $store = array();
@@ -210,22 +210,22 @@
210 210 * commands / settings-tabs / window-chrome registries expose.
211 211 *
212 212 * @internal
213 213 */
214 -function desktop_mode_flush_window_notice_registry() {
215 - desktop_mode_window_notice_registry( '__flush__' );
214 +function openstation_flush_window_notice_registry() {
215 + openstation_window_notice_registry( '__flush__' );
216 216 }
217 217
218 218 /**
219 219 * Build the payload shipped to the shell. Each entry is the stored
220 220 * registry record, runnable through the
221 - * `desktop_mode_window_notices` filter so plugins can mutate the
221 + * `openstation_window_notices` filter so plugins can mutate the
222 222 * final list (e.g. add a dynamic notice computed at request time).
223 223 *
224 224 * @return array[]
225 225 */
226 -function desktop_mode_build_window_notices_payload() {
227 - $registry = desktop_mode_window_notice_registry();
226 +function openstation_build_window_notices_payload() {
227 + $registry = openstation_window_notice_registry();
228 228 $entries = is_array( $registry ) ? array_values( $registry ) : array();
229 229
230 230 /**
231 231 * Filter the assembled list of window notices before it ships to
@@ -234,9 +234,9 @@
234 234 * without registering them statically.
235 235 *
236 236 * @param array[] $entries List of notice entries.
237 237 */
238 - $entries = apply_filters( 'desktop_mode_window_notices', $entries );
238 + $entries = apply_filters( 'openstation_window_notices', $entries );
239 239
240 240 // Re-sort by order for deterministic emission, then by id.
241 241 usort(
242 242 $entries,