WordPress/wp-includes/rest-api/endpoints
Felix Arntz e19c18cba9 Bootstrap/Load: Introduce functions to check whether WordPress is serving a REST API request.
This changeset introduces two functions:
* `wp_is_serving_rest_request()` returns a boolean for whether WordPress is serving an actual REST API request.
* `wp_is_rest_endpoint()` returns a boolean for whether a WordPress REST API endpoint is currently being used. While this is always the case if `wp_is_serving_rest_request()` returns `true`, the function additionally covers the scenario of internal REST API requests, i.e. where WordPress calls a REST API endpoint within the same request.

Both functions should only be used after the `parse_request` action.

All relevant manual checks have been adjusted to use one of the new functions, depending on the use-case. They were all using the same constant check so far, while in fact some of them were intending to check for an actual REST API request while others were intending to check for REST endpoint usage.

A new filter `wp_is_rest_endpoint` can be used to alter the return value of the `wp_is_rest_endpoint()` function.

Props lots.0.logs, TimothyBlynJacobs, flixos90, joehoyle, peterwilsoncc, swissspidy, SergeyBiryukov, pento, mikejolley, iandunn, hellofromTonya, Cybr, petitphp.
Fixes #42061.

Built from https://develop.svn.wordpress.org/trunk@57312


git-svn-id: http://core.svn.wordpress.org/trunk@56818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-19 17:40:09 +00:00
..
class-wp-rest-application-passwords-controller.php Application Passwords: Allow a Super Admin to set an application password on a site they're not a member of. 2022-08-11 18:24:09 +00:00
class-wp-rest-attachments-controller.php Bootstrap/Load: Introduce functions to check whether WordPress is serving a REST API request. 2024-01-19 17:40:09 +00:00
class-wp-rest-autosaves-controller.php REST API: Fix issue with Template and Template Part Revision/Autosave REST API controllers. 2023-10-10 14:05:21 +00:00
class-wp-rest-block-directory-controller.php REST API: Avoid unnecessarily preparing item links. 2022-07-22 14:00:12 +00:00
class-wp-rest-block-pattern-categories-controller.php REST API: Cache schema in block pattern and menu item endpoints. 2023-06-28 15:53:26 +00:00
class-wp-rest-block-patterns-controller.php REST API: Cache schema in block pattern and menu item endpoints. 2023-06-28 15:53:26 +00:00
class-wp-rest-block-renderer-controller.php
class-wp-rest-block-types-controller.php REST API: Improve the block type schema for the name field 2023-09-25 10:03:38 +00:00
class-wp-rest-blocks-controller.php Coding Standards: Remove extra space in a comment in WP_REST_Blocks_Controller. 2023-10-31 14:23:21 +00:00
class-wp-rest-comments-controller.php REST API: Pass correct number of arguments to the comment_text filter. 2023-12-09 22:13:34 +00:00
class-wp-rest-controller.php Coding Standards: Include one space after function keyword for closures. 2023-09-12 15:23:18 +00:00
class-wp-rest-edit-site-export-controller.php Theme: Use a better method to determine the theme name during export 2022-05-17 12:10:14 +00:00
class-wp-rest-global-styles-controller.php Coding Standards: Remove redundant ignore annotations, take 5. 2023-10-02 11:27:24 +00:00
class-wp-rest-global-styles-revisions-controller.php Docs: Fix indentation issue in WP_REST_Global_Styles_Revisions_Controller class. 2023-07-19 22:53:23 +00:00
class-wp-rest-menu-items-controller.php REST API: Correct the docblocks for various permission related methods. 2023-08-18 17:46:18 +00:00
class-wp-rest-menu-locations-controller.php Coding Standards: Restore more descriptive variable names in a few class methods. 2023-09-14 12:46:20 +00:00
class-wp-rest-menus-controller.php REST API: Correct the docblocks for various permission related methods. 2023-08-18 17:46:18 +00:00
class-wp-rest-navigation-fallback-controller.php General: Remove discouraged @return void annotations. 2023-10-16 15:17:23 +00:00
class-wp-rest-pattern-directory-controller.php Coding Standards: Remove redundant ignore annotations, take 5. 2023-10-02 11:27:24 +00:00
class-wp-rest-plugins-controller.php Coding Standards: Include one space after function keyword for closures. 2023-09-12 15:23:18 +00:00
class-wp-rest-post-statuses-controller.php Coding Standards: Restore more descriptive variable names in a few class methods. 2023-09-14 12:46:20 +00:00
class-wp-rest-post-types-controller.php Coding Standards: Restore more descriptive variable names in a few class methods. 2023-09-14 12:46:20 +00:00
class-wp-rest-posts-controller.php Docs: Document the $post global in REST API posts and revisions controllers. 2023-12-28 15:19:20 +00:00
class-wp-rest-revisions-controller.php Docs: Document the $post global in REST API posts and revisions controllers. 2023-12-28 15:19:20 +00:00
class-wp-rest-search-controller.php Coding Standards: Restore more descriptive variable names in a few class methods. 2023-09-14 12:46:20 +00:00
class-wp-rest-settings-controller.php Coding Standards: Remove superfluous blank lines at the end of various functions. 2023-09-08 10:03:21 +00:00
class-wp-rest-sidebars-controller.php Coding Standards: Restore more descriptive variable names in a few class methods. 2023-09-14 12:46:20 +00:00
class-wp-rest-site-health-controller.php Coding Standards: Include one space after function keyword for closures. 2023-09-12 15:23:18 +00:00
class-wp-rest-taxonomies-controller.php Coding Standards: Restore more descriptive variable names in a few class methods. 2023-09-14 12:46:20 +00:00
class-wp-rest-template-autosaves-controller.php REST API: Fix issue with Template and Template Part Revision/Autosave REST API controllers. 2023-10-10 14:05:21 +00:00
class-wp-rest-template-revisions-controller.php REST API: Fix issue with Template and Template Part Revision/Autosave REST API controllers. 2023-10-10 14:05:21 +00:00
class-wp-rest-templates-controller.php REST API: Fix issue with Template and Template Part Revision/Autosave REST API controllers. 2023-10-10 14:05:21 +00:00
class-wp-rest-terms-controller.php REST API: Correct the docblocks for various permission related methods. 2023-08-18 17:46:18 +00:00
class-wp-rest-themes-controller.php Coding Standards: Restore more descriptive variable names in a few class methods. 2023-09-14 12:46:20 +00:00
class-wp-rest-url-details-controller.php Bootstrap/Load: Introduce functions to check whether WordPress is serving a REST API request. 2024-01-19 17:40:09 +00:00
class-wp-rest-users-controller.php REST API: Limit search_columns for users without list_users. 2023-10-12 12:30:20 +00:00
class-wp-rest-widget-types-controller.php Coding Standards: Restore more descriptive variable names in a few class methods. 2023-09-14 12:46:20 +00:00
class-wp-rest-widgets-controller.php Coding Standards: Include one space after function keyword for closures. 2023-09-12 15:23:18 +00:00