Bring functions into WordPress REST API.
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';
}
}
composer require wpup/functions
Short documenation about filters, read the source code to find out more about each filter.
functions_file
- Modify file pathfunctions_handle
- Modify function/method string name (that are used forcall_user_func
)functions_directories
- Modify which directories the plugin should scan for functions files. Default iswp-content/themes/NAME/functions
MIT © Fredrik Forsmo