WP Manifestindependent plugin directory
manifest / developer / functions

WordPress REST API Functions

Bring functions into WordPress REST API

★ 5stars
5composer installs
v1.0.0latest · 7 years ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/wpup/functions/archive/refs/heads/master.zip

On Packagist as wpup/functions:

composer require wpup/functions
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

REST API Functions

Bring functions into WordPress REST API.

Example

Create hello.php in wp-content/themes/NAME/functions/hello.php

<?php

function handler($request) {
    return 'Hello, world';
}

Call it

GET /wp-json/functions/v1/hello

"Hello, world"

Supported HTTP methods for each function file are:

GET, POST, PUT, PATCH, DELETE

Namespaces and classes are supported as well.

<?php

namespace MyNamespace;

class MyClass {
    public function handler($request) {
        return 'Hello, world';
    }
}

Install

composer require wpup/functions

Filters

Short documenation about filters, read the source code to find out more about each filter.

  • functions_file - Modify file path
  • functions_handle - Modify function/method string name (that are used for call_user_func)
  • functions_directories - Modify which directories the plugin should scan for functions files. Default is wp-content/themes/NAME/functions

License

MIT © Fredrik Forsmo

Releases

1 release.

Tag
Published
v1.0.0 latest
Oct 31, 2018 7 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.