wpup/functions

将函数引入WordPress REST API

安装: 5

依赖项: 0

建议者: 0

安全: 0

星标: 4

关注者: 3

分支: 2

开放问题: 0

类型:wordpress-plugin

v1.0.0 2018-10-31 15:29 UTC

This package is auto-updated.

Last update: 2024-08-29 05:06:20 UTC


README

No Maintenance Intended

将函数引入WordPress REST API。

示例

wp-content/themes/NAME/functions/hello.php 中创建 hello.php

<?php

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

调用它

GET /wp-json/functions/v1/hello

"Hello, world"

每个函数文件支持以下HTTP方法:

GET, POST, PUT, PATCH, DELETE

也支持命名空间和类。

<?php

namespace MyNamespace;

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

安装

composer require wpup/functions

过滤器

关于过滤器的简短文档,阅读源代码以了解更多关于每个过滤器的信息。

  • functions_file - 修改文件路径
  • functions_handle - 修改用于 call_user_func 的函数/方法字符串名称
  • functions_directories - 修改插件应扫描函数文件的目录。默认为 wp-content/themes/NAME/functions

许可证

MIT © Fredrik Forsmo