Last active
June 4, 2019 13:48
-
-
Save wpsmith/8ca175ed362e78b4e7761907a5cac1b9 to your computer and use it in GitHub Desktop.
PHP: Determines whether the request is a WordPress API request.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Determines whether the current request is a RESTful request. | |
* | |
* @return bool | |
*/ | |
function is_rest() { | |
return ( | |
( defined( 'REST_REQUEST' ) && REST_REQUEST ) || | |
( isset( $GLOBALS['wp'] ) && ! empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment