tags:

views:

308

answers:

2

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");

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

Line 11 of course says

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

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

A: 

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.

Ninefingers
hrmm... I tried that, but I get the same issue... Trying it again real fast.Doing this gives me:http:// wrapper is disabled in the server configuration by allow_url_include=0 in /opt/lampp/htdocs/sandboxj/blog/wp-content/plugins/Shifty/ajax_cal_split.php on line 11
Sakamoto Kazuma
allow_url_include is a php setting, I have mine set to Off in /etc/php5/apache2/php.ini (ubuntu)... not sure what's going on there! Seems like it should work. When you use absolute paths are you doing that with the file system /opt/lampp/... or http://....?
Ninefingers
You can't have a `http://` in your absolute path. Your absolute path should look like this: `/opt/lampp/htdocs/sandboxj/blog`
Pekka
Second pekka - unless you enable allow_url_include, which you don't want to do for security reasons. Sorry, I should have said filesystem.
Ninefingers
Hrmm... This gets rid of the initial errors, but I'm getting Fatal error: Call to undefined function get_option() in /opt/lampp/htdocs/sandboxj/blog/wp-content/plugins/Shifty/ajax_cal_split.php on line 243 now when I call the ajax functions for ajax_cal_split ....
Sakamoto Kazuma
That must be some inherent problem in your file (e.g. a missing include somewhere), it has nothing to do with the include I believe.
Pekka
Is there something specific I need to have for get_option then?
Sakamoto Kazuma
A: 

Hi, I am getting the same problem here: Warning: include(../source/layout/logotipo.php) [function.include]: failed to open stream: No such file or directory in /home/coconut/public_html/index2.html on line 16 link text

torpedo gratis
pekka's solution below in the comments works if you know the absolute path name.
Sakamoto Kazuma