| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Desktop Mode — Recycle Bin: capture. | |
| 3 | + * OpenStation — Recycle Bin: capture. | |
| 4 | 4 | * |
| 5 | 5 | * Stamps "who-deleted-what-when" metadata onto posts, pages, and |
| 6 | 6 | * comments as they pass through `wp_trash_post()` / `trashed_comment`, |
| 7 | 7 | * so the Recycle Bin window can show "deleted by Alice, 5 minutes ago" |
| @@ -11,17 +11,17 @@ | ||
| 11 | 11 | * vanilla WordPress behavior (permanent-delete on first click). To |
| 12 | 12 | * enable trash for media, define `MEDIA_TRASH` as `true` in |
| 13 | 13 | * `wp-config.php`; the Recycle Bin window will surface trashed |
| 14 | 14 | * attachments automatically because `attachment` is in the default |
| 15 | - * `desktop_mode_recycle_bin_capture_post_types` list. | |
| 15 | + * `openstation_recycle_bin_capture_post_types` list. | |
| 16 | 16 | * |
| 17 | - * - `desktop_mode_recycle_bin_capture_post_types` controls which post | |
| 17 | + * - `openstation_recycle_bin_capture_post_types` controls which post | |
| 18 | 18 | * types we listen for in the first place. |
| 19 | - * - The `desktop_mode_recycle_bin_item_captured` action fires after a | |
| 19 | + * - The `openstation_recycle_bin_item_captured` action fires after a | |
| 20 | 20 | * successful capture so plugins can mirror the event (audit log, |
| 21 | 21 | * external storage, etc.). |
| 22 | 22 | * |
| 23 | - * @package WPDesktopMode | |
| 23 | + * @package OpenStation | |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | defined( 'ABSPATH' ) || exit; |
| 27 | 27 | |
| @@ -42,9 +42,9 @@ | ||
| 42 | 42 | * unless their owning feature opts in via the filter. |
| 43 | 43 | * |
| 44 | 44 | * @return string[] |
| 45 | 45 | */ |
| 46 | -function desktop_mode_recycle_bin_capture_post_types() { | |
| 46 | +function openstation_recycle_bin_capture_post_types() { | |
| 47 | 47 | $types = array( 'post', 'page', 'attachment' ); |
| 48 | 48 | |
| 49 | 49 | $custom = get_post_types( |
| 50 | 50 | array( |
| @@ -65,9 +65,9 @@ | ||
| 65 | 65 | * or add a headless (`show_ui => false`) type to opt it in. |
| 66 | 66 | * |
| 67 | 67 | * @param string[] $types Post types whose deletions the recycle bin tracks. |
| 68 | 68 | */ |
| 69 | - $types = apply_filters( 'desktop_mode_recycle_bin_capture_post_types', $types ); | |
| 69 | + $types = apply_filters( 'openstation_recycle_bin_capture_post_types', $types ); | |
| 70 | 70 | |
| 71 | 71 | return array_values( array_unique( array_filter( array_map( 'strval', (array) $types ) ) ) ); |
| 72 | 72 | } |
| 73 | 73 | |
| @@ -80,23 +80,23 @@ | ||
| 80 | 80 | * key so the table can show "deleted by Alice". |
| 81 | 81 | * |
| 82 | 82 | * @param int $post_id Post being trashed. |
| 83 | 83 | */ |
| 84 | -function desktop_mode_recycle_bin_on_trash_post( $post_id ) { | |
| 84 | +function openstation_recycle_bin_on_trash_post( $post_id ) { | |
| 85 | 85 | $post = get_post( $post_id ); |
| 86 | 86 | if ( ! $post ) { |
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | - if ( ! in_array( $post->post_type, desktop_mode_recycle_bin_capture_post_types(), true ) ) { | |
| 89 | + if ( ! in_array( $post->post_type, openstation_recycle_bin_capture_post_types(), true ) ) { | |
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | - desktop_mode_recycle_bin_record_capture( $post_id ); | |
| 92 | + openstation_recycle_bin_record_capture( $post_id ); | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * Persist who-deleted-what-when metadata for a single item. |
| 97 | 97 | * |
| 98 | - * Stored under `_desktop_mode_trash_*` postmeta on the trashed post itself — | |
| 98 | + * Stored under `_openstation_trash_*` postmeta on the trashed post itself — | |
| 99 | 99 | * survives un-trash naturally because we only consult it while in the |
| 100 | 100 | * bin, and gets cleaned up by core when the post is permanently |
| 101 | 101 | * deleted via the standard postmeta cascade. |
| 102 | 102 | * |
| @@ -101,9 +101,9 @@ | ||
| 101 | 101 | * deleted via the standard postmeta cascade. |
| 102 | 102 | * |
| 103 | 103 | * @param int $post_id Post id being captured. |
| 104 | 104 | */ |
| 105 | -function desktop_mode_recycle_bin_record_capture( $post_id ) { | |
| 105 | +function openstation_recycle_bin_record_capture( $post_id ) { | |
| 106 | 106 | $user_id = get_current_user_id(); |
| 107 | 107 | $now_gmt = current_time( 'mysql', true ); |
| 108 | 108 | |
| 109 | 109 | update_post_meta( $post_id, '_desktop_mode_trash_user_id', (int) $user_id ); |
| @@ -118,16 +118,16 @@ | ||
| 118 | 118 | * @param int $post_id Post id that was captured. |
| 119 | 119 | * @param int $user_id User id who triggered the capture. |
| 120 | 120 | * @param string $now_gmt MySQL-format GMT timestamp. |
| 121 | 121 | */ |
| 122 | - do_action( 'desktop_mode_recycle_bin_item_captured', $post_id, $user_id, $now_gmt ); | |
| 122 | + do_action( 'openstation_recycle_bin_item_captured', $post_id, $user_id, $now_gmt ); | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -add_action( 'wp_trash_post', 'desktop_mode_recycle_bin_on_trash_post', 10, 1 ); | |
| 125 | +add_action( 'wp_trash_post', 'openstation_recycle_bin_on_trash_post', 10, 1 ); | |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * Capture deleted-by metadata for comments — symmetric to |
| 129 | - * `desktop_mode_recycle_bin_record_capture` but writing to `commentmeta` | |
| 129 | + * `openstation_recycle_bin_record_capture` but writing to `commentmeta` | |
| 130 | 130 | * instead of `postmeta`. Comments use `wp_set_comment_status('trash')` |
| 131 | 131 | * which fires `trashed_comment`; we don't need to short-circuit |
| 132 | 132 | * anything (core already routes to a real trash status), just |
| 133 | 133 | * stamp the moment so the bin can show "by Alice, 5 minutes ago". |
| @@ -133,9 +133,9 @@ | ||
| 133 | 133 | * stamp the moment so the bin can show "by Alice, 5 minutes ago". |
| 134 | 134 | * |
| 135 | 135 | * @param int $comment_id Comment about to be trashed. |
| 136 | 136 | */ |
| 137 | -function desktop_mode_recycle_bin_on_trash_comment( $comment_id ) { | |
| 137 | +function openstation_recycle_bin_on_trash_comment( $comment_id ) { | |
| 138 | 138 | $comment_id = (int) $comment_id; |
| 139 | 139 | $user_id = get_current_user_id(); |
| 140 | 140 | $now_gmt = current_time( 'mysql', true ); |
| 141 | 141 | |
| @@ -148,7 +148,7 @@ | ||
| 148 | 148 | * @param int $comment_id Comment id that was captured. |
| 149 | 149 | * @param int $user_id User id who triggered the capture. |
| 150 | 150 | * @param string $now_gmt MySQL-format GMT timestamp. |
| 151 | 151 | */ |
| 152 | - do_action( 'desktop_mode_recycle_bin_comment_captured', $comment_id, $user_id, $now_gmt ); | |
| 152 | + do_action( 'openstation_recycle_bin_comment_captured', $comment_id, $user_id, $now_gmt ); | |
| 153 | 153 | } |
| 154 | -add_action( 'trashed_comment', 'desktop_mode_recycle_bin_on_trash_comment', 10, 1 ); | |
| 154 | +add_action( 'trashed_comment', 'openstation_recycle_bin_on_trash_comment', 10, 1 ); | |