Commit 89173d8
authored
Guidelines: Split singleton REST API into dedicated /content-guidelines route (#77734)
* Guidelines: Split singleton REST API into dedicated /content-guidelines route
Move the content guidelines singleton logic to a new
Gutenberg_Content_Guidelines_REST_Controller mounted at
/wp/v2/content-guidelines so the existing /wp/v2/guidelines collection can
behave like a standard post-type endpoint and serve other guideline posts
(artifacts) with full title/content/excerpt/author CRUD.
The revisions controller now accepts an overrideable parent base and parent
controller so it can be mounted under /content-guidelines while keeping the
singleton response shape on restore.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Content Guidelines: Restrict singleton routes to content-typed posts
Override get_post() and get_parent() so /wp/v2/content-guidelines/{id} and its
revisions sub-routes return 404 for guideline posts that aren't tagged with
the `content` term — those belong on the standard /wp/v2/guidelines collection.
Rename Gutenberg_Guidelines_Revisions_Controller (and its file) to
Gutenberg_Content_Guidelines_Revisions_Controller for symmetry with the REST
controller now that it's mounted exclusively under /content-guidelines.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Content Guidelines Revisions: Drop unused constructor injection
The class is dedicated to the content singleton, so $parent_post_type,
$parent_base, and $parent_controller never need overriding from the call
site. Hardcode the post type and parent base, and instantiate the singleton
controller directly inside restore_revision() when shaping the response.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Register content guideline revisions explicitly
* Content Guidelines: Generalize singleton route doc comments
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Guidelines: Inline artifact type in REST controller test
* Guidelines: Fix post type array alignment
* Guidelines: Add standard REST route coverage
* Guidelines: Map publishing capabilities
* Content Guidelines Revisions: Lock revision deletion to administrators
The inherited WP_REST_Revisions_Controller::delete_item_permissions_check
only requires `delete_post` capability, which editors hold on guideline
posts. The singleton route is admin-managed for every other write —
align revision deletion with that rule.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Guidelines: Rename standard REST test file
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: gziolo <gziolo@git.wordpress.org>1 parent c35d338 commit 89173d8
10 files changed
Lines changed: 790 additions & 264 deletions
File tree
- lib/experimental/guidelines
- phpunit/experimental/guidelines
- routes/guidelines
- test/e2e/specs/admin
Lines changed: 50 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | | - | |
| 19 | + | |
18 | 20 | | |
19 | | - | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
39 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
40 | 77 | | |
41 | 78 | | |
42 | 79 | | |
43 | | - | |
| 80 | + | |
44 | 81 | | |
45 | 82 | | |
46 | 83 | | |
| |||
206 | 243 | | |
207 | 244 | | |
208 | 245 | | |
209 | | - | |
| 246 | + | |
210 | 247 | | |
211 | | - | |
| 248 | + | |
| 249 | + | |
212 | 250 | | |
213 | 251 | | |
214 | 252 | | |
| |||
265 | 303 | | |
266 | 304 | | |
267 | 305 | | |
268 | | - | |
| 306 | + | |
269 | 307 | | |
270 | 308 | | |
271 | 309 | | |
| |||
568 | 606 | | |
569 | 607 | | |
570 | 608 | | |
571 | | - | |
| 609 | + | |
572 | 610 | | |
573 | 611 | | |
574 | 612 | | |
| |||
613 | 651 | | |
614 | 652 | | |
615 | 653 | | |
616 | | - | |
| 654 | + | |
617 | 655 | | |
618 | 656 | | |
619 | 657 | | |
| |||
0 commit comments