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/dock-rail-renderer.php +26 -33 0.8.81.1.10 View file →
@@ -2,10 +2,10 @@
2 2 /**
3 3 * Server-side opt-in for dock rail renderer scripts.
4 4 *
5 5 * Mirrors `includes/commands.php` exactly — a plugin enqueues a JS
6 - * bundle that registers a renderer with `wp.desktop.registerDockRailRenderer()`,
7 - * then calls `desktop_mode_register_dock_rail_renderer_script( $handle )`
6 + * bundle that registers a renderer with `wp.os.registerDockRailRenderer()`,
7 + * then calls `openstation_register_dock_rail_renderer_script( $handle )`
8 8 * to opt the script into the live-refresh payload. The shell loads
9 9 * the script over the chromeless bridge on activation, the JS calls
10 10 * `registerDockRailRenderer()`, and the OS Settings → Dock style picker
11 11 * surfaces the new option immediately — no F5.
@@ -14,11 +14,9 @@
14 14 * tagged with `owner: '<handle>'` is unregistered. The active id falls
15 15 * back through the registry's chain (user pick → `default`) and the
16 16 * dispatcher rebuilds the rails with whatever resolves.
17 17 *
18 - * @since 0.18.0
19 - *
20 - * @package WPDesktopMode
18 + * @package OpenStation
21 19 */
22 20
23 21 defined( 'ABSPATH' ) || exit;
24 22
@@ -27,49 +25,45 @@
27 25 *
28 26 * Example:
29 27 *
30 28 * ```php
31 - * add_action( 'desktop_mode_shell_assets', function () {
29 + * add_action( 'openstation_shell_assets', function () {
32 30 * wp_register_script(
33 31 * 'orbit-rail',
34 32 * plugin_dir_url( __FILE__ ) . 'orbit-rail.js',
35 - * array( 'desktop-mode' ),
33 + * array( 'openstation' ),
36 34 * '1.0.0',
37 35 * true
38 36 * );
39 37 * wp_enqueue_script( 'orbit-rail' );
40 38 * } );
41 - * desktop_mode_register_dock_rail_renderer_script( 'orbit-rail' );
39 + * openstation_register_dock_rail_renderer_script( 'orbit-rail' );
42 40 * ```
43 41 *
44 - * The script's JS side calls `wp.desktop.registerDockRailRenderer( { … } )`
42 + * The script's JS side calls `wp.os.registerDockRailRenderer( { … } )`
45 43 * with `owner: 'orbit-rail'` (matching the handle) so deactivation
46 44 * cleanly removes the renderer.
47 45 *
48 - * @since 0.18.0
49 - *
50 46 * @param string $handle WP-registered script handle.
51 47 * @return true|WP_Error `true` on success; `WP_Error` on validation failure.
52 48 */
53 -function desktop_mode_register_dock_rail_renderer_script( $handle ) {
49 +function openstation_register_dock_rail_renderer_script( $handle ) {
54 50 $handle = (string) $handle;
55 51 if ( '' === $handle ) {
56 - return desktop_mode_registration_error(
57 - 'desktop_mode_missing_handle',
52 + return openstation_registration_error(
53 + 'openstation_missing_handle',
58 54 __( 'Dock rail renderer script registration requires a non-empty script handle.', 'desktop-mode' )
59 55 );
60 56 }
61 57
62 - desktop_mode_dock_rail_renderer_script_registry( $handle, true );
58 + openstation_dock_rail_renderer_script_registry( $handle, true );
63 59
64 60 /**
65 61 * Fires after a desktop dock rail renderer script handle is registered.
66 62 *
67 - * @since 0.18.0
68 - *
69 63 * @param string $handle The registered script handle.
70 64 */
71 - do_action( 'desktop_mode_dock_rail_renderer_script_registered', $handle );
65 + do_action( 'openstation_dock_rail_renderer_script_registered', $handle );
72 66
73 67 return true;
74 68 }
75 69
@@ -76,9 +70,8 @@
76 70 /**
77 71 * Internal module-level registry for dock rail renderer script handles.
78 72 * Read by the payload builder, written by the registration API.
79 73 *
80 - * @since 0.18.0
81 74 * @internal
82 75 *
83 76 * @param string $handle Script handle to read or write.
84 77 * @param bool|null $value Pass `true` to register; `null` to read only.
@@ -83,9 +76,9 @@
83 76 * @param string $handle Script handle to read or write.
84 77 * @param bool|null $value Pass `true` to register; `null` to read only.
85 78 * @return array|bool When called with no args returns the full store.
86 79 */
87 -function desktop_mode_dock_rail_renderer_script_registry( $handle = '', $value = null ) {
80 +function openstation_dock_rail_renderer_script_registry( $handle = '', $value = null ) {
88 81 static $store = array();
89 82
90 83 if ( '__flush__' === (string) $handle ) {
91 84 $store = array();
@@ -100,14 +93,13 @@
100 93 return isset( $store[ (string) $handle ] ) ? $store[ (string) $handle ] : false;
101 94 }
102 95
103 96 /**
104 - * Flush the registry. Tests call this in `set_up`.
105 - *
106 - * @since 0.18.0
97 + * Test-only: clear the registry between PHPUnit cases. See
98 + * {@see openstation_flush_script_handle_registries()}.
107 99 */
108 -function desktop_mode_flush_dock_rail_renderer_script_registry() {
109 - desktop_mode_dock_rail_renderer_script_registry( '__flush__' );
100 +function openstation_flush_dock_rail_renderer_script_registry() {
101 + openstation_dock_rail_renderer_script_registry( '__flush__' );
110 102 }
111 103
112 104 /**
113 105 * Build the payload fed to the shell. Resolves each registered handle
@@ -115,14 +107,12 @@
115 107 * scriptTranslations }` entry; handles that aren't currently enqueued
116 108 * (plugin not active this request) resolve to an empty URL and are
117 109 * dropped.
118 110 *
119 - * @since 0.18.0
120 - *
121 111 * @return array[]
122 112 */
123 -function desktop_mode_build_dock_rail_renderer_scripts_payload() {
124 - $registry = desktop_mode_dock_rail_renderer_script_registry();
113 +function openstation_build_dock_rail_renderer_scripts_payload() {
114 + $registry = openstation_dock_rail_renderer_script_registry();
125 115 if ( ! is_array( $registry ) || empty( $registry ) ) {
126 116 return array();
127 117 }
128 118
@@ -131,18 +121,18 @@
131 121 foreach ( $registry as $handle => $active ) {
132 122 if ( ! $active || isset( $seen[ $handle ] ) ) {
133 123 continue;
134 124 }
135 - $payload = desktop_mode_resolve_script_payload( $handle );
125 + $payload = openstation_resolve_script_payload( $handle );
136 126 if ( '' === $payload['url'] ) {
137 - desktop_mode_warn_unresolvable_script_handle(
138 - 'desktop_mode_register_dock_rail_renderer_script',
127 + openstation_warn_unresolvable_script_handle(
128 + 'openstation_register_dock_rail_renderer_script',
139 129 'Dock rail renderer',
140 130 (string) $handle
141 131 );
142 132 continue;
143 133 }
144 - $out[] = array(
134 + $out[] = array(
145 135 'handle' => (string) $handle,
146 136 'scriptUrl' => $payload['url'],
147 137 'scriptBefore' => $payload['before'],
148 138 'scriptAfter' => $payload['after'],
@@ -147,8 +137,11 @@
147 137 'scriptBefore' => $payload['before'],
148 138 'scriptAfter' => $payload['after'],
149 139 'scriptL10n' => $payload['l10n'],
150 140 'scriptTranslations' => $payload['translations'],
141 + // The handle's dependency closure, replayed before the bundle
142 + // on its lazy load — see `openstation_resolve_script_dependencies()`.
143 + 'scriptDeps' => openstation_resolve_script_dependencies( $handle ),
151 144 );
152 145 $seen[ $handle ] = true;
153 146 }
154 147 return $out;