Skip to content

Commit

Permalink
When 'rest_route' URL var is used it's a REST request
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzap committed Oct 19, 2021
1 parent 3aca602 commit d41b3b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/WpContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ final public static function determine(): WpContext
*/
private static function isRestRequest(): bool
{
if (defined('REST_REQUEST') && REST_REQUEST) {
if (
(defined('REST_REQUEST') && REST_REQUEST)
|| !empty($_GET['rest_route']) // phpcs:ignore
) {
return true;
}

if (!get_option('permalink_structure')) {
return !empty($_GET['rest_route']); // phpcs:ignore
return false;
}

/*
Expand Down

0 comments on commit d41b3b5

Please sign in to comment.