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

WordPress Trac noreply at wordpress.org
Tue Oct 5 15:42:36 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 TimothyBlynJacobs):

 Replying to [comment:3 swissspidy]:
 > 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.

 IMO instead of exposing a getter to access this info, we should follow the
 `rest_base` paradigm and add a `rest_namespace` argument when registering
 the post type. I don't think we should be reaching into the controller
 instance.

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


More information about the wp-trac mailing list