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/title-bar-buttons.php +24 -21 0.9.81.1.10 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * Desktop title-bar button registration API.
4 4 *
5 5 * Mirrors the command-script / settings-tab-script registration
6 - * pattern: minimum-ceremony PHP opt-in (`desktop_mode_register_titlebar_button_script`)
6 + * pattern: minimum-ceremony PHP opt-in (`openstation_register_titlebar_button_script`)
7 7 * tells the shell which enqueued scripts contribute title-bar
8 8 * buttons. The shell injects the script URL into the live-refresh
9 9 * payload so a plugin activated mid-session paints its button
10 10 * immediately, no F5 needed.
@@ -9,12 +9,12 @@
9 9 * payload so a plugin activated mid-session paints its button
10 10 * immediately, no F5 needed.
11 11 *
12 12 * Buttons themselves are declared JS-side via
13 - * `wp.desktop.registerTitleBarButton( … )` — the predicate, render,
13 + * `wp.os.registerTitleBarButton( … )` — the predicate, render,
14 14 * and onClick all live in the plugin's TypeScript / JavaScript.
15 15 *
16 - * @package WPDesktopMode
16 + * @package OpenStation
17 17 */
18 18
19 19 defined( 'ABSPATH' ) || exit;
20 20
@@ -28,15 +28,15 @@
28 28 * add_action( 'admin_enqueue_scripts', function () {
29 29 * wp_register_script(
30 30 * 'my-plugin-titlebar',
31 31 * plugins_url( 'js/titlebar.js', __FILE__ ),
32 - * array( 'desktop-mode' ),
32 + * array( 'openstation' ),
33 33 * '1.0.0',
34 34 * true
35 35 * );
36 36 * wp_enqueue_script( 'my-plugin-titlebar' );
37 - * } );
38 - * desktop_mode_register_titlebar_button_script( 'my-plugin-titlebar' );
37 + * }, 5 ); // Before the shell harvests the payload at priority 10.
38 + * openstation_register_titlebar_button_script( 'my-plugin-titlebar' );
39 39 * ```
40 40 *
41 41 * For live unregistration on deactivation, the plugin's JS should
42 42 * set `owner: 'my-plugin-titlebar'` on each `registerTitleBarButton`
@@ -45,18 +45,18 @@
45 45 *
46 46 * @param string $handle WP-registered script handle.
47 47 * @return true|WP_Error `true` on success; `WP_Error` on validation failure.
48 48 */
49 -function desktop_mode_register_titlebar_button_script( $handle ) {
49 +function openstation_register_titlebar_button_script( $handle ) {
50 50 $handle = (string) $handle;
51 51 if ( '' === $handle ) {
52 - return desktop_mode_registration_error(
53 - 'desktop_mode_missing_handle',
52 + return openstation_registration_error(
53 + 'openstation_missing_handle',
54 54 __( 'Title-bar button script registration requires a non-empty script handle.', 'desktop-mode' )
55 55 );
56 56 }
57 57
58 - desktop_mode_desktop_titlebar_button_script_registry( $handle, true );
58 + openstation_desktop_titlebar_button_script_registry( $handle, true );
59 59
60 60 /**
61 61 * Fires after a desktop title-bar button script handle is registered.
62 62 *
@@ -61,9 +61,9 @@
61 61 * Fires after a desktop title-bar button script handle is registered.
62 62 *
63 63 * @param string $handle The registered script handle.
64 64 */
65 - do_action( 'desktop_mode_titlebar_button_script_registered', $handle );
65 + do_action( 'openstation_titlebar_button_script_registered', $handle );
66 66
67 67 return true;
68 68 }
69 69
@@ -75,9 +75,9 @@
75 75 * @param string $handle Script handle to read or write.
76 76 * @param bool|null $value Pass `true` to register; `null` to read only.
77 77 * @return array|bool When called with no args returns the full store.
78 78 */
79 -function desktop_mode_desktop_titlebar_button_script_registry( $handle = '', $value = null ) {
79 +function openstation_desktop_titlebar_button_script_registry( $handle = '', $value = null ) {
80 80 static $store = array();
81 81
82 82 if ( '__flush__' === (string) $handle ) {
83 83 $store = array();
@@ -93,12 +93,12 @@
93 93 }
94 94
95 95 /**
96 96 * Test-only: clear the registry between PHPUnit cases. See
97 - * {@see desktop_mode_flush_script_handle_registries()}.
97 + * {@see openstation_flush_script_handle_registries()}.
98 98 */
99 -function desktop_mode_flush_desktop_titlebar_button_script_registry() {
100 - desktop_mode_desktop_titlebar_button_script_registry( '__flush__' );
99 +function openstation_flush_desktop_titlebar_button_script_registry() {
100 + openstation_desktop_titlebar_button_script_registry( '__flush__' );
101 101 }
102 102
103 103 /**
104 104 * Build the script-handle payload fed to the shell. Handles that
@@ -105,10 +105,10 @@
105 105 * aren't currently enqueued resolve to an empty URL and are dropped.
106 106 *
107 107 * @return array[] List of `{ handle, scriptUrl, scriptBefore, scriptAfter, scriptL10n, scriptTranslations }` entries.
108 108 */
109 -function desktop_mode_build_desktop_titlebar_button_scripts_payload() {
110 - $registry = desktop_mode_desktop_titlebar_button_script_registry();
109 +function openstation_build_desktop_titlebar_button_scripts_payload() {
110 + $registry = openstation_desktop_titlebar_button_script_registry();
111 111 if ( ! is_array( $registry ) || empty( $registry ) ) {
112 112 return array();
113 113 }
114 114
@@ -117,19 +117,19 @@
117 117 foreach ( $registry as $handle => $active ) {
118 118 if ( ! $active || isset( $seen[ $handle ] ) ) {
119 119 continue;
120 120 }
121 - $payload = desktop_mode_resolve_script_payload( $handle );
121 + $payload = openstation_resolve_script_payload( $handle );
122 122 if ( '' === $payload['url'] ) {
123 123 // Loud diagnostic — visible under WP_DEBUG. Plugin
124 124 // authors who pass a typo'd handle, or call our
125 125 // register helper before `wp_register_script()`, used
126 126 // to silently register nothing and stare at an empty
127 - // title bar. Deduped by `desktop_mode_warn_unresolvable_script_handle`
127 + // title bar. Deduped by `openstation_warn_unresolvable_script_handle`
128 128 // so the notice fires exactly once per handle per
129 129 // request, not on every shell-config rebuild.
130 - desktop_mode_warn_unresolvable_script_handle(
131 - 'desktop_mode_register_titlebar_button_script',
130 + openstation_warn_unresolvable_script_handle(
131 + 'openstation_register_titlebar_button_script',
132 132 'Title-bar button',
133 133 (string) $handle
134 134 );
135 135 continue;
@@ -140,8 +140,11 @@
140 140 'scriptBefore' => $payload['before'],
141 141 'scriptAfter' => $payload['after'],
142 142 'scriptL10n' => $payload['l10n'],
143 143 'scriptTranslations' => $payload['translations'],
144 + // The handle's dependency closure, replayed before the bundle
145 + // on its lazy load — see `openstation_resolve_script_dependencies()`.
146 + 'scriptDeps' => openstation_resolve_script_dependencies( $handle ),
144 147 );
145 148 $seen[ $handle ] = true;
146 149 }
147 150 return $out;