我有一个JS/PHP文件在wordpress插件file.js.php中结合。wordpress检测插件路径到根
问题是 - 我需要包含一个wordpress文件以便能够使用GLOBALS和wp函数。
我的问题有两个部分:
1 - 该文件是最好的一个,包括(安全性,性能等)
2 - 我怎样才能找到他的路径表示文件 - 假设我不能使用plugins_url()包含它来识别路径或wp root?
现在我使用:
include("../../../../wp-load.php");
或
require_once (dirname(dirname(dirname(dirname(dirname (__FILE__))))).'/wp-config.php');
但是,当然,这是一个半硬编码的方法。它不会提供任何保障,如果内容”或‘插件’目录移到...
的问题进行了概述,并同时解决了这个问题浮出水面:PHP constant inside JS file