PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.8.7
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.8.7
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
desktop-mode / includes / rest / README.md

README.md in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 0.8.7, at includes/rest/README.md

44 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # `includes/rest/` — REST route map
2
3 Discoverability index for the REST surface. Routes are still registered in their owning subsystem files (where the callback closures and module state live), so moving the `register_rest_route()` calls into a single directory would have been a paperwork rename that broke nothing and improved nothing. This document is the central grep target instead.
4
5 Plugin authors looking for the canonical route URL → handler map start here; the implementation file is one open away.
6
7 ## Namespace
8
9 All in-tree routes register under `desktop-mode/v1`. Extensions are expected to register under `desktop-mode-<extension>/v1` (the `extensions/base/Desktop_Mode_Extension_Rest` base enforces this).
10
11 ## Routes
12
13 | Route | Verb | Handler file | Permission |
14 |---|---|---|---|
15 | `/session` | GET / POST / DELETE | `includes/session.php` | logged-in + `read` |
16 | `/default-window` | GET / POST | `includes/default-window.php` | logged-in + `read` |
17 | `/seen-intros` | GET / POST | `includes/seen-intros.php` | logged-in + `read` |
18 | `/os-settings` | GET / POST | `includes/os-settings.php` | logged-in + `read` |
19 | `/extended-options/*` | various | `includes/extended-options.php` | `manage_options` |
20 | `/pwa/*` | various | `includes/pwa.php` | logged-in + `read` |
21 | `/devtools/*` | various | `includes/devtools.php` | `manage_options` |
22 | `/presence` | GET | `includes/presence.php` | logged-in + `read` |
23 | `/posts/*` | various | `includes/posts-window/window.php` | `edit_posts` |
24 | `/my-wordpress/comments/*` | various | `includes/my-wordpress/comment-stats.php` | `read` |
25 | `/my-wordpress/terms/*` | various | `includes/my-wordpress/term-stats.php` | `read` |
26 | `/my-wordpress/users/*` | various | `includes/my-wordpress/user-stats.php` | `list_users` |
27 | `/recycle-bin/*` | various | `includes/recycle-bin/rest.php` | `delete_posts` (per-route gate) |
28 | `/desktop-files/*` | various | `includes/desktop-files/rest.php` | logged-in + per-file caps |
29 | `/ai/search` | POST | `includes/ai-copilot/search.php` | logged-in + AI feature flag |
30 | `/ai/platform-settings` | GET / POST | `includes/ai-copilot/platform-settings.php` | `manage_options` |
31 | `/ai/reindex` | POST | `includes/ai-copilot/reindex.php` | `manage_options` |
32
33 ## Conventions
34
35 - **Nonce.** Every state-changing route requires `X-WP-Nonce` (the standard REST nonce). Read routes that depend on per-user state also require it.
36 - **Permission.** Permission callbacks use either `is_user_logged_in()` + capability checks or domain predicates (`desktop_mode_is_enabled()` for shell-internal endpoints). Filtering with `desktop_mode_*` hooks lets plugins extend or harden access.
37 - **Errors.** Failures return `WP_Error` with a stable `code`, a translated `message`, and a `data: { status: <int> }` block. Codes are documented per-endpoint in `docs/hooks-reference.md`.
38
39 ## Why no central registration
40
41 PHP `register_rest_route()` calls execute on `rest_api_init`. The callback closures in the existing files capture per-module state — the recycle-bin store, the desktop-files registry, the AI provider — that lives in the same module. Moving the registration calls out of those files would force every callback to re-look-up its dependencies, increasing surface area without reducing coupling. The route → handler-file map above is the discoverability win we wanted; the per-module registrations are the layout that minimises blast radius.
42
43 If a future extension adds REST routes that don't fit any existing module, the `extensions/base/Desktop_Mode_Extension_Rest` base class is the cheapest path. See `extensions/base/README.md`.
44