#61639 closed enhancement (fixed)
REST API: Posts/Pages endpoint prefixes private pages titles.
Reported by: | youknowriad | Owned by: | youknowriad |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | has-patch has-unit-tests |
Focuses: | rest-api | Cc: |
Description (last modified by )
Discovered in https://github.com/WordPress/gutenberg/issues/56154
When using the /posts or /pages, REST API, for private posts or pages, you get the following title property:
title: { raw: "Some title", rendered: "Private: Some title" }
I would like to understand more why did we decide to prefix the rendered titles here knowing that we already have the information about the status separately.
Maybe I'm misunderstanding what "rendered" property is about, but IMO we should consider removing these prefixes as REST API clients should have access to the rendered title without it (like the linked example above: render the title in the list views)
Change History (6)
#2
@
3 weeks ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Type changed from defect (bug) to enhancement
- Version set to 4.7
This ticket was mentioned in PR #7019 on WordPress/wordpress-develop by @youknowriad.
3 weeks ago
#3
- Keywords has-patch has-unit-tests added; needs-patch removed
When using the /posts or /pages, REST API, for private posts or pages, you get the following title property:
title: { raw: "Some title", rendered: "Private: Some title" }
As discussed on the trac ticket, this PR removes the prefix from private posts (just like what we do for protected posts)
#5
@
13 days ago
- Owner set to youknowriad
- Resolution set to fixed
- Status changed from new to closed
In 58783:
I don't think there was a conscious decision to explicitly add this to the REST API. It simply uses
get_the_title()
internally which happens to add the "Private:" prefix (but only if you are not in the admin!).By default,
get_the_title()
adds a "Protected:" prefix too, but the REST API removes it (see\WP_REST_Posts_Controller::protected_title_format()
). This was added in https://github.com/WP-API/WP-API/pull/2720 because you can still access a protected post in the API, but you can't see the content & excerpt fields.For consistency reasons it sounds reasonable to me to omit the prefix for "Private" as well. Would probably be good to mention it in a misc dev note if it lands.
---
Aside:
Private:
for empty private pages is just wrong IMO.