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/unfocus-effects.php +24 -21 0.9.81.1.10 View file →
@@ -3,9 +3,9 @@
3 3 * Desktop unfocused-window effect registration API.
4 4 *
5 5 * Mirrors the command-script / title-bar-button-script registration
6 6 * pattern: minimum-ceremony PHP opt-in
7 - * (`desktop_mode_register_unfocus_effect_script`) tells the shell which
7 + * (`openstation_register_unfocus_effect_script`) tells the shell which
8 8 * enqueued scripts contribute unfocus effects. The shell injects the
9 9 * script URL into the live-refresh payload so a plugin activated
10 10 * mid-session surfaces its effect in OS Settings → Effects immediately,
11 11 * no F5 needed.
@@ -10,14 +10,14 @@
10 10 * mid-session surfaces its effect in OS Settings → Effects immediately,
11 11 * no F5 needed.
12 12 *
13 13 * Effects themselves are declared JS-side via
14 - * `wp.desktop.registerUnfocusEffect( … )` — the CSS class, apply/clear
14 + * `wp.os.registerUnfocusEffect( … )` — the CSS class, apply/clear
15 15 * callbacks, and label all live in the plugin's TypeScript /
16 16 * JavaScript. The built-in `darken` is registered through the very
17 17 * same JS hook (see `src/effects/registry.ts`).
18 18 *
19 - * @package WPDesktopMode
19 + * @package OpenStation
20 20 */
21 21
22 22 defined( 'ABSPATH' ) || exit;
23 23
@@ -30,15 +30,15 @@
30 30 * add_action( 'admin_enqueue_scripts', function () {
31 31 * wp_register_script(
32 32 * 'my-plugin-effects',
33 33 * plugins_url( 'js/effects.js', __FILE__ ),
34 - * array( 'desktop-mode' ),
34 + * array( 'openstation' ),
35 35 * '1.0.0',
36 36 * true
37 37 * );
38 38 * wp_enqueue_script( 'my-plugin-effects' );
39 - * } );
40 - * desktop_mode_register_unfocus_effect_script( 'my-plugin-effects' );
39 + * }, 5 ); // Before the shell harvests the payload at priority 10.
40 + * openstation_register_unfocus_effect_script( 'my-plugin-effects' );
41 41 * ```
42 42 *
43 43 * For live unregistration on deactivation, the plugin's JS should set
44 44 * `owner: 'my-plugin-effects'` on each `registerUnfocusEffect` call.
@@ -47,18 +47,18 @@
47 47 *
48 48 * @param string $handle WP-registered script handle.
49 49 * @return true|WP_Error `true` on success; `WP_Error` on validation failure.
50 50 */
51 -function desktop_mode_register_unfocus_effect_script( $handle ) {
51 +function openstation_register_unfocus_effect_script( $handle ) {
52 52 $handle = (string) $handle;
53 53 if ( '' === $handle ) {
54 - return desktop_mode_registration_error(
55 - 'desktop_mode_missing_handle',
54 + return openstation_registration_error(
55 + 'openstation_missing_handle',
56 56 __( 'Unfocus effect script registration requires a non-empty script handle.', 'desktop-mode' )
57 57 );
58 58 }
59 59
60 - desktop_mode_desktop_unfocus_effect_script_registry( $handle, true );
60 + openstation_desktop_unfocus_effect_script_registry( $handle, true );
61 61
62 62 /**
63 63 * Fires after a desktop unfocus-effect script handle is registered.
64 64 *
@@ -63,9 +63,9 @@
63 63 * Fires after a desktop unfocus-effect script handle is registered.
64 64 *
65 65 * @param string $handle The registered script handle.
66 66 */
67 - do_action( 'desktop_mode_unfocus_effect_script_registered', $handle );
67 + do_action( 'openstation_unfocus_effect_script_registered', $handle );
68 68
69 69 return true;
70 70 }
71 71
@@ -77,9 +77,9 @@
77 77 * @param string $handle Script handle to read or write.
78 78 * @param bool|null $value Pass `true` to register; `null` to read only.
79 79 * @return array|bool When called with no args returns the full store.
80 80 */
81 -function desktop_mode_desktop_unfocus_effect_script_registry( $handle = '', $value = null ) {
81 +function openstation_desktop_unfocus_effect_script_registry( $handle = '', $value = null ) {
82 82 static $store = array();
83 83
84 84 if ( '__flush__' === (string) $handle ) {
85 85 $store = array();
@@ -95,12 +95,12 @@
95 95 }
96 96
97 97 /**
98 98 * Test-only: clear the registry between PHPUnit cases. See
99 - * {@see desktop_mode_flush_script_handle_registries()}.
99 + * {@see openstation_flush_script_handle_registries()}.
100 100 */
101 -function desktop_mode_flush_desktop_unfocus_effect_script_registry() {
102 - desktop_mode_desktop_unfocus_effect_script_registry( '__flush__' );
101 +function openstation_flush_desktop_unfocus_effect_script_registry() {
102 + openstation_desktop_unfocus_effect_script_registry( '__flush__' );
103 103 }
104 104
105 105 /**
106 106 * Build the script-handle payload fed to the shell. Handles that
@@ -107,10 +107,10 @@
107 107 * aren't currently enqueued resolve to an empty URL and are dropped.
108 108 *
109 109 * @return array[] List of `{ handle, scriptUrl, … }` entries.
110 110 */
111 -function desktop_mode_build_desktop_unfocus_effect_scripts_payload() {
112 - $registry = desktop_mode_desktop_unfocus_effect_script_registry();
111 +function openstation_build_desktop_unfocus_effect_scripts_payload() {
112 + $registry = openstation_desktop_unfocus_effect_script_registry();
113 113 if ( ! is_array( $registry ) || empty( $registry ) ) {
114 114 return array();
115 115 }
116 116
@@ -119,15 +119,15 @@
119 119 foreach ( $registry as $handle => $active ) {
120 120 if ( ! $active || isset( $seen[ $handle ] ) ) {
121 121 continue;
122 122 }
123 - $payload = desktop_mode_resolve_script_payload( $handle );
123 + $payload = openstation_resolve_script_payload( $handle );
124 124 if ( '' === $payload['url'] ) {
125 125 // Loud diagnostic — visible under WP_DEBUG. Deduped by
126 - // `desktop_mode_warn_unresolvable_script_handle` so the
126 + // `openstation_warn_unresolvable_script_handle` so the
127 127 // notice fires once per handle per request.
128 - desktop_mode_warn_unresolvable_script_handle(
129 - 'desktop_mode_register_unfocus_effect_script',
128 + openstation_warn_unresolvable_script_handle(
129 + 'openstation_register_unfocus_effect_script',
130 130 'Unfocus effect',
131 131 (string) $handle
132 132 );
133 133 continue;
@@ -138,8 +138,11 @@
138 138 'scriptBefore' => $payload['before'],
139 139 'scriptAfter' => $payload['after'],
140 140 'scriptL10n' => $payload['l10n'],
141 141 'scriptTranslations' => $payload['translations'],
142 + // The handle's dependency closure, replayed before the bundle
143 + // on its lazy load — see `openstation_resolve_script_dependencies()`.
144 + 'scriptDeps' => openstation_resolve_script_dependencies( $handle ),
142 145 );
143 146 $seen[ $handle ] = true;
144 147 }
145 148 return $out;