[wp-trac] [WordPress Trac] #42061: Add new utility function for checking if the current request is a REST API request.

WordPress Trac noreply at wordpress.org
Wed Apr 8 18:57:28 UTC 2026


#42061: Add new utility function for checking if the current request is a REST API
request.
-------------------------------------------------+-------------------------
 Reporter:  lots.0.logs                          |       Owner:
                                                 |  TimothyBlynJacobs
     Type:  enhancement                          |      Status:  closed
 Priority:  normal                               |   Milestone:  6.5
Component:  Bootstrap/Load                       |     Version:  4.9
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch dev-feedback commit has-   |     Focuses:  rest-api,
  unit-tests add-to-field-guide                  |  performance
-------------------------------------------------+-------------------------

Comment (by johnjamesjacoby):

 Just found this!

 From a code-completion standpoint and the benefit of hindsight,
 `wp_is_serving_rest_request()` should have been `wp_doing_rest()` because
 that's the established pattern even if it isn't perfect for its context.
 The convenience of typing or searching for `wp_doing_` and your IDE
 showing all of the similar constant wrappers is hard to beat, plus we all
 know what those functions are intending to do.

 `_serving_` is a brand new unique verb without a need for any other
 `wp_is_serving_` functions. It's longer for no benefit, doesn't pair
 nicely with `wp_is_rest_endpoint()`, and introduces doubt as to what is
 going on internally in both functions.

 I'd still like to see `wp_doing_rest()` happen, along with
 `wp_doing_cli()` in a new ticket.

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


More information about the wp-trac mailing list