[wp-trac] [WordPress Trac] #45265: REST API: register_rest_route should warn when used improperly.
WordPress Trac
noreply at wordpress.org
Fri Nov 2 14:51:36 UTC 2018
#45265: REST API: register_rest_route should warn when used improperly.
--------------------------+-----------------------------
Reporter: kraftbj | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Keywords: has-patch
Focuses: rest-api |
--------------------------+-----------------------------
According to the [https://developer.wordpress.org/rest-api/extending-the-
rest-api/routes-and-endpoints/#creating-endpoints documentation], REST API
endpoints should be hooked onto the `rest_api_init` action.
When this function is fired without a hook or on the wrong hook, it can
result in unexpected behavior. For example, calling it directly from a mu-
plugin to add an endpoint on a namespace that is also defined on the
`rest_api_init` hook will result in the mu-plugin directly-called version
completely overriding the namespace, instead of the expected merging to
the namespace.
To help ensure intended use, we should `_doing_it_wrong` when
register_rest_route is used outside of the expected hook.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45265>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list