| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Desktop Mode — Cascade cleanup of placements on entity trash. | |
| 3 | + * OpenStation — Cascade cleanup of placements on entity trash. | |
| 4 | 4 | * |
| 5 | 5 | * When a WordPress entity that a desktop shortcut points at is |
| 6 | 6 | * trashed or deleted, the matching placement rows are soft-trashed |
| 7 | 7 | * so the wallpaper stops painting tiles that resolve to nothing. |
| @@ -31,9 +31,9 @@ | ||
| 31 | 31 | * in the table. The placement surfaces in the Recycle Bin and the |
| 32 | 32 | * user can restore it from there (independent of the source entity's |
| 33 | 33 | * trash status — restoring a post does NOT auto-restore its shortcut). |
| 34 | 34 | * |
| 35 | - * @package WPDesktopMode | |
| 35 | + * @package OpenStation | |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | 38 | defined( 'ABSPATH' ) || exit; |
| 39 | 39 | |
| @@ -42,9 +42,9 @@ | ||
| 42 | 42 | * |
| 43 | 43 | * Iterates `wp_desktop_mode_file_placements` for rows with the |
| 44 | 44 | * matching `file_type` + `file_ref` whose `trashed_at_ms` is |
| 45 | 45 | * unset, and stamps the trash columns. Each affected placement |
| 46 | - * fires `desktop_mode_files_after_cascade_trash_placement` so | |
| 46 | + * fires `openstation_files_after_cascade_trash_placement` so | |
| 47 | 47 | * plugins (and the live UI refresh path) can react. |
| 48 | 48 | * |
| 49 | 49 | * Idempotent: re-running with an already-trashed entity is a |
| 50 | 50 | * no-op because the `trashed_at_ms IS NULL` filter excludes |
| @@ -57,13 +57,13 @@ | ||
| 57 | 57 | * |
| 58 | 58 | * @param string $file_type File-type slug — `'post'`, |
| 59 | 59 | * `'attachment'`, `'user'`, plugin- |
| 60 | 60 | * defined. Must match |
| 61 | - * {@see Desktop_Mode_File::type()}. | |
| 61 | + * {@see OpenStation_File::type()}. | |
| 62 | 62 | * @param string|int $file_ref Entity ref (post id, user id, …). |
| 63 | 63 | * @return int Number of placements soft-trashed. |
| 64 | 64 | */ |
| 65 | -function desktop_mode_files_cascade_trash_placements_for_entity( $file_type, $file_ref ) { | |
| 65 | +function openstation_files_cascade_trash_placements_for_entity( $file_type, $file_ref ) { | |
| 66 | 66 | global $wpdb; |
| 67 | 67 | $file_type = (string) $file_type; |
| 68 | 68 | $file_ref = (string) $file_ref; |
| 69 | 69 | if ( '' === $file_type || '' === $file_ref ) { |
| @@ -68,9 +68,9 @@ | ||
| 68 | 68 | $file_ref = (string) $file_ref; |
| 69 | 69 | if ( '' === $file_type || '' === $file_ref ) { |
| 70 | 70 | return 0; |
| 71 | 71 | } |
| 72 | - $tables = desktop_mode_files_table_names(); | |
| 72 | + $tables = openstation_files_table_names(); | |
| 73 | 73 | |
| 74 | 74 | // SELECT the affected rows up front so we can fire a per-row |
| 75 | 75 | // action without a second roundtrip. Restrict to live (not yet |
| 76 | 76 | // trashed) placements — the cascade is idempotent and we don't |
| @@ -91,14 +91,14 @@ | ||
| 91 | 91 | if ( empty( $rows ) ) { |
| 92 | 92 | return 0; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - $now = desktop_mode_files_now_ms(); | |
| 95 | + $now = openstation_files_now_ms(); | |
| 96 | 96 | $trashed = 0; |
| 97 | 97 | foreach ( $rows as $row ) { |
| 98 | 98 | $placement_id = (int) $row['id']; |
| 99 | 99 | $owner_id = (int) $row['owner_id']; |
| 100 | - $ancestry = desktop_mode_files_capture_ancestry( (int) $row['parent_id'] ); | |
| 100 | + $ancestry = openstation_files_capture_ancestry( (int) $row['parent_id'] ); | |
| 101 | 101 | // `trashed_meta` carries the ancestry (so a restore knows |
| 102 | 102 | // where to put the tile back) plus a cascade marker so the |
| 103 | 103 | // recycle-bin UI can distinguish entity-cascade rows from |
| 104 | 104 | // user-initiated trashes if a plugin ever wants to render |
| @@ -112,9 +112,9 @@ | ||
| 112 | 112 | 'file_ref' => $file_ref, |
| 113 | 113 | ), |
| 114 | 114 | ) |
| 115 | 115 | ); |
| 116 | - $ok = $wpdb->update( | |
| 116 | + $ok = $wpdb->update( | |
| 117 | 117 | $tables['placements'], |
| 118 | 118 | array( |
| 119 | 119 | 'trashed_at_ms' => $now, |
| 120 | 120 | 'trashed_by' => $owner_id, |
| @@ -139,9 +139,9 @@ | ||
| 139 | 139 | * @param string $file_type Source entity file type. |
| 140 | 140 | * @param string|int $file_ref Source entity ref. |
| 141 | 141 | */ |
| 142 | 142 | do_action( |
| 143 | - 'desktop_mode_files_after_cascade_trash_placement', | |
| 143 | + 'openstation_files_after_cascade_trash_placement', | |
| 144 | 144 | $placement_id, |
| 145 | 145 | $owner_id, |
| 146 | 146 | $file_type, |
| 147 | 147 | $file_ref |
| @@ -162,9 +162,9 @@ | ||
| 162 | 162 | * `delete_attachment` hook below covers attachments. |
| 163 | 163 | * |
| 164 | 164 | * @param int $post_id Post id. |
| 165 | 165 | */ |
| 166 | -function desktop_mode_files_cascade_on_post_trash( $post_id ) { | |
| 166 | +function openstation_files_cascade_on_post_trash( $post_id ) { | |
| 167 | 167 | $post_id = (int) $post_id; |
| 168 | 168 | if ( $post_id <= 0 ) { |
| 169 | 169 | return; |
| 170 | 170 | } |
| @@ -178,19 +178,19 @@ | ||
| 178 | 178 | // the soft-trash path for attachments (when `EMPTY_TRASH_DAYS` |
| 179 | 179 | // is non-zero) also fires `wp_trash_post` — we cover it by |
| 180 | 180 | // dispatching to the attachment cascade below. |
| 181 | 181 | if ( 'attachment' === $post->post_type ) { |
| 182 | - desktop_mode_files_cascade_trash_placements_for_entity( | |
| 182 | + openstation_files_cascade_trash_placements_for_entity( | |
| 183 | 183 | 'attachment', |
| 184 | 184 | (string) $post_id |
| 185 | 185 | ); |
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | - desktop_mode_files_cascade_trash_placements_for_entity( 'post', (string) $post_id ); | |
| 188 | + openstation_files_cascade_trash_placements_for_entity( 'post', (string) $post_id ); | |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | -add_action( 'wp_trash_post', 'desktop_mode_files_cascade_on_post_trash', 10, 1 ); | |
| 192 | -add_action( 'before_delete_post', 'desktop_mode_files_cascade_on_post_trash', 10, 1 ); | |
| 191 | +add_action( 'wp_trash_post', 'openstation_files_cascade_on_post_trash', 10, 1 ); | |
| 192 | +add_action( 'before_delete_post', 'openstation_files_cascade_on_post_trash', 10, 1 ); | |
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | 195 | * Force-delete path for attachments — Core's `wp_delete_attachment()` |
| 196 | 196 | * fires this BEFORE the attachment row is gone, so `get_post()` is |
| @@ -197,20 +197,20 @@ | ||
| 197 | 197 | * still resolvable for any plugin that needs the metadata. |
| 198 | 198 | * |
| 199 | 199 | * @param int $attachment_id Attachment id. |
| 200 | 200 | */ |
| 201 | -function desktop_mode_files_cascade_on_attachment_delete( $attachment_id ) { | |
| 201 | +function openstation_files_cascade_on_attachment_delete( $attachment_id ) { | |
| 202 | 202 | $attachment_id = (int) $attachment_id; |
| 203 | 203 | if ( $attachment_id <= 0 ) { |
| 204 | 204 | return; |
| 205 | 205 | } |
| 206 | - desktop_mode_files_cascade_trash_placements_for_entity( | |
| 206 | + openstation_files_cascade_trash_placements_for_entity( | |
| 207 | 207 | 'attachment', |
| 208 | 208 | (string) $attachment_id |
| 209 | 209 | ); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | -add_action( 'delete_attachment', 'desktop_mode_files_cascade_on_attachment_delete', 10, 1 ); | |
| 212 | +add_action( 'delete_attachment', 'openstation_files_cascade_on_attachment_delete', 10, 1 ); | |
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | 215 | * User account removed — cascade-trash every shortcut whose |
| 216 | 216 | * `file_type='user', file_ref='<id>'` pointed at the gone user. |
| @@ -219,16 +219,16 @@ | ||
| 219 | 219 | * row, only its id. |
| 220 | 220 | * |
| 221 | 221 | * @param int $user_id Deleted user id. |
| 222 | 222 | */ |
| 223 | -function desktop_mode_files_cascade_on_user_delete( $user_id ) { | |
| 223 | +function openstation_files_cascade_on_user_delete( $user_id ) { | |
| 224 | 224 | $user_id = (int) $user_id; |
| 225 | 225 | if ( $user_id <= 0 ) { |
| 226 | 226 | return; |
| 227 | 227 | } |
| 228 | - desktop_mode_files_cascade_trash_placements_for_entity( | |
| 228 | + openstation_files_cascade_trash_placements_for_entity( | |
| 229 | 229 | 'user', |
| 230 | 230 | (string) $user_id |
| 231 | 231 | ); |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | -add_action( 'deleted_user', 'desktop_mode_files_cascade_on_user_delete', 10, 1 ); | |
| 234 | +add_action( 'deleted_user', 'openstation_files_cascade_on_user_delete', 10, 1 ); | |