Skip to content

wpup/functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API Functions

No Maintenance Intended

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