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/my-wordpress/lock.php +22 -27 0.9.81.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — My WordPress: post-lock REST field.
3 + * OpenStation — My WordPress: post-lock REST field.
4 4 *
5 5 * Surfaces "is this post currently being edited by someone else?"
6 6 * on every post / page / opt-in CPT REST response so the My WordPress
7 7 * file-explorer can show a lock icon + the locking user's name on
@@ -14,15 +14,15 @@
14 14 * We expose the same intelligence as a structured field, gated on
15 15 * `edit_post` so users who can't edit the post never see who else is
16 16 * editing it.
17 17 *
18 - * The field name is `desktop_mode_lock`; shape:
18 + * The field name is `openstation_lock`; shape:
19 19 *
20 20 * - `null` — not locked, OR the requester lacks edit caps.
21 21 * - `{ userId, userName, userAvatarUrl, time }` — locked by another
22 22 * user. `time` is the ISO-8601 timestamp of the lock heartbeat.
23 23 *
24 - * @package WPDesktopMode
24 + * @package OpenStation
25 25 */
26 26
27 27 defined( 'ABSPATH' ) || exit;
28 28
@@ -36,9 +36,9 @@
36 36 *
37 37 * @param int $post_id Post id.
38 38 * @return array{userId:int,userName:string,userAvatarUrl:string,time:string}|null
39 39 */
40 -function desktop_mode_my_wordpress_post_lock_payload( $post_id ) {
40 +function openstation_my_wordpress_post_lock_payload( $post_id ) {
41 41 $post_id = (int) $post_id;
42 42 if ( $post_id <= 0 ) {
43 43 return null;
44 44 }
@@ -91,9 +91,9 @@
91 91 * 3. The `_edit_last` post meta — who saved the post most
92 92 * recently; the only signal on installs with revisions
93 93 * disabled.
94 94 * 4. Anything plugins return from the
95 - * `desktop_mode_my_wordpress_post_contributors` filter, which
95 + * `openstation_my_wordpress_post_contributors` filter, which
96 96 * receives the post id + the running user-id list. Filter
97 97 * contract is plain int[] for ergonomics; we expand each id
98 98 * into the structured shape afterwards.
99 99 *
@@ -107,9 +107,9 @@
107 107 *
108 108 * @param int $post_id Post id.
109 109 * @return array<int,array{userId:int,userName:string,userAvatarUrl:string}>
110 110 */
111 -function desktop_mode_my_wordpress_post_contributors_payload( $post_id ) {
111 +function openstation_my_wordpress_post_contributors_payload( $post_id ) {
112 112 $post_id = (int) $post_id;
113 113 if ( $post_id <= 0 ) {
114 114 return array();
115 115 }
@@ -187,9 +187,9 @@
187 187 * Examples:
188 188 *
189 189 * ```php
190 190 * // ACF user-list field "post_contributors":
191 - * add_filter( 'desktop_mode_my_wordpress_post_contributors',
191 + * add_filter( 'openstation_my_wordpress_post_contributors',
192 192 * function ( $ids, $post_id ) {
193 193 * $extra = (array) get_field( 'post_contributors', $post_id );
194 194 * foreach ( $extra as $u ) {
195 195 * if ( $u instanceof WP_User ) {
@@ -205,9 +205,9 @@
205 205 * @param int[] $ids Contributor user ids gathered so far
206 206 * (from Co-Authors Plus, etc.).
207 207 * @param int $post_id Post id.
208 208 */
209 - $ids = (array) apply_filters( 'desktop_mode_my_wordpress_post_contributors', $ids, $post_id );
209 + $ids = (array) apply_filters( 'openstation_my_wordpress_post_contributors', $ids, $post_id );
210 210
211 211 // De-duplicate, drop the primary author so the Contributors
212 212 // sub-folder only carries *additional* people, drop empty/0,
213 213 // and resolve to user records.
@@ -239,34 +239,29 @@
239 239 return $out;
240 240 }
241 241
242 242 /**
243 - * Register the REST fields on every public post type that runs
244 - * through the standard `/wp/v2/<type>` endpoint. Posts and pages
245 - * cover the Phase 1 surface; CPTs come along for free.
243 + * Register the REST fields on every post type the site window can
244 + * browse — public REST-exposed types plus the ones bridged under
245 + * `desktop-mode/v1`. Posts and pages cover the Phase 1 surface; CPTs
246 + * come along for free.
246 247 *
247 248 * Two fields:
248 - * - `desktop_mode_lock` — active edit-lock holder.
249 - * - `desktop_mode_contributors` — additional contributor users
249 + * - `openstation_lock` — active edit-lock holder.
250 + * - `openstation_contributors` — additional contributor users
250 251 * beyond the primary author.
251 252 */
252 -function desktop_mode_my_wordpress_register_lock_field() {
253 - $types = get_post_types(
254 - array(
255 - 'show_in_rest' => true,
256 - 'public' => true,
257 - ),
258 - 'names'
259 - );
253 +function openstation_my_wordpress_register_lock_field() {
254 + $types = openstation_my_wordpress_rest_field_post_types();
260 255
261 256 foreach ( $types as $type ) {
262 257 register_rest_field(
263 258 $type,
264 - 'desktop_mode_lock',
259 + 'openstation_lock',
265 260 array(
266 261 'get_callback' => static function ( $post ) {
267 262 $post_id = isset( $post['id'] ) ? (int) $post['id'] : 0;
268 - return desktop_mode_my_wordpress_post_lock_payload( $post_id );
263 + return openstation_my_wordpress_post_lock_payload( $post_id );
269 264 },
270 265 'schema' => array(
271 266 'description' => __( 'Active edit-lock holder, or null when the post is not locked.', 'desktop-mode' ),
272 267 'type' => array( 'object', 'null' ),
@@ -283,16 +278,16 @@
283 278 );
284 279
285 280 register_rest_field(
286 281 $type,
287 - 'desktop_mode_contributors',
282 + 'openstation_contributors',
288 283 array(
289 284 'get_callback' => static function ( $post ) {
290 285 $post_id = isset( $post['id'] ) ? (int) $post['id'] : 0;
291 - return desktop_mode_my_wordpress_post_contributors_payload( $post_id );
286 + return openstation_my_wordpress_post_contributors_payload( $post_id );
292 287 },
293 288 'schema' => array(
294 - 'description' => __( 'Additional contributor users beyond the primary author. Sourced from Co-Authors Plus when present, revision authors, the `_edit_last` meta, plus anything plugins return via `desktop_mode_my_wordpress_post_contributors`. Empty for requesters who cannot edit the post.', 'desktop-mode' ),
289 + 'description' => __( 'Additional contributor users beyond the primary author. Sourced from Co-Authors Plus when present, revision authors, the `_edit_last` meta, plus anything plugins return via `openstation_my_wordpress_post_contributors`. Empty for requesters who cannot edit the post.', 'desktop-mode' ),
295 290 'type' => 'array',
296 291 'context' => array( 'view', 'edit' ),
297 292 'readonly' => true,
298 293 'items' => array(
@@ -307,5 +302,5 @@
307 302 )
308 303 );
309 304 }
310 305 }
311 -add_action( 'rest_api_init', 'desktop_mode_my_wordpress_register_lock_field' );
306 +add_action( 'rest_api_init', 'openstation_my_wordpress_register_lock_field' );