[wp-trac] [WordPress Trac] #35329: Permit rest_do_request() to be used in non-REST API contexts

WordPress Trac noreply at wordpress.org
Wed Jan 6 16:07:15 UTC 2016


#35329: Permit rest_do_request() to be used in non-REST API contexts
-----------------------------+------------------------------------------
 Reporter:  danielbachhuber  |      Owner:
     Type:  enhancement      |     Status:  new
 Priority:  normal           |  Milestone:  4.5
Component:  REST API         |    Version:
 Severity:  normal           |   Keywords:  needs-patch needs-unit-tests
  Focuses:                   |
-----------------------------+------------------------------------------
 `rest_do_request()` currently requires `$wp_rest_server` to be properly
 instantiated:

 {{{
 function rest_do_request( $request ) {
     global $wp_rest_server;
     $request = rest_ensure_request( $request );
     return $wp_rest_server->dispatch( $request );
 }
 }}}

 We should improve it such that it initializes `$wp_rest_server` if it
 isn't already loaded, such that you could use `rest_do_request()` in a
 non-REST API context.

 @joehoyle wrote an [https://gist.github.com/joehoyle/e7321570525af6daeae2
 equivalent function] we can crib from.

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


More information about the wp-trac mailing list