检索WordPress根目录路径? [英] Retrieve WordPress root directory path?
本文介绍了检索WordPress根目录路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 WordPress CMS 中检索根目录的路径?
How can I retrieve the path to the root directory in WordPress CMS?
推荐答案
注意:这个答案真的很陈旧,从那以后,WordPress 领域可能已经发生了变化.
我猜您需要从您的插件或主题中检测 WordPress 根.我在 FireStats 中使用以下代码来检测安装 FireStats 的 WordPress 插件的根 WordPress 目录.
I am guessing that you need to detect the WordPress root from your plugin or theme. I use the following code in FireStats to detect the root WordPress directory where FireStats is installed a a WordPress plugin.
function fs_get_wp_config_path()
{
$base = dirname(__FILE__);
$path = false;
if (@file_exists(dirname(dirname($base))."/wp-config.php"))
{
$path = dirname(dirname($base))."/wp-config.php";
}
else
if (@file_exists(dirname(dirname(dirname($base)))."/wp-config.php"))
{
$path = dirname(dirname(dirname($base)))."/wp-config.php";
}
else
$path = false;
if ($path != false)
{
$path = str_replace("\\", "/", $path);
}
return $path;
}
这篇关于检索WordPress根目录路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文