[wp-trac] [WordPress Trac] #41273: WP REST API: allow separate add_post_type_support() for post when accessing via REST vs WP Admin
WordPress Trac
noreply at wordpress.org
Sat Jul 8 13:17:34 UTC 2017
#41273: WP REST API: allow separate add_post_type_support() for post when accessing
via REST vs WP Admin
-----------------------------+-----------------------------
Reporter: lougreenwood | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.8
Severity: normal | Keywords:
Focuses: rest-api |
-----------------------------+-----------------------------
I have a number of CPTs where I have disabled various features
(post_title, author etc) so that these fields are disabled in WP Admin.
However, I have code which is triggered aftershave which auto-sets values
for these fields. The reason for disabling the fields in WP Admin is to
maintain the integrity of these field values and know that the post_title
will always be an auto-set value.
I also have functional tests which use WP REST API to check that these
post_titles are automatically set correctly.
It seems that when features are disabled using add_post_type_support(),
its not possible to override this when accessing WP REST API. this means
that in my scenario it's not possible to pass my tests because post_title
is not present in REST API response (because it's disabled using
add_post_type_support())
I have an idea for a short term hack, which is to check for user ID or
role (to identify a test user which I used by functional tests) and then
enable these features when REST API is being used. but it seems overly
hacky.
Is there any plan for separating add_post_type_support() for REST and
standard WP?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41273>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list