0
我试图将Wordpress安装中的插件目录中的单个文件复制到Wordpress安装的根目录。无论安装位于何处,我都需要该功能来执行此操作。这是我的Wordpress插件,它似乎并没有在我测试的网站上工作。将文件复制到主目录中的问题PHP
不知何故,我在想我并没有在我的function destpath()
函数中捕获每个可能的目录位置。我需要它成功找到Plugin文件夹的确切目录,以便它将文件(process.php)复制到确切的根目录,而不管Wordpress安装的位置。
function destpath()
{
$base = dirname(__FILE__);
$path = false;
if (@file_exists(dirname(dirname($base))."/wp-config.php")) {
$path = dirname(dirname($base))."/process.php";
} else
if (@file_exists(dirname(dirname(dirname($base)))."/wp-config.php")) {
$path = dirname(dirname(dirname($base)))."/process.php";
} else
$path = false;
if ($path != false) {
$path = str_replace("\\", "/", $path);
}
return $path;
}
function pluginpath()
{
$base = dirname(__FILE__);
$path = false;
if (@file_exists(dirname(dirname($base))."/wp-content/plugins/malware finder/process.php")) {
$path = dirname(dirname($base))."/wp-content/plugins/malware finder/process.php";
} else
if (@file_exists(dirname(dirname(dirname($base)))."/wp-content/plugins/malware finder/process.php")) {
$path = dirname(dirname(dirname($base)))."/wp-content/plugins/malware finder/process.php";
} else
$path = false;
if ($path != false) {
$path = str_replace("\\", "/", $path);
}
return $path;
}
copy(pluginpath(), destpath());
您是否检查了您的文件夹的权限? – 2012-03-27 21:14:18
检查您的日志文件,以获取可能的权限错误 – 2012-03-27 21:22:45
我更改了Wordpress安装顶部的所有子目录的权限。仍然没有变化。感谢您的好建议。 – 2012-03-27 21:26:12