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/desktop-files/trash.php +160 -215 0.9.61.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Files-on-the-Desktop trash + restore + purge.
3 + * OpenStation — Files-on-the-Desktop trash + restore + purge.
4 4 *
5 5 * Both placements and folders soft-trash before they ever hit the
6 6 * physical row delete. Trashed rows live in the same tables (with
7 7 * `trashed_at_ms` / `trashed_by` columns set; `trashed_via_folder`
@@ -19,25 +19,25 @@
19 19 *
20 20 * - Veto any trash / restore / purge (`*_user_can_*` filters).
21 21 * - Observe any state transition (`*_before_*` / `*_after_*`).
22 22 * - React to recycle-bin list / restore / purge of the new types
23 - * via the existing recycle-bin hooks (`desktop_mode_recycle_bin_*`).
23 + * via the existing recycle-bin hooks (`openstation_recycle_bin_*`).
24 24 *
25 - * @package WPDesktopMode
26 - * @since 0.8.0
25 + * @package OpenStation
27 26 */
28 27
29 28 defined( 'ABSPATH' ) || exit;
30 29
31 -/* ================================================================== *
30 +/*
31 +================================================================== *
32 32 * Capability gates.
33 - * ================================================================== */
33 + * ==================================================================
34 + */
34 35
35 36 /**
36 37 * Default ownership check shared by every trash / restore / purge
37 38 * capability gate: the acting user must be the row's `owner_id`.
38 39 *
39 - * @since 0.8.0
40 40 * @access private
41 41 *
42 42 * @param int $user_id Acting user.
43 43 * @param array $row Placement or folder row.
@@ -42,9 +42,9 @@
42 42 * @param int $user_id Acting user.
43 43 * @param array $row Placement or folder row.
44 44 * @return bool
45 45 */
46 -function desktop_mode_files_user_owns_row( $user_id, $row ) {
46 +function openstation_files_user_owns_row( $user_id, $row ) {
47 47 $user_id = (int) $user_id;
48 48 return ( $user_id > 0 )
49 49 && isset( $row['owner_id'] )
50 50 && (int) $row['owner_id'] === $user_id;
@@ -53,27 +53,23 @@
53 53 /**
54 54 * Whether the given user can trash a placement they own. Defaults
55 55 * to ownership; plugins can broaden via filter.
56 56 *
57 - * @since 0.8.0
58 - *
59 57 * @param int $user_id Acting user.
60 58 * @param array $row Placement row (raw from DB or normalized).
61 59 * @return bool
62 60 */
63 -function desktop_mode_files_user_can_trash_placement( $user_id, $row ) {
61 +function openstation_files_user_can_trash_placement( $user_id, $row ) {
64 62 /**
65 63 * Filter whether the user can trash this placement.
66 64 *
67 - * @since 0.8.0
68 - *
69 65 * @param bool $can Default: ownership match.
70 66 * @param int $user_id Acting user.
71 67 * @param array $row Placement row.
72 68 */
73 69 return (bool) apply_filters(
74 - 'desktop_mode_files_user_can_trash_placement',
75 - desktop_mode_files_user_owns_row( $user_id, $row ),
70 + 'openstation_files_user_can_trash_placement',
71 + openstation_files_user_owns_row( $user_id, $row ),
76 72 (int) $user_id,
77 73 $row
78 74 );
79 75 }
@@ -80,25 +76,21 @@
80 76
81 77 /**
82 78 * Whether the given user can restore a trashed placement.
83 79 *
84 - * @since 0.8.0
85 - *
86 80 * @param int $user_id Acting user.
87 81 * @param array $row Placement row (already trashed).
88 82 * @return bool
89 83 */
90 -function desktop_mode_files_user_can_restore_placement( $user_id, $row ) {
84 +function openstation_files_user_can_restore_placement( $user_id, $row ) {
91 85 /**
92 - * @since 0.8.0
93 - *
94 86 * @param bool $can
95 87 * @param int $user_id
96 88 * @param array $row
97 89 */
98 90 return (bool) apply_filters(
99 - 'desktop_mode_files_user_can_restore_placement',
100 - desktop_mode_files_user_owns_row( $user_id, $row ),
91 + 'openstation_files_user_can_restore_placement',
92 + openstation_files_user_owns_row( $user_id, $row ),
101 93 (int) $user_id,
102 94 $row
103 95 );
104 96 }
@@ -104,22 +96,18 @@
104 96 }
105 97
106 98 /**
107 99 * Whether the given user can permanently purge a trashed placement.
108 - *
109 - * @since 0.8.0
110 100 */
111 -function desktop_mode_files_user_can_purge_placement( $user_id, $row ) {
101 +function openstation_files_user_can_purge_placement( $user_id, $row ) {
112 102 /**
113 - * @since 0.8.0
114 - *
115 103 * @param bool $can
116 104 * @param int $user_id
117 105 * @param array $row
118 106 */
119 107 return (bool) apply_filters(
120 - 'desktop_mode_files_user_can_purge_placement',
121 - desktop_mode_files_user_owns_row( $user_id, $row ),
108 + 'openstation_files_user_can_purge_placement',
109 + openstation_files_user_owns_row( $user_id, $row ),
122 110 (int) $user_id,
123 111 $row
124 112 );
125 113 }
@@ -125,22 +113,18 @@
125 113 }
126 114
127 115 /**
128 116 * Whether the given user can trash a folder. Default: folder owner.
129 - *
130 - * @since 0.8.0
131 117 */
132 -function desktop_mode_files_user_can_trash_folder( $user_id, $row ) {
118 +function openstation_files_user_can_trash_folder( $user_id, $row ) {
133 119 /**
134 - * @since 0.8.0
135 - *
136 120 * @param bool $can
137 121 * @param int $user_id
138 122 * @param array $row
139 123 */
140 124 return (bool) apply_filters(
141 - 'desktop_mode_files_user_can_trash_folder',
142 - desktop_mode_files_user_owns_row( $user_id, $row ),
125 + 'openstation_files_user_can_trash_folder',
126 + openstation_files_user_owns_row( $user_id, $row ),
143 127 (int) $user_id,
144 128 $row
145 129 );
146 130 }
@@ -146,22 +130,18 @@
146 130 }
147 131
148 132 /**
149 133 * Whether the given user can restore a trashed folder.
150 - *
151 - * @since 0.8.0
152 134 */
153 -function desktop_mode_files_user_can_restore_folder( $user_id, $row ) {
135 +function openstation_files_user_can_restore_folder( $user_id, $row ) {
154 136 /**
155 - * @since 0.8.0
156 - *
157 137 * @param bool $can
158 138 * @param int $user_id
159 139 * @param array $row
160 140 */
161 141 return (bool) apply_filters(
162 - 'desktop_mode_files_user_can_restore_folder',
163 - desktop_mode_files_user_owns_row( $user_id, $row ),
142 + 'openstation_files_user_can_restore_folder',
143 + openstation_files_user_owns_row( $user_id, $row ),
164 144 (int) $user_id,
165 145 $row
166 146 );
167 147 }
@@ -167,28 +147,25 @@
167 147 }
168 148
169 149 /**
170 150 * Whether the given user can permanently purge a trashed folder.
171 - *
172 - * @since 0.8.0
173 151 */
174 -function desktop_mode_files_user_can_purge_folder( $user_id, $row ) {
152 +function openstation_files_user_can_purge_folder( $user_id, $row ) {
175 153 /**
176 - * @since 0.8.0
177 - *
178 154 * @param bool $can
179 155 * @param int $user_id
180 156 * @param array $row
181 157 */
182 158 return (bool) apply_filters(
183 - 'desktop_mode_files_user_can_purge_folder',
184 - desktop_mode_files_user_owns_row( $user_id, $row ),
159 + 'openstation_files_user_can_purge_folder',
160 + openstation_files_user_owns_row( $user_id, $row ),
185 161 (int) $user_id,
186 162 $row
187 163 );
188 164 }
189 165
190 -/* ================================================================== *
166 +/*
167 +================================================================== *
191 168 * Ancestry snapshot + resurrection.
192 169 *
193 170 * When a placement is soft-trashed we capture every folder in
194 171 * its parent chain into a JSON blob on `placements.trashed_meta`.
@@ -196,9 +173,10 @@
196 173 * still alive are reused, trashed folders cascade-restore, and
197 174 * hard-deleted folders are recreated (with new ids; the chain is
198 175 * rewritten as it walks). The placement comes back at the same
199 176 * visual position inside the (possibly resurrected) parent.
200 - * ================================================================== */
177 + * ==================================================================
178 + */
201 179
202 180 /**
203 181 * Walk up `$parent_id` through the folders + placements tables and
204 182 * return the parent chain root-first.
@@ -217,16 +195,14 @@
217 195 * )
218 196 *
219 197 * Returns `[]` for a root-level placement (`$parent_id === 0`).
220 198 *
221 - * @since 0.8.0
222 - *
223 199 * @param int $parent_id Immediate parent folder id.
224 200 * @return array<int, array<string, mixed>>
225 201 */
226 -function desktop_mode_files_capture_ancestry( $parent_id ) {
202 +function openstation_files_capture_ancestry( $parent_id ) {
227 203 global $wpdb;
228 - $tables = desktop_mode_files_table_names();
204 + $tables = openstation_files_table_names();
229 205 $chain = array();
230 206 $cursor = (int) $parent_id;
231 207 $guard = 0; // depth-bound — defends against accidental cycles.
232 208 while ( $cursor > 0 && $guard < 32 ) {
@@ -243,9 +219,9 @@
243 219 }
244 220 // The folder's "where I sit on the desktop tree" lives on
245 221 // its placement row. Pick any active or trashed placement
246 222 // of this folder — we just need its parent_id + (x, y).
247 - $placement = $wpdb->get_row(
223 + $placement = $wpdb->get_row(
248 224 $wpdb->prepare(
249 225 "SELECT parent_id, x, y FROM {$tables['placements']}
250 226 WHERE file_type = 'folder' AND file_ref = %s
251 227 ORDER BY id ASC LIMIT 1",
@@ -254,9 +230,9 @@
254 230 ARRAY_A
255 231 );
256 232 $share_meta_raw = isset( $folder['share_meta'] ) ? (string) $folder['share_meta'] : '';
257 233 $share_meta = '' !== $share_meta_raw ? json_decode( $share_meta_raw, true ) : null;
258 - $entry = array(
234 + $entry = array(
259 235 'folder_id' => (int) $folder['id'],
260 236 'folder_name' => (string) $folder['name'],
261 237 'folder_share_mode' => (string) $folder['share_mode'],
262 238 'folder_share_meta' => is_array( $share_meta ) ? $share_meta : null,
@@ -278,10 +254,8 @@
278 254 * downstream entries rewrite their `placement_parent_id` so a
279 255 * deeper folder lands inside the correct (possibly recreated)
280 256 * parent.
281 257 *
282 - * @since 0.8.0
283 - *
284 258 * @param int $user_id Acting user (used as owner for any
285 259 * recreated folder).
286 260 * @param array $ancestry Root-first chain captured at trash time.
287 261 * @return int Resolved leaf parent id (0 when the placement was
@@ -286,9 +260,9 @@
286 260 * @param array $ancestry Root-first chain captured at trash time.
287 261 * @return int Resolved leaf parent id (0 when the placement was
288 262 * at desktop root).
289 263 */
290 -function desktop_mode_files_resurrect_ancestry( $user_id, $ancestry ) {
264 +function openstation_files_resurrect_ancestry( $user_id, $ancestry ) {
291 265 if ( empty( $ancestry ) ) {
292 266 return 0;
293 267 }
294 268 $user_id = (int) $user_id;
@@ -302,15 +276,15 @@
302 276 $resolved_parent = isset( $id_map[ $orig_par ] )
303 277 ? (int) $id_map[ $orig_par ]
304 278 : $orig_par;
305 279
306 - $folder = desktop_mode_files_get_folder( $orig_id, true );
280 + $folder = openstation_files_get_folder( $orig_id, true );
307 281 if ( $folder ) {
308 282 // Folder still exists. If trashed, restore it (cascade
309 283 // brings back its own children that were trashed via
310 284 // folder cascade).
311 285 if ( ! empty( $folder['trashed_at_ms'] ) ) {
312 - desktop_mode_files_restore_folder( $user_id, $orig_id );
286 + openstation_files_restore_folder( $user_id, $orig_id );
313 287 }
314 288 $id_map[ $orig_id ] = $orig_id;
315 289 $resolved = $orig_id;
316 290 continue;
@@ -319,23 +293,26 @@
319 293 // Folder is gone — recreate it and place it under the
320 294 // resolved parent. Owner falls back to the acting user
321 295 // when the original owner can't be inferred (shared-
322 296 // folder edge case Phase 6 will revisit).
323 - $owner_id = (int) ( $entry['folder_owner_id'] ?: $user_id );
324 - $new_id = desktop_mode_files_create_folder( $owner_id, array(
325 - 'name' => (string) $entry['folder_name'],
326 - 'share_mode' => (string) $entry['folder_share_mode'],
327 - 'share_meta' => $entry['folder_share_meta'],
328 - ) );
297 + $owner_id = (int) ( $entry['folder_owner_id'] ? $entry['folder_owner_id'] : $user_id );
298 + $new_id = openstation_files_create_folder(
299 + $owner_id,
300 + array(
301 + 'name' => (string) $entry['folder_name'],
302 + 'share_mode' => (string) $entry['folder_share_mode'],
303 + 'share_meta' => $entry['folder_share_meta'],
304 + )
305 + );
329 306 if ( is_wp_error( $new_id ) ) {
330 307 // Fall back to root — restoring at the wrong place is
331 308 // strictly better than failing the restore outright.
332 - $resolved = $resolved_parent;
309 + $resolved = $resolved_parent;
333 310 $id_map[ $orig_id ] = $resolved;
334 311 continue;
335 312 }
336 313 // Place the recreated folder where the snapshot says.
337 - desktop_mode_files_place(
314 + openstation_files_place(
338 315 $user_id,
339 316 $resolved_parent,
340 317 'folder',
341 318 (string) $new_id,
@@ -349,11 +326,13 @@
349 326 }
350 327 return $resolved;
351 328 }
352 329
353 -/* ================================================================== *
330 +/*
331 +================================================================== *
354 332 * Placement: trash / restore / purge.
355 - * ================================================================== */
333 + * ==================================================================
334 + */
356 335
357 336 /**
358 337 * Soft-trash a placement. Sets `trashed_at_ms`, `trashed_by`. Returns
359 338 * `true` on success, `WP_Error` on permission failure / missing row.
@@ -360,19 +339,17 @@
360 339 *
361 340 * Idempotent: trashing an already-trashed placement is a no-op
362 341 * success.
363 342 *
364 - * @since 0.8.0
365 - *
366 343 * @param int $user_id Acting user.
367 344 * @param int $placement_id Placement id.
368 345 * @return true|WP_Error
369 346 */
370 -function desktop_mode_files_trash_placement( $user_id, $placement_id ) {
347 +function openstation_files_trash_placement( $user_id, $placement_id ) {
371 348 global $wpdb;
372 349 $user_id = (int) $user_id;
373 350 $placement_id = (int) $placement_id;
374 - $tables = desktop_mode_files_table_names();
351 + $tables = openstation_files_table_names();
375 352
376 353 $row = $wpdb->get_row(
377 354 $wpdb->prepare(
378 355 "SELECT * FROM {$tables['placements']} WHERE id = %d",
@@ -381,9 +358,9 @@
381 358 ARRAY_A
382 359 );
383 360 if ( ! $row ) {
384 361 return new WP_Error(
385 - 'desktop_mode_files_placement_not_found',
362 + 'openstation_files_placement_not_found',
386 363 __( 'Placement not found.', 'desktop-mode' ),
387 364 array( 'status' => 404 )
388 365 );
389 366 }
@@ -389,11 +366,11 @@
389 366 }
390 367 if ( null !== $row['trashed_at_ms'] && '' !== $row['trashed_at_ms'] ) {
391 368 return true;
392 369 }
393 - if ( ! desktop_mode_files_user_can_trash_placement( $user_id, $row ) ) {
370 + if ( ! openstation_files_user_can_trash_placement( $user_id, $row ) ) {
394 371 return new WP_Error(
395 - 'desktop_mode_files_forbidden',
372 + 'openstation_files_forbidden',
396 373 __( 'You do not have permission to trash this item.', 'desktop-mode' ),
397 374 array( 'status' => 403 )
398 375 );
399 376 }
@@ -400,18 +377,16 @@
400 377
401 378 /**
402 379 * Fires before a placement is trashed.
403 380 *
404 - * @since 0.8.0
405 - *
406 381 * @param int $placement_id Placement id.
407 382 * @param int $user_id Acting user.
408 383 * @param array $row Placement row.
409 384 */
410 - do_action( 'desktop_mode_files_before_trash_placement', $placement_id, $user_id, $row );
385 + do_action( 'openstation_files_before_trash_placement', $placement_id, $user_id, $row );
411 386
412 - $now = desktop_mode_files_now_ms();
413 - $ancestry = desktop_mode_files_capture_ancestry( (int) $row['parent_id'] );
387 + $now = openstation_files_now_ms();
388 + $ancestry = openstation_files_capture_ancestry( (int) $row['parent_id'] );
414 389 $meta = wp_json_encode( array( 'ancestry' => $ancestry ) );
415 390 $result = $wpdb->update(
416 391 $tables['placements'],
417 392 array(
@@ -430,9 +405,9 @@
430 405 // 200 OK and the UI would show "moved to trash" with nothing
431 406 // actually trashed.
432 407 if ( false === $result ) {
433 408 return new WP_Error(
434 - 'desktop_mode_files_trash_failed',
409 + 'openstation_files_trash_failed',
435 410 isset( $wpdb->last_error ) && $wpdb->last_error
436 411 ? (string) $wpdb->last_error
437 412 : __( 'Failed to write trash row.', 'desktop-mode' ),
438 413 array( 'status' => 500 )
@@ -441,14 +416,12 @@
441 416
442 417 /**
443 418 * Fires after a placement is trashed.
444 419 *
445 - * @since 0.8.0
446 - *
447 420 * @param int $placement_id Placement id.
448 421 * @param int $user_id Acting user.
449 422 */
450 - do_action( 'desktop_mode_files_after_trash_placement', $placement_id, $user_id );
423 + do_action( 'openstation_files_after_trash_placement', $placement_id, $user_id );
451 424
452 425 return true;
453 426 }
454 427
@@ -454,19 +427,17 @@
454 427
455 428 /**
456 429 * Restore a trashed placement back to its original folder + (x, y).
457 430 *
458 - * @since 0.8.0
459 - *
460 431 * @param int $user_id Acting user.
461 432 * @param int $placement_id Placement id.
462 433 * @return true|WP_Error
463 434 */
464 -function desktop_mode_files_restore_placement( $user_id, $placement_id ) {
435 +function openstation_files_restore_placement( $user_id, $placement_id ) {
465 436 global $wpdb;
466 437 $user_id = (int) $user_id;
467 438 $placement_id = (int) $placement_id;
468 - $tables = desktop_mode_files_table_names();
439 + $tables = openstation_files_table_names();
469 440
470 441 $row = $wpdb->get_row(
471 442 $wpdb->prepare(
472 443 "SELECT * FROM {$tables['placements']} WHERE id = %d",
@@ -475,9 +446,9 @@
475 446 ARRAY_A
476 447 );
477 448 if ( ! $row ) {
478 449 return new WP_Error(
479 - 'desktop_mode_files_placement_not_found',
450 + 'openstation_files_placement_not_found',
480 451 __( 'Placement not found.', 'desktop-mode' ),
481 452 array( 'status' => 404 )
482 453 );
483 454 }
@@ -483,11 +454,11 @@
483 454 }
484 455 if ( null === $row['trashed_at_ms'] || '' === $row['trashed_at_ms'] ) {
485 456 return true; // Already active — idempotent.
486 457 }
487 - if ( ! desktop_mode_files_user_can_restore_placement( $user_id, $row ) ) {
458 + if ( ! openstation_files_user_can_restore_placement( $user_id, $row ) ) {
488 459 return new WP_Error(
489 - 'desktop_mode_files_forbidden',
460 + 'openstation_files_forbidden',
490 461 __( 'You do not have permission to restore this item.', 'desktop-mode' ),
491 462 array( 'status' => 403 )
492 463 );
493 464 }
@@ -492,24 +463,24 @@
492 463 );
493 464 }
494 465
495 466 // Resolve the parent folder. Three branches:
496 - // - parent is alive → reuse the same id
497 - // - parent is trashed → cascade-restore it (and rest of the
498 - // chain) before placing the leaf
499 - // - parent is gone → walk the captured ancestry and
500 - // recreate every missing folder in
501 - // the chain
467 + // - parent is alive → reuse the same id
468 + // - parent is trashed → cascade-restore it (and rest of the
469 + // chain) before placing the leaf
470 + // - parent is gone → walk the captured ancestry and
471 + // recreate every missing folder in
472 + // the chain
502 473 $original_parent_id = (int) $row['parent_id'];
503 474 $resolved_parent_id = $original_parent_id;
504 475 if ( $original_parent_id > 0 ) {
505 - $parent_alive = desktop_mode_files_get_folder( $original_parent_id, true );
476 + $parent_alive = openstation_files_get_folder( $original_parent_id, true );
506 477 if ( $parent_alive ) {
507 478 if ( ! empty( $parent_alive['trashed_at_ms'] ) ) {
508 479 // Cascade restore — reach into the snapshot the
509 480 // folder itself stored at trash time so any chain
510 481 // above it is also resurrected.
511 - $folder_restore = desktop_mode_files_restore_folder( $user_id, $original_parent_id );
482 + $folder_restore = openstation_files_restore_folder( $user_id, $original_parent_id );
512 483 if ( is_wp_error( $folder_restore ) ) {
513 484 return $folder_restore;
514 485 }
515 486 }
@@ -516,14 +487,14 @@
516 487 $resolved_parent_id = $original_parent_id;
517 488 } else {
518 489 // Hard-deleted parent — read the ancestry snapshot we
519 490 // stored at trash time and resurrect the chain.
520 - $meta_raw = isset( $row['trashed_meta'] ) ? (string) $row['trashed_meta'] : '';
521 - $decoded = '' !== $meta_raw ? json_decode( $meta_raw, true ) : null;
522 - $ancestry = ( is_array( $decoded ) && isset( $decoded['ancestry'] ) && is_array( $decoded['ancestry'] ) )
491 + $meta_raw = isset( $row['trashed_meta'] ) ? (string) $row['trashed_meta'] : '';
492 + $decoded = '' !== $meta_raw ? json_decode( $meta_raw, true ) : null;
493 + $ancestry = ( is_array( $decoded ) && isset( $decoded['ancestry'] ) && is_array( $decoded['ancestry'] ) )
523 494 ? $decoded['ancestry']
524 495 : array();
525 - $resolved_parent_id = desktop_mode_files_resurrect_ancestry( $user_id, $ancestry );
496 + $resolved_parent_id = openstation_files_resurrect_ancestry( $user_id, $ancestry );
526 497 }
527 498 }
528 499
529 500 /**
@@ -528,15 +499,13 @@
528 499
529 500 /**
530 501 * Fires before a placement is restored.
531 502 *
532 - * @since 0.8.0
533 - *
534 503 * @param int $placement_id
535 504 * @param int $user_id
536 505 * @param array $row
537 506 */
538 - do_action( 'desktop_mode_files_before_restore_placement', $placement_id, $user_id, $row );
507 + do_action( 'openstation_files_before_restore_placement', $placement_id, $user_id, $row );
539 508
540 509 $wpdb->update(
541 510 $tables['placements'],
542 511 array(
@@ -544,9 +513,9 @@
544 513 'trashed_at_ms' => null,
545 514 'trashed_by' => null,
546 515 'trashed_via_folder' => null,
547 516 'trashed_meta' => null,
548 - 'updated_at_ms' => desktop_mode_files_now_ms(),
517 + 'updated_at_ms' => openstation_files_now_ms(),
549 518 ),
550 519 array( 'id' => $placement_id ),
551 520 array( '%d', null, null, null, null, '%d' ),
552 521 array( '%d' )
@@ -556,17 +525,15 @@
556 525 // a placement coming back to life must not carry lingering
557 526 // tombstones from an earlier (reversible) removal. Without this,
558 527 // every heartbeat tick would re-deliver those tombstones to the
559 528 // client and the row would flicker off the desktop on each tick.
560 - desktop_mode_files_clear_tombstones_for( 'placement', $placement_id );
529 + openstation_files_clear_tombstones_for( 'placement', $placement_id );
561 530
562 531 /**
563 - * @since 0.8.0
564 - *
565 532 * @param int $placement_id
566 533 * @param int $user_id
567 534 */
568 - do_action( 'desktop_mode_files_after_restore_placement', $placement_id, $user_id );
535 + do_action( 'openstation_files_after_restore_placement', $placement_id, $user_id );
569 536
570 537 return true;
571 538 }
572 539
@@ -572,19 +539,17 @@
572 539
573 540 /**
574 541 * Permanently delete a trashed placement.
575 542 *
576 - * @since 0.8.0
577 - *
578 543 * @param int $user_id
579 544 * @param int $placement_id
580 545 * @return true|WP_Error
581 546 */
582 -function desktop_mode_files_purge_placement( $user_id, $placement_id ) {
547 +function openstation_files_purge_placement( $user_id, $placement_id ) {
583 548 global $wpdb;
584 549 $user_id = (int) $user_id;
585 550 $placement_id = (int) $placement_id;
586 - $tables = desktop_mode_files_table_names();
551 + $tables = openstation_files_table_names();
587 552
588 553 $row = $wpdb->get_row(
589 554 $wpdb->prepare(
590 555 "SELECT * FROM {$tables['placements']} WHERE id = %d",
@@ -594,11 +559,11 @@
594 559 );
595 560 if ( ! $row ) {
596 561 return true; // Already gone — idempotent.
597 562 }
598 - if ( ! desktop_mode_files_user_can_purge_placement( $user_id, $row ) ) {
563 + if ( ! openstation_files_user_can_purge_placement( $user_id, $row ) ) {
599 564 return new WP_Error(
600 - 'desktop_mode_files_forbidden',
565 + 'openstation_files_forbidden',
601 566 __( 'You do not have permission to delete this item.', 'desktop-mode' ),
602 567 array( 'status' => 403 )
603 568 );
604 569 }
@@ -603,43 +568,41 @@
603 568 );
604 569 }
605 570
606 571 /**
607 - * @since 0.8.0
608 - *
609 572 * @param int $placement_id
610 573 * @param int $user_id
611 574 * @param array $row
612 575 */
613 - do_action( 'desktop_mode_files_before_purge_placement', $placement_id, $user_id, $row );
576 + do_action( 'openstation_files_before_purge_placement', $placement_id, $user_id, $row );
614 577
615 578 $wpdb->delete( $tables['placements'], array( 'id' => $placement_id ), array( '%d' ) );
616 579
617 - // Mirror `desktop_mode_files_remove()`: a purge IS a permanent
580 + // Mirror `openstation_files_remove()`: a purge IS a permanent
618 581 // removal, so the same lifecycle action fires. Load-bearing for
619 582 // the `upload` type — the stored-files listener deletes the real
620 583 // bytes when the owner's last placement goes away; without this
621 - // the recycle-bin "Delete forever" path leaked them (0.9.6).
584 + // the recycle-bin "Delete forever" path leaked them.
622 585 do_action(
623 - 'desktop_mode_file_unplaced',
586 + 'openstation_file_unplaced',
624 587 $placement_id,
625 - desktop_mode_files_normalize_placement_row( $row )
588 + openstation_files_normalize_placement_row( $row )
626 589 );
627 590
628 591 /**
629 - * @since 0.8.0
630 - *
631 592 * @param int $placement_id
632 593 * @param int $user_id
633 594 */
634 - do_action( 'desktop_mode_files_after_purge_placement', $placement_id, $user_id );
595 + do_action( 'openstation_files_after_purge_placement', $placement_id, $user_id );
635 596
636 597 return true;
637 598 }
638 599
639 -/* ================================================================== *
600 +/*
601 +================================================================== *
640 602 * Folder: trash / restore / purge (cascades to child placements).
641 - * ================================================================== */
603 + * ==================================================================
604 + */
642 605
643 606 /**
644 607 * Soft-trash a folder. Cascades to every child placement (any
645 608 * placement whose `parent_id = folder_id`), marking them with
@@ -647,19 +610,17 @@
647 610 * the same set without time-window heuristics.
648 611 *
649 612 * Idempotent on already-trashed.
650 613 *
651 - * @since 0.8.0
652 - *
653 614 * @param int $user_id
654 615 * @param int $folder_id
655 616 * @return true|WP_Error
656 617 */
657 -function desktop_mode_files_trash_folder( $user_id, $folder_id ) {
618 +function openstation_files_trash_folder( $user_id, $folder_id ) {
658 619 global $wpdb;
659 620 $user_id = (int) $user_id;
660 621 $folder_id = (int) $folder_id;
661 - $tables = desktop_mode_files_table_names();
622 + $tables = openstation_files_table_names();
662 623
663 624 $row = $wpdb->get_row(
664 625 $wpdb->prepare(
665 626 "SELECT * FROM {$tables['folders']} WHERE id = %d",
@@ -668,9 +629,9 @@
668 629 ARRAY_A
669 630 );
670 631 if ( ! $row ) {
671 632 return new WP_Error(
672 - 'desktop_mode_files_folder_not_found',
633 + 'openstation_files_folder_not_found',
673 634 __( 'Folder not found.', 'desktop-mode' ),
674 635 array( 'status' => 404 )
675 636 );
676 637 }
@@ -676,11 +637,11 @@
676 637 }
677 638 if ( null !== $row['trashed_at_ms'] && '' !== $row['trashed_at_ms'] ) {
678 639 return true;
679 640 }
680 - if ( ! desktop_mode_files_user_can_trash_folder( $user_id, $row ) ) {
641 + if ( ! openstation_files_user_can_trash_folder( $user_id, $row ) ) {
681 642 return new WP_Error(
682 - 'desktop_mode_files_forbidden',
643 + 'openstation_files_forbidden',
683 644 __( 'You do not have permission to trash this folder.', 'desktop-mode' ),
684 645 array( 'status' => 403 )
685 646 );
686 647 }
@@ -685,17 +646,15 @@
685 646 );
686 647 }
687 648
688 649 /**
689 - * @since 0.8.0
690 - *
691 650 * @param int $folder_id
692 651 * @param int $user_id
693 652 * @param array $row
694 653 */
695 - do_action( 'desktop_mode_files_before_trash_folder', $folder_id, $user_id, $row );
654 + do_action( 'openstation_files_before_trash_folder', $folder_id, $user_id, $row );
696 655
697 - $now = desktop_mode_files_now_ms();
656 + $now = openstation_files_now_ms();
698 657 // Capture the folder's own placement-chain ancestry so a future
699 658 // restore can resurrect any parent folders that got hard-deleted
700 659 // while this one was sitting in trash.
701 660 $folder_placement = $wpdb->get_row(
@@ -706,12 +665,12 @@
706 665 (string) $folder_id
707 666 ),
708 667 ARRAY_A
709 668 );
710 - $folder_ancestry = $folder_placement
711 - ? desktop_mode_files_capture_ancestry( (int) $folder_placement['parent_id'] )
669 + $folder_ancestry = $folder_placement
670 + ? openstation_files_capture_ancestry( (int) $folder_placement['parent_id'] )
712 671 : array();
713 - $folder_meta = wp_json_encode( array( 'ancestry' => $folder_ancestry ) );
672 + $folder_meta = wp_json_encode( array( 'ancestry' => $folder_ancestry ) );
714 673
715 674 // Trash the folder row.
716 675 $folder_update = $wpdb->update(
717 676 $tables['folders'],
@@ -726,9 +685,9 @@
726 685 array( '%d' )
727 686 );
728 687 if ( false === $folder_update ) {
729 688 return new WP_Error(
730 - 'desktop_mode_files_trash_failed',
689 + 'openstation_files_trash_failed',
731 690 isset( $wpdb->last_error ) && $wpdb->last_error
732 691 ? (string) $wpdb->last_error
733 692 : __( 'Failed to trash folder.', 'desktop-mode' ),
734 693 array( 'status' => 500 )
@@ -742,9 +701,9 @@
742 701 // just one child later (after the parent folder was hard-
743 702 // deleted) can still recreate the chain — same shape as a
744 703 // direct trash. Captured per-row because every child shares
745 704 // the same parent chain, so we compute once.
746 - $ancestry = desktop_mode_files_capture_ancestry( $folder_id );
705 + $ancestry = openstation_files_capture_ancestry( $folder_id );
747 706 $meta = wp_json_encode( array( 'ancestry' => $ancestry ) );
748 707 $wpdb->query(
749 708 $wpdb->prepare(
750 709 "UPDATE {$tables['placements']}
@@ -773,18 +732,16 @@
773 732 $folder_id
774 733 )
775 734 );
776 735 foreach ( (array) $child_folder_ids as $child_id ) {
777 - desktop_mode_files_trash_folder( $user_id, (int) $child_id );
736 + openstation_files_trash_folder( $user_id, (int) $child_id );
778 737 }
779 738
780 739 /**
781 - * @since 0.8.0
782 - *
783 740 * @param int $folder_id
784 741 * @param int $user_id
785 742 */
786 - do_action( 'desktop_mode_files_after_trash_folder', $folder_id, $user_id );
743 + do_action( 'openstation_files_after_trash_folder', $folder_id, $user_id );
787 744
788 745 return true;
789 746 }
790 747
@@ -793,19 +750,17 @@
793 750 * its cascade. Items that were trashed BEFORE the folder cascade
794 751 * (i.e. `trashed_via_folder IS NULL`) stay in the recycle bin —
795 752 * the user trashed them deliberately, separate from the folder.
796 753 *
797 - * @since 0.8.0
798 - *
799 754 * @param int $user_id
800 755 * @param int $folder_id
801 756 * @return true|WP_Error
802 757 */
803 -function desktop_mode_files_restore_folder( $user_id, $folder_id ) {
758 +function openstation_files_restore_folder( $user_id, $folder_id ) {
804 759 global $wpdb;
805 760 $user_id = (int) $user_id;
806 761 $folder_id = (int) $folder_id;
807 - $tables = desktop_mode_files_table_names();
762 + $tables = openstation_files_table_names();
808 763
809 764 $row = $wpdb->get_row(
810 765 $wpdb->prepare(
811 766 "SELECT * FROM {$tables['folders']} WHERE id = %d",
@@ -814,9 +769,9 @@
814 769 ARRAY_A
815 770 );
816 771 if ( ! $row ) {
817 772 return new WP_Error(
818 - 'desktop_mode_files_folder_not_found',
773 + 'openstation_files_folder_not_found',
819 774 __( 'Folder not found.', 'desktop-mode' ),
820 775 array( 'status' => 404 )
821 776 );
822 777 }
@@ -822,11 +777,11 @@
822 777 }
823 778 if ( null === $row['trashed_at_ms'] || '' === $row['trashed_at_ms'] ) {
824 779 return true;
825 780 }
826 - if ( ! desktop_mode_files_user_can_restore_folder( $user_id, $row ) ) {
781 + if ( ! openstation_files_user_can_restore_folder( $user_id, $row ) ) {
827 782 return new WP_Error(
828 - 'desktop_mode_files_forbidden',
783 + 'openstation_files_forbidden',
829 784 __( 'You do not have permission to restore this folder.', 'desktop-mode' ),
830 785 array( 'status' => 403 )
831 786 );
832 787 }
@@ -831,17 +786,15 @@
831 786 );
832 787 }
833 788
834 789 /**
835 - * @since 0.8.0
836 - *
837 790 * @param int $folder_id
838 791 * @param int $user_id
839 792 * @param array $row
840 793 */
841 - do_action( 'desktop_mode_files_before_restore_folder', $folder_id, $user_id, $row );
794 + do_action( 'openstation_files_before_restore_folder', $folder_id, $user_id, $row );
842 795
843 - $now = desktop_mode_files_now_ms();
796 + $now = openstation_files_now_ms();
844 797 // Snapshot nested folder ids BEFORE we null `trashed_via_folder`
845 798 // on the placements — that column is the only stable link from
846 799 // a child folder's placement back to the parent cascade.
847 800 $nested_ids = $wpdb->get_col(
@@ -888,12 +841,12 @@
888 841 );
889 842 if ( $folder_placement_row ) {
890 843 $origin_parent = (int) $folder_placement_row['parent_id'];
891 844 $alive = $origin_parent > 0
892 - ? desktop_mode_files_get_folder( $origin_parent, true )
845 + ? openstation_files_get_folder( $origin_parent, true )
893 846 : null;
894 847 if ( $origin_parent > 0 && ! $alive ) {
895 - $resolved = desktop_mode_files_resurrect_ancestry( $user_id, $ancestry );
848 + $resolved = openstation_files_resurrect_ancestry( $user_id, $ancestry );
896 849 $wpdb->update(
897 850 $tables['placements'],
898 851 array(
899 852 'parent_id' => $resolved,
@@ -921,9 +874,9 @@
921 874 )
922 875 );
923 876 // Recursively restore nested folders captured in the snapshot.
924 877 foreach ( (array) $nested_ids as $nid ) {
925 - desktop_mode_files_restore_folder( $user_id, (int) $nid );
878 + openstation_files_restore_folder( $user_id, (int) $nid );
926 879 }
927 880
928 881 // Enforce the "tombstones never refer to alive rows" invariant
929 882 // across the restored cohort: the folder itself, every cascade-
@@ -931,9 +884,9 @@
931 884 // folder recursed into above already clears its own. Here we
932 885 // scrub the FOLDER's own tombstones plus those of every cascade-
933 886 // restored placement so a fresh heartbeat tick can't surface
934 887 // them as `removed.*` against the now-alive rows.
935 - desktop_mode_files_clear_tombstones_for( 'folder', $folder_id );
888 + openstation_files_clear_tombstones_for( 'folder', $folder_id );
936 889 $restored_placement_ids = $wpdb->get_col(
937 890 $wpdb->prepare(
938 891 "SELECT id FROM {$tables['placements']}
939 892 WHERE trashed_via_folder IS NULL
@@ -942,18 +895,16 @@
942 895 (string) $folder_id
943 896 )
944 897 );
945 898 foreach ( (array) $restored_placement_ids as $rpid ) {
946 - desktop_mode_files_clear_tombstones_for( 'placement', (int) $rpid );
899 + openstation_files_clear_tombstones_for( 'placement', (int) $rpid );
947 900 }
948 901
949 902 /**
950 - * @since 0.8.0
951 - *
952 903 * @param int $folder_id
953 904 * @param int $user_id
954 905 */
955 - do_action( 'desktop_mode_files_after_restore_folder', $folder_id, $user_id );
906 + do_action( 'openstation_files_after_restore_folder', $folder_id, $user_id );
956 907
957 908 return true;
958 909 }
959 910
@@ -961,19 +912,17 @@
961 912 * Permanently delete a trashed folder and all its trashed-via-
962 913 * cascade child placements. Independent placements that landed in
963 914 * the trash separately stay there.
964 915 *
965 - * @since 0.8.0
966 - *
967 916 * @param int $user_id
968 917 * @param int $folder_id
969 918 * @return true|WP_Error
970 919 */
971 -function desktop_mode_files_purge_folder( $user_id, $folder_id ) {
920 +function openstation_files_purge_folder( $user_id, $folder_id ) {
972 921 global $wpdb;
973 922 $user_id = (int) $user_id;
974 923 $folder_id = (int) $folder_id;
975 - $tables = desktop_mode_files_table_names();
924 + $tables = openstation_files_table_names();
976 925
977 926 $row = $wpdb->get_row(
978 927 $wpdb->prepare(
979 928 "SELECT * FROM {$tables['folders']} WHERE id = %d",
@@ -983,11 +932,11 @@
983 932 );
984 933 if ( ! $row ) {
985 934 return true;
986 935 }
987 - if ( ! desktop_mode_files_user_can_purge_folder( $user_id, $row ) ) {
936 + if ( ! openstation_files_user_can_purge_folder( $user_id, $row ) ) {
988 937 return new WP_Error(
989 - 'desktop_mode_files_forbidden',
938 + 'openstation_files_forbidden',
990 939 __( 'You do not have permission to delete this folder.', 'desktop-mode' ),
991 940 array( 'status' => 403 )
992 941 );
993 942 }
@@ -992,15 +941,13 @@
992 941 );
993 942 }
994 943
995 944 /**
996 - * @since 0.8.0
997 - *
998 945 * @param int $folder_id
999 946 * @param int $user_id
1000 947 * @param array $row
1001 948 */
1002 - do_action( 'desktop_mode_files_before_purge_folder', $folder_id, $user_id, $row );
949 + do_action( 'openstation_files_before_purge_folder', $folder_id, $user_id, $row );
1003 950
1004 951 // Cascade-revoke every share + per-user decision for the folder
1005 952 // BEFORE deleting the folder row. Without this, purge left
1006 953 // orphan `folder_shares` + `share_user_decisions` rows pointing
@@ -1006,9 +953,9 @@
1006 953 // orphan `folder_shares` + `share_user_decisions` rows pointing
1007 954 // at a folder id that no longer exists — `compute_visible_folders`
1008 955 // would still join them, and the row leak grew with every
1009 956 // recycle-bin empty. Mirrors the same cleanup
1010 - // `desktop_mode_files_delete_folder_recursive` does for the
957 + // `openstation_files_delete_folder_recursive` does for the
1011 958 // "delete from desktop" path.
1012 959 // `target_type` scoping is load-bearing: `folder_id` carries a
1013 960 // STORED-FILE id on `target_type='file'` rows, and the two id
1014 961 // sequences are independent — without the predicate a folder
@@ -1048,9 +995,9 @@
1048 995 (string) $folder_id
1049 996 )
1050 997 );
1051 998 foreach ( $pointing_ids as $pid ) {
1052 - desktop_mode_files_write_tombstone( 'placement', (int) $pid );
999 + openstation_files_write_tombstone( 'placement', (int) $pid );
1053 1000 }
1054 1001 if ( ! empty( $pointing_ids ) ) {
1055 1002 $placeholders = implode( ',', array_fill( 0, count( $pointing_ids ), '%d' ) );
1056 1003 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
@@ -1064,9 +1011,9 @@
1064 1011
1065 1012 // Upload placements among the cascade-trashed children carry
1066 1013 // real bytes — run the stored-files deletion contract for them
1067 1014 // after the rows go. Direct guarded call (not the public
1068 - // `desktop_mode_file_unplaced` action) so cascade hook semantics
1015 + // `openstation_file_unplaced` action) so cascade hook semantics
1069 1016 // for every other type stay unchanged.
1070 1017 $cascade_upload_rows = (array) $wpdb->get_results(
1071 1018 $wpdb->prepare(
1072 1019 "SELECT * FROM {$tables['placements']}
@@ -1079,13 +1026,13 @@
1079 1026 $tables['placements'],
1080 1027 array( 'trashed_via_folder' => $folder_id ),
1081 1028 array( '%d' )
1082 1029 );
1083 - if ( function_exists( 'desktop_mode_stored_files_handle_unplaced' ) ) {
1030 + if ( function_exists( 'openstation_stored_files_handle_unplaced' ) ) {
1084 1031 foreach ( $cascade_upload_rows as $upload_row ) {
1085 - desktop_mode_stored_files_handle_unplaced(
1032 + openstation_stored_files_handle_unplaced(
1086 1033 (int) $upload_row['id'],
1087 - desktop_mode_files_normalize_placement_row( $upload_row )
1034 + openstation_files_normalize_placement_row( $upload_row )
1088 1035 );
1089 1036 }
1090 1037 }
1091 1038 $wpdb->delete( $tables['folders'], array( 'id' => $folder_id ), array( '%d' ) );
@@ -1090,21 +1037,21 @@
1090 1037 }
1091 1038 $wpdb->delete( $tables['folders'], array( 'id' => $folder_id ), array( '%d' ) );
1092 1039
1093 1040 /**
1094 - * @since 0.8.0
1095 - *
1096 1041 * @param int $folder_id
1097 1042 * @param int $user_id
1098 1043 */
1099 - do_action( 'desktop_mode_files_after_purge_folder', $folder_id, $user_id );
1044 + do_action( 'openstation_files_after_purge_folder', $folder_id, $user_id );
1100 1045
1101 1046 return true;
1102 1047 }
1103 1048
1104 -/* ================================================================== *
1049 +/*
1050 +================================================================== *
1105 1051 * Recycle-bin list builder.
1106 - * ================================================================== */
1052 + * ==================================================================
1053 + */
1107 1054
1108 1055 /**
1109 1056 * Count of trashed placements + folders surfaced to the recycle bin
1110 1057 * for `$user_id`. Mirrors `_list_trashed_for_recycle_bin`'s "skip
@@ -1109,20 +1056,18 @@
1109 1056 * Count of trashed placements + folders surfaced to the recycle bin
1110 1057 * for `$user_id`. Mirrors `_list_trashed_for_recycle_bin`'s "skip
1111 1058 * cascaded children" rule so the badge matches the visible list.
1112 1059 *
1113 - * @since 0.8.0
1114 - *
1115 1060 * @param int $user_id Owner.
1116 1061 * @return int
1117 1062 */
1118 -function desktop_mode_files_count_trashed_for_recycle_bin( $user_id ) {
1063 +function openstation_files_count_trashed_for_recycle_bin( $user_id ) {
1119 1064 global $wpdb;
1120 1065 $user_id = (int) $user_id;
1121 1066 if ( $user_id <= 0 ) {
1122 1067 return 0;
1123 1068 }
1124 - $tables = desktop_mode_files_table_names();
1069 + $tables = openstation_files_table_names();
1125 1070
1126 1071 $placements = (int) $wpdb->get_var(
1127 1072 $wpdb->prepare(
1128 1073 "SELECT COUNT(*) FROM {$tables['placements']}
@@ -1131,9 +1076,9 @@
1131 1076 AND trashed_via_folder IS NULL",
1132 1077 $user_id
1133 1078 )
1134 1079 );
1135 - $folders = (int) $wpdb->get_var(
1080 + $folders = (int) $wpdb->get_var(
1136 1081 $wpdb->prepare(
1137 1082 "SELECT COUNT(*) FROM {$tables['folders']}
1138 1083 WHERE owner_id = %d AND trashed_at_ms IS NOT NULL",
1139 1084 $user_id
@@ -1146,17 +1091,15 @@
1146 1091 * Return the trashed placements + folders for a user, shaped as
1147 1092 * recycle-bin items. Used by the recycle bin's REST list endpoint
1148 1093 * to merge files-on-the-desktop trash with the WP-core trash.
1149 1094 *
1150 - * @since 0.8.0
1151 - *
1152 1095 * @param int $user_id Owner.
1153 1096 * @return array[] List of recycle-bin item shapes.
1154 1097 */
1155 -function desktop_mode_files_list_trashed_for_recycle_bin( $user_id ) {
1098 +function openstation_files_list_trashed_for_recycle_bin( $user_id ) {
1156 1099 global $wpdb;
1157 1100 $user_id = (int) $user_id;
1158 - $tables = desktop_mode_files_table_names();
1101 + $tables = openstation_files_table_names();
1159 1102 $out = array();
1160 1103
1161 1104 // Trashed placements owned by this user.
1162 1105 $placements = $wpdb->get_results(
@@ -1173,20 +1116,22 @@
1173 1116 // the whole bundle in the recycle bin.
1174 1117 if ( ! empty( $row['trashed_via_folder'] ) ) {
1175 1118 continue;
1176 1119 }
1177 - $file = function_exists( 'desktop_mode_resolve_file' )
1178 - ? desktop_mode_resolve_file( $row['file_type'], $row['file_ref'] )
1120 + $file = function_exists( 'openstation_resolve_file' )
1121 + ? openstation_resolve_file( $row['file_type'], $row['file_ref'] )
1179 1122 : null;
1180 - $title = $file ? (string) $file->title() : (string) $row['file_type'];
1123 + $title = $file
1124 + ? openstation_plain_text_title( $file->title() )
1125 + : (string) $row['file_type'];
1181 1126 $icon = $file ? (string) $file->icon() : 'dashicons-no-alt';
1182 1127 // Two recycle-bin buckets:
1183 - // - `shortcut` → plugin-registered icons (file_type='shortcut')
1184 - // - `placement` → every other placement (post / page /
1185 - // attachment / user / term / comment / …)
1128 + // - `shortcut` → plugin-registered icons (file_type='shortcut')
1129 + // - `placement` → every other placement (post / page /
1130 + // attachment / user / term / comment / …)
1186 1131 // Lets the bin's type-filter tabs split "Shortcuts" from
1187 1132 // "Files" without overloading either label.
1188 - $bucket = ( 'shortcut' === (string) $row['file_type'] )
1133 + $bucket = ( 'shortcut' === (string) $row['file_type'] )
1189 1134 ? 'shortcut'
1190 1135 : 'placement';
1191 1136 $subtitle = ( 'shortcut' === $bucket )
1192 1137 ? __( 'Desktop shortcut', 'desktop-mode' )
@@ -1211,10 +1156,10 @@
1211 1156 'icon' => $icon,
1212 1157 'deleted_at' => gmdate( 'c', (int) round( (int) $row['trashed_at_ms'] / 1000 ) ),
1213 1158 'deleted_by' => '',
1214 1159 'deleted_by_id' => (int) $row['trashed_by'],
1215 - 'can_restore' => desktop_mode_files_user_can_restore_placement( $user_id, $row ),
1216 - 'can_purge' => desktop_mode_files_user_can_purge_placement( $user_id, $row ),
1160 + 'can_restore' => openstation_files_user_can_restore_placement( $user_id, $row ),
1161 + 'can_purge' => openstation_files_user_can_purge_placement( $user_id, $row ),
1217 1162 'edit_link' => '',
1218 1163 );
1219 1164 if ( 'link' === (string) $row['file_type'] ) {
1220 1165 $item['type_label'] = __( 'URL', 'desktop-mode' );
@@ -1239,9 +1184,9 @@
1239 1184 WHERE trashed_via_folder = %d",
1240 1185 (int) $row['id']
1241 1186 )
1242 1187 );
1243 - $out[] = array(
1188 + $out[] = array(
1244 1189 'id' => (int) $row['id'],
1245 1190 'type' => 'folder',
1246 1191 'title' => (string) $row['name'],
1247 1192 'subtitle' => $child_count > 0
@@ -1256,10 +1201,10 @@
1256 1201 'icon' => 'dashicons-portfolio',
1257 1202 'deleted_at' => gmdate( 'c', (int) round( (int) $row['trashed_at_ms'] / 1000 ) ),
1258 1203 'deleted_by' => '',
1259 1204 'deleted_by_id' => (int) $row['trashed_by'],
1260 - 'can_restore' => desktop_mode_files_user_can_restore_folder( $user_id, $row ),
1261 - 'can_purge' => desktop_mode_files_user_can_purge_folder( $user_id, $row ),
1205 + 'can_restore' => openstation_files_user_can_restore_folder( $user_id, $row ),
1206 + 'can_purge' => openstation_files_user_can_purge_folder( $user_id, $row ),
1262 1207 'edit_link' => '',
1263 1208 );
1264 1209 }
1265 1210
@@ -1270,9 +1215,9 @@
1270 1215 if ( $uid <= 0 ) {
1271 1216 continue;
1272 1217 }
1273 1218 if ( ! isset( $user_cache[ $uid ] ) ) {
1274 - $u = get_userdata( $uid );
1219 + $u = get_userdata( $uid );
1275 1220 $user_cache[ $uid ] = $u ? $u->display_name : '';
1276 1221 }
1277 1222 $item['deleted_by'] = $user_cache[ $uid ];
1278 1223 }