wpup / functions
将函数引入WordPress REST API
v1.0.0
2018-10-31 15:29 UTC
Requires
- php: ^7.0
- composer/installers: ~1.0
Requires (Dev)
- frozzare/wp-test-suite: ~1.0
- wp-coding-standards/wpcs: dev-develop
This package is auto-updated.
Last update: 2024-08-29 05:06:20 UTC
README
将函数引入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