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/recycle-bin.php +23 -36 0.9.61.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Pinned notes in the Recycle Bin.
3 + * OpenStation — Pinned notes in the Recycle Bin.
4 4 *
5 5 * `wpd_note` is a headless CPT (`show_ui => false`), so the bin's
6 6 * auto-capture of admin-UI post types skips it — this file opts it in
7 7 * through the bin's existing filter pipeline and adapts the generic
@@ -28,10 +28,9 @@
28 28 * `wp_untrash_post_status` filter in `cpt.php` brings the note back
29 29 * with its original private/publish status, and the Heartbeat delta
30 30 * re-pins it on the wall without a reload.
31 31 *
32 - * @package WPDesktopMode
33 - * @since 0.9.6
32 + * @package OpenStation
34 33 */
35 34
36 35 defined( 'ABSPATH' ) || exit;
37 36
@@ -37,30 +36,26 @@
37 36
38 37 /**
39 38 * Opt `wpd_note` into the recycle bin's capture list.
40 39 *
41 - * @since 0.9.6
42 - *
43 40 * @param string[] $types Tracked post types.
44 41 * @return string[]
45 42 */
46 -function desktop_mode_notes_recycle_bin_capture_types( $types ) {
43 +function openstation_notes_recycle_bin_capture_types( $types ) {
47 44 $types = (array) $types;
48 - $types[] = DESKTOP_MODE_NOTES_POST_TYPE;
45 + $types[] = OPENSTATION_NOTES_POST_TYPE;
49 46 return $types;
50 47 }
51 -add_filter( 'desktop_mode_recycle_bin_capture_post_types', 'desktop_mode_notes_recycle_bin_capture_types' );
48 +add_filter( 'openstation_recycle_bin_capture_post_types', 'openstation_notes_recycle_bin_capture_types' );
52 49
53 50 /**
54 51 * Whether a trashed post is a note owned by the current user.
55 52 *
56 - * @since 0.9.6
57 - *
58 53 * @param WP_Post $post Trashed post.
59 54 * @return bool
60 55 */
61 -function desktop_mode_notes_recycle_bin_owns( $post ) {
62 - return (int) $post->post_author === get_current_user_id();
56 +function openstation_notes_recycle_bin_owns( $post ) {
57 + return get_current_user_id() === (int) $post->post_author;
63 58 }
64 59
65 60 /**
66 61 * Owner-only view/restore/purge for notes — replaces the bin's
@@ -65,40 +60,36 @@
65 60 /**
66 61 * Owner-only view/restore/purge for notes — replaces the bin's
67 62 * default `edit_post`/`delete_post` gates for this post type.
68 63 *
69 - * @since 0.9.6
70 - *
71 64 * @param bool $can The bin's default answer.
72 65 * @param WP_Post $post Trashed post.
73 66 * @return bool
74 67 */
75 -function desktop_mode_notes_recycle_bin_gate( $can, $post ) {
76 - if ( DESKTOP_MODE_NOTES_POST_TYPE !== $post->post_type ) {
68 +function openstation_notes_recycle_bin_gate( $can, $post ) {
69 + if ( OPENSTATION_NOTES_POST_TYPE !== $post->post_type ) {
77 70 return $can;
78 71 }
79 - return desktop_mode_notes_recycle_bin_owns( $post );
72 + return openstation_notes_recycle_bin_owns( $post );
80 73 }
81 -add_filter( 'desktop_mode_recycle_bin_user_can_view', 'desktop_mode_notes_recycle_bin_gate', 10, 2 );
82 -add_filter( 'desktop_mode_recycle_bin_user_can_restore', 'desktop_mode_notes_recycle_bin_gate', 10, 2 );
83 -add_filter( 'desktop_mode_recycle_bin_user_can_purge', 'desktop_mode_notes_recycle_bin_gate', 10, 2 );
74 +add_filter( 'openstation_recycle_bin_user_can_view', 'openstation_notes_recycle_bin_gate', 10, 2 );
75 +add_filter( 'openstation_recycle_bin_user_can_restore', 'openstation_notes_recycle_bin_gate', 10, 2 );
76 +add_filter( 'openstation_recycle_bin_user_can_purge', 'openstation_notes_recycle_bin_gate', 10, 2 );
84 77
85 78 /**
86 79 * Paper-flavored row shape for trashed notes.
87 80 *
88 - * @since 0.9.6
89 - *
90 81 * @param array $item Bin item shape.
91 82 * @param WP_Post $post Source post.
92 83 * @return array
93 84 */
94 -function desktop_mode_notes_recycle_bin_item( $item, $post ) {
95 - if ( DESKTOP_MODE_NOTES_POST_TYPE !== $post->post_type ) {
85 +function openstation_notes_recycle_bin_item( $item, $post ) {
86 + if ( OPENSTATION_NOTES_POST_TYPE !== $post->post_type ) {
96 87 return $item;
97 88 }
98 89 $item['type_label'] = __( 'Note', 'desktop-mode' );
99 90 $item['icon'] = 'dashicons-sticky';
100 - $item['subtitle'] = wp_trim_words( desktop_mode_recycle_bin_plain_text( (string) $post->post_content ), 18, '…' );
91 + $item['subtitle'] = wp_trim_words( openstation_recycle_bin_plain_text( (string) $post->post_content ), 18, '…' );
101 92 // Notes have no admin edit screen — a chromeless post.php iframe
102 93 // would 403 on the headless CPT.
103 94 $item['edit_link'] = '';
104 95
@@ -117,21 +108,19 @@
117 108 }
118 109
119 110 return $item;
120 111 }
121 -add_filter( 'desktop_mode_recycle_bin_item', 'desktop_mode_notes_recycle_bin_item', 10, 2 );
112 +add_filter( 'openstation_recycle_bin_item', 'openstation_notes_recycle_bin_item', 10, 2 );
122 113
123 114 /**
124 115 * Number of trashed notes for a given scope.
125 116 *
126 - * @since 0.9.6
127 - *
128 117 * @param int|null $author_id Scope to one author, or null for all.
129 118 * @return int
130 119 */
131 -function desktop_mode_notes_recycle_bin_trashed_count( $author_id = null ) {
120 +function openstation_notes_recycle_bin_trashed_count( $author_id = null ) {
132 121 $args = array(
133 - 'post_type' => DESKTOP_MODE_NOTES_POST_TYPE,
122 + 'post_type' => OPENSTATION_NOTES_POST_TYPE,
134 123 'post_status' => 'trash',
135 124 'posts_per_page' => 1,
136 125 'fields' => 'ids',
137 126 'no_found_rows' => false,
@@ -151,20 +140,18 @@
151 140 * holding `edit_others_posts`, OWN trashed notes for `edit_posts`
152 141 * holders, and none for anyone else. Normalize every case to "own
153 142 * trashed notes".
154 143 *
155 - * @since 0.9.6
156 - *
157 144 * @param int $total Generic total.
158 145 * @return int
159 146 */
160 -function desktop_mode_notes_recycle_bin_count( $total ) {
147 +function openstation_notes_recycle_bin_count( $total ) {
161 148 $total = (int) $total;
162 - $own = desktop_mode_notes_recycle_bin_trashed_count( get_current_user_id() );
149 + $own = openstation_notes_recycle_bin_trashed_count( get_current_user_id() );
163 150
164 151 if ( current_user_can( 'edit_others_posts' ) ) {
165 152 // Counted everyone's notes; keep only ours.
166 - $total = $total - desktop_mode_notes_recycle_bin_trashed_count() + $own;
153 + $total = $total - openstation_notes_recycle_bin_trashed_count() + $own;
167 154 } elseif ( ! current_user_can( 'edit_posts' ) ) {
168 155 // Counted none of ours; add them.
169 156 $total = $total + $own;
170 157 }
@@ -171,5 +158,5 @@
171 158 // `edit_posts`-only users were already counted author-scoped.
172 159
173 160 return max( 0, $total );
174 161 }
175 -add_filter( 'desktop_mode_recycle_bin_count', 'desktop_mode_notes_recycle_bin_count' );
162 +add_filter( 'openstation_recycle_bin_count', 'openstation_notes_recycle_bin_count' );