[wp-trac] [WordPress Trac] #53656: Not possible to get a post type's REST API namespace if modified

WordPress Trac noreply at wordpress.org
Fri Sep 17 10:41:09 UTC 2021


#53656: Not possible to get a post type's REST API namespace if modified
--------------------------+-----------------------------
 Reporter:  swissspidy    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  REST API      |     Version:  4.7
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+-----------------------------

Comment (by swissspidy):

 @TimothyBlynJacobs even `rest_get_route_for_post()` has this same problem,
 as the `wp/v2` namespace is hardcoded there. But at least there's a
 filter.

 To fix this, `WP_REST_Controller` needs a getter to access `$namespace`
 and `$rest_base`. Then functions like `rest_get_route_for_post()` or a
 potential `rest_get_route_for_post_type()` could get the REST controller
 for the entity and get the route via those getters.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53656#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list