WordPress plugin intelligence profile

GP routing – WP compatible REST API

Allows developers to create REST-ish API's that have access to all of Wordpress and its plug-ins objects.

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 4.3
Current version1.0
WordPress coverageTested up to WordPress 4.3
Minimum stackWP 3.0.1 · PHP —
Directory statusactive
Last directory update27 Nov 201510y ago
Active installationsNewAdoption metric — not a quality score
WordPress.org ratingNo WordPress.org ratings yet
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records GP routing – WP compatible REST API version 1.0 as active, updated 10y ago and tested up to WordPress 4.3.

Overview

About this plugin

Allows developers to create REST-ish API’s that have access to all of WordPress and its plug-ins objects.

Usage

Install the plug-in as any other plug-in.

Project is divided in two sets of files:

php - This is where you register routes and/or middleware. * routes/ - This is where you place your routes.

Middleware

Middlewares are functions that will be executed on every call to the API, generally used to validate parameters or

transform requests before they reach routes, code for middleware is structured like this:

app::middleware(function () { doSomething(); });

  • Middlewares run for every Verb and do not automatically assign $_POST or $_GET to any variable

Routes

A route is where you would link a request to a function depending on its HTTP Verb.

The routing engine will prepend /api/ to all calls and will append a trailing slash to all requests.

A GET request would be matched like this:

app::get('/testget', function($req){ return $req; });

In which:

* app::get - This will match up a GET request. * '/testget' - the path the routing engine will look for. * function(){ }...

- the function to execute when the route is matched. * $req - parameters sent to the verb.

To make a call to this route, the full path would be:

com/api/testget/

  • The trailing slash is always required.
  • Parameters for all routes will be sent as the first parameter to the callback.

A route should be registered on the index file by placing a call to app::routes with the filename of the route (without the extension) as a parameter:

app::routes('test');

  • All routes output their return value as a JSON encoded response.

Samples for all verbs

-

GET:

app::get(‘/testget’, function($req){

return $req;

});

-

POST:

app::post(‘/testpost’, function($req){

return $req;

});

-

DELETE:

app::delete(‘/testdelete’, function($req){

return $req;

});

-

PUT:

app::put(‘/testput’, function($req){

return $req;

});

Nested routes

Routes can be nested like this:

app::delete('/admin/machines', function($req){ return $req; });

Which could be called by issuing a DELETE to:

php file like this:

function gp_registerapimethods()

{

app::middleware(function () {

});

app::routes('test');

}

php file.

Middleware and Routes can have as many instances as needed.

All routes inside the routes folder can be registered by doing this call instead of the individual route registration:

php route a call for each verb which you could use as a starting point for your own services.

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • api
  • rest
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 4.3

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 4.3.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to4.3
Minimum requirementsWordPress 3.0.1 · PHP not listed
Update activity27 Nov 201510y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.