humanmade / humanmade/Mercator-Redirect

`REST_REQUEST` is defined after `plugins_loaded`.

Open
#11 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
PHP
Stars
14
Forks
10
PR merge metrics
No merged PRs in 30d

Description

The plugin runs the following on the `plugins_loaded` hook to determine if the site is making a rest request.

```php
// Don't redirect REST API requests
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
return;
}
```

Unfortunately, `REST_REQUEST` is only defined after the plugins have loaded so after the code above is passed.

Moving the redirect to the `send_headers` action works around this.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the plugin code that checks REST_REQUEST on the plugins_loaded hook and trace how the redirect is registered. Verify the behavior for a REST request, then confirm that moving the redirect to send_headers prevents REST API requests from being redirected.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.