注册功能该去哪里?( register_rest_route()
)
- 它必须在主题/子functions.php中吗?
- 或者它可以在插件基础 php 文件中吗?(例如 \wp-content\plugins\example\example.php)
是否有任何文件可以澄清这一点?
官方文档中没有提到它: https ://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/
同样,端点函数必须存储在哪里?注册函数只命名它,而不指定它的路径。
例如,你可以这样做:
- 注册函数调用 (
register_rest_route
) 进入主插件文件(例如 \wp-content\plugins\example\example.php) - 端点函数位于其他插件文件中(例如 \wp-content\plugins\example\sub-path-stuff\example-controller.php)
如果是这样,怎么做?
以下链接似乎尝试这样做,但没有指定这些属性(例如 \wp-content\plugins\example\example.php)