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/notes/cpt.php +25 -40 0.9.71.1.10 View file →
@@ -1,18 +1,16 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Pinned notes CPT.
3 + * OpenStation — Pinned notes CPT.
4 4 *
5 5 * Registers the `wpd_note` post type backing the pinned-notes feature:
6 - * paper notes the user writes in the Note Pad widget and pins to the
7 - * desktop wallpaper. Distinct from the Guidelines-backed sticky-notes
8 - * layer (`includes/sticky-notes/heartbeat.php`) — that one rides
9 - * Gutenberg's `wp_guideline` CPT; this one is plugin-owned.
6 + * paper notes the user writes in the Note Pad widget (or straight on
7 + * the wallpaper, via its right-click menu) and pins to the desktop.
10 8 *
11 9 * Visibility model: the "public" checkbox maps to `post_status`.
12 10 *
13 11 * 'private' — default; only the owner sees the note.
14 - * 'publish' — public; every desktop-mode user sees it (read-only
12 + * 'publish' — public; every openstation user sees it (read-only
15 13 * for non-owners). Nothing leaks outside the plugin's
16 14 * own REST controller because the CPT is not publicly
17 15 * queryable, excluded from search, and absent from the
18 16 * core REST API.
@@ -20,15 +18,14 @@
20 18 * Position (normalized 0–1 of the desktop area), paper color, and
21 19 * z-order live in postmeta — per-owner placement is the canonical
22 20 * placement every viewer sees.
23 21 *
24 - * @package WPDesktopMode
25 - * @since 0.9.6
22 + * @package OpenStation
26 23 */
27 24
28 25 defined( 'ABSPATH' ) || exit;
29 26
30 -const DESKTOP_MODE_NOTES_POST_TYPE = 'wpd_note';
27 +const OPENSTATION_NOTES_POST_TYPE = 'wpd_note';
31 28
32 29 /**
33 30 * The pastel paper color slugs a note may use.
34 31 *
@@ -35,13 +32,11 @@
35 32 * Mirrored client-side in `src/notes/colors.ts` — keep both lists in
36 33 * sync (the CSS custom properties in `assets/css/notes.css` are keyed
37 34 * by these slugs).
38 35 *
39 - * @since 0.9.6
40 - *
41 36 * @return string[] Color slugs.
42 37 */
43 -function desktop_mode_notes_colors() {
38 +function openstation_notes_colors() {
44 39 $colors = array( 'butter', 'blush', 'sky', 'mint', 'lilac', 'peach' );
45 40
46 41 /**
47 42 * Filters the allowed pinned-note paper colors.
@@ -50,13 +45,11 @@
50 45 * (`--dm-note-paper` / `--dm-note-paper-deep` / `--dm-note-ink`)
51 46 * for a `[data-note-color="<slug>"]` selector, otherwise notes
52 47 * using them render with the fallback (butter) paper.
53 48 *
54 - * @since 0.9.6
55 - *
56 49 * @param string[] $colors Allowed color slugs.
57 50 */
58 - $colors = apply_filters( 'desktop_mode_notes_colors', $colors );
51 + $colors = apply_filters( 'openstation_notes_colors', $colors );
59 52
60 53 return array_values( array_filter( array_map( 'sanitize_key', (array) $colors ) ) );
61 54 }
62 55
@@ -61,14 +54,12 @@
61 54 }
62 55
63 56 /**
64 57 * Register the `wpd_note` post type + its meta.
65 - *
66 - * @since 0.9.6
67 58 */
68 -function desktop_mode_notes_register_cpt() {
59 +function openstation_notes_register_cpt() {
69 60 register_post_type(
70 - DESKTOP_MODE_NOTES_POST_TYPE,
61 + OPENSTATION_NOTES_POST_TYPE,
71 62 array(
72 63 'label' => __( 'Desktop Notes', 'desktop-mode' ),
73 64 'public' => false,
74 65 'publicly_queryable' => false,
@@ -85,42 +76,42 @@
85 76 )
86 77 );
87 78
88 79 register_post_meta(
89 - DESKTOP_MODE_NOTES_POST_TYPE,
80 + OPENSTATION_NOTES_POST_TYPE,
90 81 '_wpd_note_color',
91 82 array(
92 83 'type' => 'string',
93 84 'single' => true,
94 85 'default' => 'butter',
95 - 'sanitize_callback' => 'desktop_mode_notes_sanitize_color',
86 + 'sanitize_callback' => 'openstation_notes_sanitize_color',
96 87 )
97 88 );
98 89
99 90 register_post_meta(
100 - DESKTOP_MODE_NOTES_POST_TYPE,
91 + OPENSTATION_NOTES_POST_TYPE,
101 92 '_wpd_note_x',
102 93 array(
103 94 'type' => 'number',
104 95 'single' => true,
105 96 'default' => 0.1,
106 - 'sanitize_callback' => 'desktop_mode_notes_sanitize_fraction',
97 + 'sanitize_callback' => 'openstation_notes_sanitize_fraction',
107 98 )
108 99 );
109 100
110 101 register_post_meta(
111 - DESKTOP_MODE_NOTES_POST_TYPE,
102 + OPENSTATION_NOTES_POST_TYPE,
112 103 '_wpd_note_y',
113 104 array(
114 105 'type' => 'number',
115 106 'single' => true,
116 107 'default' => 0.1,
117 - 'sanitize_callback' => 'desktop_mode_notes_sanitize_fraction',
108 + 'sanitize_callback' => 'openstation_notes_sanitize_fraction',
118 109 )
119 110 );
120 111
121 112 register_post_meta(
122 - DESKTOP_MODE_NOTES_POST_TYPE,
113 + OPENSTATION_NOTES_POST_TYPE,
123 114 '_wpd_note_z',
124 115 array(
125 116 'type' => 'integer',
126 117 'single' => true,
@@ -131,9 +122,9 @@
131 122
132 123 // Jitter seed — hashed from the note's text once at CREATION and
133 124 // never rewritten, so the paper's subtle tilt survives edits.
134 125 register_post_meta(
135 - DESKTOP_MODE_NOTES_POST_TYPE,
126 + OPENSTATION_NOTES_POST_TYPE,
136 127 '_wpd_note_seed',
137 128 array(
138 129 'type' => 'integer',
139 130 'single' => true,
@@ -141,21 +132,19 @@
141 132 'sanitize_callback' => 'absint',
142 133 )
143 134 );
144 135 }
145 -add_action( 'init', 'desktop_mode_notes_register_cpt' );
136 +add_action( 'init', 'openstation_notes_register_cpt' );
146 137
147 138 /**
148 139 * Clamp a note color to the allowed pastel whitelist.
149 140 *
150 - * @since 0.9.6
151 - *
152 141 * @param mixed $color Raw value.
153 142 * @return string Whitelisted slug (falls back to 'butter').
154 143 */
155 -function desktop_mode_notes_sanitize_color( $color ) {
144 +function openstation_notes_sanitize_color( $color ) {
156 145 $color = is_scalar( $color ) ? sanitize_key( (string) $color ) : '';
157 - $colors = desktop_mode_notes_colors();
146 + $colors = openstation_notes_colors();
158 147 if ( in_array( $color, $colors, true ) ) {
159 148 return $color;
160 149 }
161 150 return isset( $colors[0] ) ? $colors[0] : 'butter';
@@ -163,14 +152,12 @@
163 152
164 153 /**
165 154 * Clamp a note position coordinate to the normalized 0–1 range.
166 155 *
167 - * @since 0.9.6
168 - *
169 156 * @param mixed $value Raw value.
170 157 * @return float
171 158 */
172 -function desktop_mode_notes_sanitize_fraction( $value ) {
159 +function openstation_notes_sanitize_fraction( $value ) {
173 160 return (float) min( 1, max( 0, (float) $value ) );
174 161 }
175 162
176 163 /**
@@ -179,17 +166,15 @@
179 166 * Core's default untrash status is 'draft', which would silently flip
180 167 * a public note private (and make it invisible to its own list query,
181 168 * which only looks at private + publish). Restore what the note was.
182 169 *
183 - * @since 0.9.6
184 - *
185 170 * @param string $new_status Status the post is about to get.
186 171 * @param int $post_id Post ID.
187 172 * @param string $previous_status Status the post had before trashing.
188 173 * @return string
189 174 */
190 -function desktop_mode_notes_untrash_status( $new_status, $post_id, $previous_status ) {
191 - if ( DESKTOP_MODE_NOTES_POST_TYPE !== get_post_type( $post_id ) ) {
175 +function openstation_notes_untrash_status( $new_status, $post_id, $previous_status ) {
176 + if ( OPENSTATION_NOTES_POST_TYPE !== get_post_type( $post_id ) ) {
192 177 return $new_status;
193 178 }
194 179 if ( in_array( $previous_status, array( 'private', 'publish' ), true ) ) {
195 180 return $previous_status;
@@ -195,5 +180,5 @@
195 180 return $previous_status;
196 181 }
197 182 return 'private';
198 183 }
199 -add_filter( 'wp_untrash_post_status', 'desktop_mode_notes_untrash_status', 10, 3 );
184 +add_filter( 'wp_untrash_post_status', 'openstation_notes_untrash_status', 10, 3 );