Skip to content

Handle wp_error for /wp-json #605

@jkmassel

Description

@jkmassel

There are plugins that emit a WP_Error when the REST API is disabled. This is pretty standard behaviour (return a valid response shape, or else a WP_Error) for the rest of the API, so we should handle it as an application-level error in the library.

Here are two example responses:

{
  "code": "rest_forbidden",
  "message": "REST API access is restricted.",
  "data": {
    "status": 403
  }
}
{
  "code": "rest_not_logged_in",
  "message": "You are not currently logged in.",
  "data": {
    "status": 401
  }
}

Example Plugins:

For login specifically, we should have the ability to scan the code field and have a list of signatures (similar to what we use for the list of plugins that block Application Passwords) and tie that back to a specific plugin so we can tell the user "You have plugin xxxx installed, and the JSON API is disabled because of it. You'll need to disable this plugin to use the app"

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions