下面是一个示例。。。
//..path/to/wp-content/plugins/your-plugin-basedir/
$path = plugin_dir_path( __FILE__);
//..directory within your plugin
$path .= \'templates\';
//..continue with your script...
$dir_handle = @opendir($path) or die("Cannot open the damn file $path");
顺便说一下,我测试了脚本的其余部分,看看它是否确实读取了目录并列出了带有*的文件。php扩展,它不会工作。
而是在将其修改为之后;
$dir_handle = @opendir($path) or die("Cannot open the damn file $path");
while ($file = readdir($dir_handle)) {
//get length of filename inc. extension
$length_of_filename = strlen($file);
//strip all but last three characters from file name to get extension
$ext = substr($file, -3, $length_of_filename);
if($ext == "php" ) {
$TheLinkedFile = $path."/".$file;
if(file_exists($TheLinkedFile)) {
echo $TheLinkedFile.\'<br>\';
} else {
echo "nothing";
}
}
}
closedir($dir_handle);
它起作用了。。。