Wordpress include("../../../wp-blog-header");失败 [英] Wordpress include("../../../wp-blog-header"); failing

查看:67
本文介绍了Wordpress include("../../../wp-blog-header");失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为Wordpress开发一个涉及大量.php文件的插件.我看到对于我的AddShift.php文件,我们使用以下代码行成功导入了博客标题:

I am currently working on a plugin for Wordpress involving lots of .php files. I see that for my AddShift.php file, we are successfully importing the blog header using the following line of code:

include("../../../wp-blog-header.php");

但是,当我尝试在ajax_cal_split.php文件中执行相同的操作时,出现以下错误:

However, when I try to do the same thing in my ajax_cal_split.php file, I get the following error:

Warning: include(./wp-blog-header.php) [function.include]: failed to open stream: No such file or directory in /opt/lampp/htdocs/sandboxj/blog/wp-content/plugins/Shifty/ajax_cal_split.php on line 11

Warning: include() [function.include]: Failed opening './wp-blog-header.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/sandboxj/blog/wp-content/plugins/Shifty/ajax_cal_split.php on line 11

第11行当然是

include("../../../wp-blog-header.php");

当它们位于同一个目录中时,是否有任何理由使该调用在一个.php文件上起作用而不在另一个文件上起作用?

Is there any reason for this call to work on one .php file and not another, when they reside in the same directory?

推荐答案

是的-我相信wordpress对wp-content目录中的内容运行一种安全机制,我对主题也有同样的问题.我使用的解决方法是包括绝对路径名.

Yes - I believe wordpress operates a security mechanism on content in the wp-content directory, I had the same problem with themes. The workaround I used was to include with absolute path names.

这篇关于Wordpress include("../../../wp-blog-header");失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆