[wp-trac] [WordPress Trac] #54087: A plugin can't change the parameters of a REST API endpoint

WordPress Trac noreply at wordpress.org
Wed Sep 8 17:27:10 UTC 2021


#54087: A plugin can't change the parameters of a REST API endpoint
---------------------------+-----------------------------
 Reporter:  antonvlasenko  |      Owner:  (none)
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  REST API       |    Version:  trunk
 Severity:  normal         |   Keywords:
  Focuses:  rest-api       |
---------------------------+-----------------------------
 Sometimes a plugin needs to change the parameters of an already registered
 REST API endpoint.
 Now we need to override the whole WP_REST_Controller::register_routes
 method to achieve it. Unfortunately, that leads to code duplication, and
 that is not the best practice.
 See an example of this here:
 [https://github.com/WordPress/gutenberg/blob/trunk/lib/class-wp-rest-menu-
 items-controller.php#L26].

 We should add a new filter (add_filter) at the very beginning of the
 register_rest_route's function body. That filter must allow to modify all
 arguments of the register_rest_route function.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54087>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list