我正在开发一个只包含REST API查询的插件。它只包括myplugin.php 和模板文件(index.php, style.css &;functions.js) 与已安装的WP主题没有连接。
插件应可通过URL访问:example.com/myplugin, 这是我在plugin.php:
add_action(\'init\', function () {
add_rewrite_rule(\'myplugin\', \'wp-content/plugins/myplugin/theme/index.php\', \'top\');
});
在
index.php 不幸的是,我只能通过绝对路径包含两个外部脚本(.css、.js),因为如果我在
plugin.php, 未在中输出
index.php.
如何集成模板(index.php) 这样它就可以访问之前定义的变量?