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/recycle-bin/rest.php +32 -32 0.9.81.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Recycle Bin: REST routes.
3 + * OpenStation — Recycle Bin: REST routes.
4 4 *
5 5 * Five routes, all under `/desktop-mode/v1/recycle-bin`:
6 6 *
7 7 * GET / — list trashed items
@@ -9,13 +9,13 @@
9 9 * POST /purge — body { ids: int[] }
10 10 * POST /empty — empties the visible bin
11 11 * GET /count — total items in the bin (badge polling)
12 12 *
13 - * Permission gating delegates to `desktop_mode_recycle_bin_user_can_*` per item;
13 + * Permission gating delegates to `openstation_recycle_bin_user_can_*` per item;
14 14 * the route-level callback only checks "are you logged in and in
15 - * desktop mode at all?" via `desktop_mode_is_enabled()`.
15 + * OpenStation at all?" via `openstation_is_enabled()`.
16 16 *
17 - * @package WPDesktopMode
17 + * @package OpenStation
18 18 */
19 19
20 20 defined( 'ABSPATH' ) || exit;
21 21
@@ -21,9 +21,9 @@
21 21
22 22 /**
23 23 * Register REST routes.
24 24 */
25 -function desktop_mode_recycle_bin_register_rest_routes() {
25 +function openstation_recycle_bin_register_rest_routes() {
26 26 $namespace = 'desktop-mode/v1';
27 27
28 28 register_rest_route(
29 29 $namespace,
@@ -29,10 +29,10 @@
29 29 $namespace,
30 30 '/recycle-bin',
31 31 array(
32 32 'methods' => WP_REST_Server::READABLE,
33 - 'permission_callback' => 'desktop_mode_recycle_bin_rest_permission',
34 - 'callback' => 'desktop_mode_recycle_bin_rest_list',
33 + 'permission_callback' => 'openstation_recycle_bin_rest_permission',
34 + 'callback' => 'openstation_recycle_bin_rest_list',
35 35 'args' => array(
36 36 'page' => array(
37 37 'type' => 'integer',
38 38 'default' => 1,
@@ -61,10 +61,10 @@
61 61 $namespace,
62 62 '/recycle-bin/restore',
63 63 array(
64 64 'methods' => WP_REST_Server::CREATABLE,
65 - 'permission_callback' => 'desktop_mode_recycle_bin_rest_permission',
66 - 'callback' => 'desktop_mode_recycle_bin_rest_restore',
65 + 'permission_callback' => 'openstation_recycle_bin_rest_permission',
66 + 'callback' => 'openstation_recycle_bin_rest_restore',
67 67 // Accepts either `items: [{id, type}]` (preferred) or
68 68 // `ids: int[]` (legacy — assumes post-ish entities).
69 69 // Both registered as optional; the handler validates.
70 70 'args' => array(
@@ -85,10 +85,10 @@
85 85 $namespace,
86 86 '/recycle-bin/purge',
87 87 array(
88 88 'methods' => WP_REST_Server::CREATABLE,
89 - 'permission_callback' => 'desktop_mode_recycle_bin_rest_permission',
90 - 'callback' => 'desktop_mode_recycle_bin_rest_purge',
89 + 'permission_callback' => 'openstation_recycle_bin_rest_permission',
90 + 'callback' => 'openstation_recycle_bin_rest_purge',
91 91 'args' => array(
92 92 'items' => array(
93 93 'type' => 'array',
94 94 'required' => false,
@@ -106,10 +106,10 @@
106 106 $namespace,
107 107 '/recycle-bin/empty',
108 108 array(
109 109 'methods' => WP_REST_Server::CREATABLE,
110 - 'permission_callback' => 'desktop_mode_recycle_bin_rest_permission',
111 - 'callback' => 'desktop_mode_recycle_bin_rest_empty',
110 + 'permission_callback' => 'openstation_recycle_bin_rest_permission',
111 + 'callback' => 'openstation_recycle_bin_rest_empty',
112 112 )
113 113 );
114 114
115 115 register_rest_route(
@@ -116,29 +116,29 @@
116 116 $namespace,
117 117 '/recycle-bin/count',
118 118 array(
119 119 'methods' => WP_REST_Server::READABLE,
120 - 'permission_callback' => 'desktop_mode_recycle_bin_rest_permission',
120 + 'permission_callback' => 'openstation_recycle_bin_rest_permission',
121 121 'callback' => static function () {
122 122 return rest_ensure_response(
123 - array( 'count' => desktop_mode_recycle_bin_count() )
123 + array( 'count' => openstation_recycle_bin_count() )
124 124 );
125 125 },
126 126 )
127 127 );
128 128 }
129 -add_action( 'rest_api_init', 'desktop_mode_recycle_bin_register_rest_routes' );
129 +add_action( 'rest_api_init', 'openstation_recycle_bin_register_rest_routes' );
130 130
131 131 /**
132 132 * Route-level permission gate.
133 133 *
134 134 * Per-item capability checks happen inside the store layer; here we
135 - * only enforce "logged-in user with desktop mode opted in" — same
135 + * only enforce "logged-in user with OpenStation opted in" — same
136 136 * baseline as every other desktop REST surface.
137 137 *
138 138 * @return bool|WP_Error
139 139 */
140 -function desktop_mode_recycle_bin_rest_permission() {
140 +function openstation_recycle_bin_rest_permission() {
141 141 if ( ! is_user_logged_in() ) {
142 142 return new WP_Error(
143 143 'rest_forbidden',
144 144 __( 'Sorry, you must be logged in.', 'desktop-mode' ),
@@ -144,12 +144,12 @@
144 144 __( 'Sorry, you must be logged in.', 'desktop-mode' ),
145 145 array( 'status' => 401 )
146 146 );
147 147 }
148 - if ( function_exists( 'desktop_mode_is_enabled' ) && ! desktop_mode_is_enabled() ) {
148 + if ( function_exists( 'openstation_is_enabled' ) && ! openstation_is_enabled() ) {
149 149 return new WP_Error(
150 150 'rest_forbidden',
151 - __( 'Desktop mode is not enabled for this user.', 'desktop-mode' ),
151 + __( 'OpenStation is not enabled for this user.', 'desktop-mode' ),
152 152 array( 'status' => 403 )
153 153 );
154 154 }
155 155 return true;
@@ -160,10 +160,10 @@
160 160 *
161 161 * @param WP_REST_Request $request REST request.
162 162 * @return WP_REST_Response
163 163 */
164 -function desktop_mode_recycle_bin_rest_list( $request ) {
165 - $payload = desktop_mode_recycle_bin_get_items(
164 +function openstation_recycle_bin_rest_list( $request ) {
165 + $payload = openstation_recycle_bin_get_items(
166 166 array(
167 167 'page' => (int) $request->get_param( 'page' ),
168 168 'per_page' => (int) $request->get_param( 'per_page' ),
169 169 'type' => (string) $request->get_param( 'type' ),
@@ -179,11 +179,11 @@
179 179 *
180 180 * @param WP_REST_Request $request REST request.
181 181 * @return WP_REST_Response
182 182 */
183 -function desktop_mode_recycle_bin_rest_restore( $request ) {
184 - $items = desktop_mode_recycle_bin_normalize_items( $request );
185 - return rest_ensure_response( desktop_mode_recycle_bin_apply_bulk( $items, 'desktop_mode_recycle_bin_restore' ) );
183 +function openstation_recycle_bin_rest_restore( $request ) {
184 + $items = openstation_recycle_bin_normalize_items( $request );
185 + return rest_ensure_response( openstation_recycle_bin_apply_bulk( $items, 'openstation_recycle_bin_restore' ) );
186 186 }
187 187
188 188 /**
189 189 * POST /recycle-bin/purge
@@ -190,11 +190,11 @@
190 190 *
191 191 * @param WP_REST_Request $request REST request.
192 192 * @return WP_REST_Response
193 193 */
194 -function desktop_mode_recycle_bin_rest_purge( $request ) {
195 - $items = desktop_mode_recycle_bin_normalize_items( $request );
196 - return rest_ensure_response( desktop_mode_recycle_bin_apply_bulk( $items, 'desktop_mode_recycle_bin_purge' ) );
194 +function openstation_recycle_bin_rest_purge( $request ) {
195 + $items = openstation_recycle_bin_normalize_items( $request );
196 + return rest_ensure_response( openstation_recycle_bin_apply_bulk( $items, 'openstation_recycle_bin_purge' ) );
197 197 }
198 198
199 199 /**
200 200 * Read either `items: [{id, type}]` (preferred) or `ids: int[]`
@@ -203,9 +203,9 @@
203 203 *
204 204 * @param WP_REST_Request $request REST request.
205 205 * @return array<int, array{id:int, type:string}>
206 206 */
207 -function desktop_mode_recycle_bin_normalize_items( $request ) {
207 +function openstation_recycle_bin_normalize_items( $request ) {
208 208 $out = array();
209 209
210 210 $items = $request->get_param( 'items' );
211 211 if ( is_array( $items ) ) {
@@ -245,10 +245,10 @@
245 245 * POST /recycle-bin/empty
246 246 *
247 247 * @return WP_REST_Response
248 248 */
249 -function desktop_mode_recycle_bin_rest_empty() {
250 - return rest_ensure_response( desktop_mode_recycle_bin_empty() );
249 +function openstation_recycle_bin_rest_empty() {
250 + return rest_ensure_response( openstation_recycle_bin_empty() );
251 251 }
252 252
253 253 /**
254 254 * Run a per-item callback over a list, capturing per-item results.
@@ -256,9 +256,9 @@
256 256 * @param array<int, array{id:int, type:string}> $items Items to operate on.
257 257 * @param callable $callback `($id, $type) → true|WP_Error`.
258 258 * @return array{ok:int[], errors:array<int, array{id:int, code:string, message:string}>}
259 259 */
260 -function desktop_mode_recycle_bin_apply_bulk( $items, $callback ) {
260 +function openstation_recycle_bin_apply_bulk( $items, $callback ) {
261 261 $ok = array();
262 262 $errors = array();
263 263
264 264 foreach ( $items as $item ) {