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/widgets/heartbeat.php +48 -54 0.9.51.1.10 View file →
@@ -1,9 +1,9 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Heartbeat widget (built-in, lazy-loaded).
3 + * OpenStation — Heartbeat widget (built-in, lazy-loaded).
4 4 *
5 - * Dogfoods the public `desktop_mode_register_widget()` API for a
5 + * Dogfoods the public `openstation_register_widget()` API for a
6 6 * built-in widget: the metadata + script handle live here, the
7 7 * JS + CSS ship as their own Vite bundle
8 8 * (`assets/js/widget-heartbeat[.min].js` and matching `.css`).
9 9 * The shell's widgets `server-sync` only loads them when the user
@@ -9,10 +9,9 @@
9 9 * The shell's widgets `server-sync` only loads them when the user
10 10 * adds the widget or the picker is opened — main bundle keeps
11 11 * none of the heart's code.
12 12 *
13 - * @package WPDesktopMode
14 - * @since 0.8.5
13 + * @package OpenStation
15 14 */
16 15
17 16 defined( 'ABSPATH' ) || exit;
18 17
@@ -20,36 +19,34 @@
20 19 * Register the JS bundle as a script handle so it can be loaded
21 20 * lazily via `wp_register_script()` / its URL. The CSS file
22 21 * emitted by Vite alongside the JS is registered as its own
23 22 * style handle and eagerly enqueued by
24 - * desktop_mode_enqueue_heartbeat_widget_styles() below — the
23 + * openstation_enqueue_heartbeat_widget_styles() below — the
25 24 * widget server-sync only injects the JS, so the stylesheet must
26 25 * ship ahead of time for the chrome to paint with the JS.
27 - *
28 - * @since 0.8.5
29 26 */
30 -function desktop_mode_register_heartbeat_widget_assets() {
31 - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
32 - $version = defined( 'DESKTOP_MODE_VERSION' ) ? DESKTOP_MODE_VERSION : '0';
27 +function openstation_register_heartbeat_widget_assets() {
28 + $suffix = openstation_asset_suffix();
29 + $version = defined( 'OPENSTATION_VERSION' ) ? OPENSTATION_VERSION : '0';
33 30
34 - $js_path = DESKTOP_MODE_DIR . 'assets/js/widget-heartbeat' . $suffix . '.js';
35 - $css_path = DESKTOP_MODE_DIR . 'assets/js/widget-heartbeat' . $suffix . '.css';
31 + $js_path = OPENSTATION_DIR . 'assets/js/widget-heartbeat' . $suffix . '.js';
32 + $css_path = OPENSTATION_DIR . 'assets/js/widget-heartbeat' . $suffix . '.css';
36 33
37 34 wp_register_style(
38 - 'desktop-mode-heartbeat-widget',
39 - DESKTOP_MODE_URL . 'assets/js/widget-heartbeat' . $suffix . '.css',
35 + 'os-heartbeat-widget',
36 + OPENSTATION_URL . 'assets/js/widget-heartbeat' . $suffix . '.css',
40 37 array(),
41 38 file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version
42 39 );
43 40 wp_register_script(
44 - 'desktop-mode-heartbeat-widget',
45 - DESKTOP_MODE_URL . 'assets/js/widget-heartbeat' . $suffix . '.js',
41 + 'os-heartbeat-widget',
42 + OPENSTATION_URL . 'assets/js/widget-heartbeat' . $suffix . '.js',
46 43 array( 'wp-hooks' ),
47 44 file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version,
48 45 true
49 46 );
50 47 }
51 -add_action( 'init', 'desktop_mode_register_heartbeat_widget_assets', 5 );
48 +add_action( 'init', 'openstation_register_heartbeat_widget_assets', 5 );
52 49
53 50 /**
54 51 * Register the widget itself. Sizing constraints + chrome metadata
55 52 * (label / description / icon) live here so the framework knows
@@ -54,38 +51,39 @@
54 51 * Register the widget itself. Sizing constraints + chrome metadata
55 52 * (label / description / icon) live here so the framework knows
56 53 * the widget exists at picker-render time, before the JS bundle
57 54 * is even fetched.
58 - *
59 - * @since 0.8.5
60 55 */
61 -function desktop_mode_register_heartbeat_widget() {
62 - if ( ! function_exists( 'desktop_mode_register_widget' ) ) {
56 +function openstation_register_heartbeat_widget() {
57 + if ( ! function_exists( 'openstation_register_widget' ) ) {
63 58 return;
64 59 }
65 - desktop_mode_register_widget( 'desktop-mode/heartbeat', array(
66 - 'label' => __( 'Heartbeat', 'desktop-mode' ),
67 - 'description' => __(
68 - 'A gently beating heart that pulses with the WordPress Heartbeat. The bar fills as the next tick approaches.',
69 - 'desktop-mode'
70 - ),
71 - 'icon' => 'dashicons-heart',
72 - 'script' => 'desktop-mode-heartbeat-widget',
73 - 'movable' => true,
74 - 'resizable' => false,
75 - 'min_width' => 310,
76 - 'max_width' => 310,
77 - 'min_height' => 230,
78 - 'max_height' => 230,
79 - 'default_width' => 310,
80 - 'default_height' => 230,
81 - ) );
60 + openstation_register_widget(
61 + 'desktop-mode/heartbeat',
62 + array(
63 + 'label' => __( 'Heartbeat', 'desktop-mode' ),
64 + 'description' => __(
65 + 'A gently beating heart that pulses with the WordPress Heartbeat. The bar fills as the next tick approaches.',
66 + 'desktop-mode'
67 + ),
68 + 'icon' => 'dashicons-heart',
69 + 'script' => 'os-heartbeat-widget',
70 + 'movable' => true,
71 + 'resizable' => false,
72 + 'min_width' => 310,
73 + 'max_width' => 310,
74 + 'min_height' => 230,
75 + 'max_height' => 230,
76 + 'default_width' => 310,
77 + 'default_height' => 230,
78 + )
79 + );
82 80 }
83 -add_action( 'init', 'desktop_mode_register_heartbeat_widget', 6 );
81 +add_action( 'init', 'openstation_register_heartbeat_widget', 6 );
84 82
85 83 /**
86 84 * Eagerly enqueue the widget's CSS handle when the current
87 - * request runs in Desktop Mode and is not a chromeless iframe
85 + * request runs in OpenStation and is not a chromeless iframe
88 86 * load. The JS bundle stays lazy and loads via the widget
89 87 * server-sync the first time the picker opens or the widget
90 88 * mounts.
91 89 *
@@ -103,22 +101,20 @@
103 101 * themselves — sending the stylesheet there is dead weight. Note
104 102 * that classic-override pages (`?desktop_mode_classic=1`) are
105 103 * not excluded: they skip the shell but still receive the
106 104 * (1.9 KB) stylesheet. The
107 - * `desktop_mode_heartbeat_widget_eager_css` filter lets a
105 + * `openstation_heartbeat_widget_eager_css` filter lets a
108 106 * site owner opt out entirely without forking the plugin.
109 - *
110 - * @since 0.8.5
111 107 */
112 -function desktop_mode_enqueue_heartbeat_widget_styles() {
113 - if ( function_exists( 'desktop_mode_is_enabled' ) && ! desktop_mode_is_enabled() ) {
108 +function openstation_enqueue_heartbeat_widget_styles() {
109 + if ( function_exists( 'openstation_is_enabled' ) && ! openstation_is_enabled() ) {
114 110 return;
115 111 }
116 112 // Chromeless requests render content inside an iframe owned
117 113 // by a shell elsewhere — they never mount widgets themselves.
118 114 if (
119 - function_exists( 'desktop_mode_is_chromeless_request' )
120 - && desktop_mode_is_chromeless_request()
115 + function_exists( 'openstation_is_chromeless_request' )
116 + && openstation_is_chromeless_request()
121 117 ) {
122 118 return;
123 119 }
124 120 /**
@@ -123,20 +119,18 @@
123 119 }
124 120 /**
125 121 * Whether to enqueue the heartbeat widget's stylesheet on
126 122 * this request. Defaults to `true` for shell requests in
127 - * Desktop Mode. Sites that never plan to ship the heartbeat
123 + * OpenStation. Sites that never plan to ship the heartbeat
128 124 * widget can return `false` and save the ~0.66 KB gzipped
129 125 * stylesheet roundtrip.
130 126 *
131 - * @since 0.8.5
132 - *
133 127 * @param bool $eager Default `true` once the chromeless +
134 - * desktop-mode gates above have passed.
128 + * openstation gates above have passed.
135 129 */
136 - $eager = (bool) apply_filters( 'desktop_mode_heartbeat_widget_eager_css', true );
130 + $eager = (bool) apply_filters( 'openstation_heartbeat_widget_eager_css', true );
137 131 if ( ! $eager ) {
138 132 return;
139 133 }
140 - wp_enqueue_style( 'desktop-mode-heartbeat-widget' );
134 + wp_enqueue_style( 'os-heartbeat-widget' );
141 135 }
142 -add_action( 'admin_enqueue_scripts', 'desktop_mode_enqueue_heartbeat_widget_styles', 20 );
136 +add_action( 'admin_enqueue_scripts', 'openstation_enqueue_heartbeat_widget_styles', 20 );