PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.4
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.4
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
desktop-mode / includes / code-blue / window.php

window.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.4, at includes/code-blue/window.php

131 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation — Code Blue: window + desktop icon registration.
4 *
5 * Filterable surface (mirrors the content-graph module shape):
6 *
7 * - `openstation_code_blue_window_args`
8 * - `openstation_code_blue_icon_args`
9 * - `openstation_code_blue_template_html`
10 * - `openstation_code_blue_user_can_use` (in log-reader.php)
11 *
12 * @package OpenStation
13 */
14
15 defined( 'ABSPATH' ) || exit;
16
17 /**
18 * The vitals-monitor SVG, shared by the window icon and the desktop
19 * icon.
20 *
21 * A single pulse waveform: flatline, a beat, flatline. It is the
22 * universal mark for "is this thing healthy?", which is exactly the
23 * question the window answers — and it stays legible at 20px
24 * because it is one stroke. The dot at the end is the live cursor a
25 * monitor draws, and doubles as visual weight so the mark doesn't
26 * read as a bare zigzag.
27 *
28 * Drawn in `currentColor` like the Corkboard icon, so `renderIcon()`
29 * paints it as a CSS mask and it takes whatever colour the surface
30 * is already using for text. Hand-placed at 64×64, the established
31 * grid for custom icons here, and held to two elements.
32 *
33 * @return string Raw `<svg>` markup.
34 */
35 function openstation_code_blue_icon_svg() {
36 return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">'
37 . '<path d="M6 34 H20 L26 16 L36 50 L42 28 L46 34 H52" fill="none" stroke="currentColor" stroke-width="4.5" stroke-linecap="round" stroke-linejoin="round"/>'
38 . '<circle cx="57" cy="34" r="4.5" fill="currentColor"/>'
39 . '</svg>';
40 }
41
42 /**
43 * Render the Code Blue window's static template body. The bundle
44 * mounts its UI into `[data-os-code-blue-root]`.
45 */
46 function openstation_code_blue_render_template() {
47 ob_start();
48 ?>
49 <div class="openstation-code-blue" data-os-code-blue-root>
50 <div class="os-code-blue__loading" data-os-code-blue-loading>
51 <os-spinner></os-spinner>
52 </div>
53 </div>
54 <?php
55 $html = (string) ob_get_clean();
56
57 /**
58 * Filter the Code Blue window's template HTML.
59 *
60 * @param string $html Default template HTML.
61 */
62 $filtered = (string) apply_filters( 'openstation_code_blue_template_html', $html );
63
64 $allowed_html = function_exists( 'openstation_native_window_allowed_html' )
65 ? openstation_native_window_allowed_html()
66 : wp_kses_allowed_html( 'post' );
67
68 echo wp_kses( $filtered, $allowed_html );
69 }
70
71 /**
72 * Register the native window + the desktop icon on `init` priority
73 * 20, matching the content-graph + my-wordpress modules.
74 */
75 function openstation_code_blue_register_window() {
76 if ( ! openstation_code_blue_user_can_use() ) {
77 return;
78 }
79
80 $icon_uri = 'data:image/svg+xml;base64,' . base64_encode( openstation_code_blue_icon_svg() );
81
82 $window_args = array(
83 'title' => __( 'Code Blue', 'desktop-mode' ),
84 'icon' => $icon_uri,
85 'template' => 'openstation_code_blue_render_template',
86 'script' => 'openstation-code-blue',
87 'styles' => array( 'openstation-code-blue' ),
88 'width' => 1060,
89 'height' => 700,
90 'min_width' => 720,
91 'min_height' => 480,
92 'placement' => 'none',
93 'config' => array(
94 'restNonce' => wp_create_nonce( 'wp_rest' ),
95 'apiBase' => esc_url_raw( rest_url( 'desktop-mode/v1/code-blue' ) ),
96 ),
97 );
98
99 /**
100 * Filter the args used to register the Code Blue native window.
101 *
102 * @param array $window_args Args passed to `openstation_register_window()`.
103 */
104 $window_args = (array) apply_filters( 'openstation_code_blue_window_args', $window_args );
105
106 $registered = openstation_register_window( 'openstation-code-blue', $window_args );
107 if ( is_wp_error( $registered ) ) {
108 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
109 error_log( '[openstation] Code Blue window registration failed: ' . $registered->get_error_message() );
110 return;
111 }
112
113 $icon_args = array(
114 'title' => __( 'Code Blue', 'desktop-mode' ),
115 'icon_svg' => openstation_code_blue_icon_svg(),
116 'window' => 'openstation-code-blue',
117 'pinned' => false,
118 'position' => 24,
119 );
120
121 /**
122 * Filter the args used to register the Code Blue desktop icon.
123 *
124 * @param array $icon_args Args passed to `openstation_register_icon()`.
125 */
126 $icon_args = (array) apply_filters( 'openstation_code_blue_icon_args', $icon_args );
127
128 openstation_register_icon( 'openstation-code-blue', $icon_args );
129 }
130 add_action( 'init', 'openstation_code_blue_register_window', 20 );
131