Ok, I’m going to try to explain this as simple as possible.
I’m trying to modify a plugin called smart-lencioni-image-resizer v2.0. to be used in WP-Multisite.
I’m trying to display an image through SLIR using the following URL:
I’ve done this successfully in v.1.4.2. But v2.0 is using a different method for including files. The index.php
file looks like this:
function __autoload($className)
{
var_dump($className);
require_once strtolower($className) . '.class.php';
}
new SLIR();
Now, where ever I try to include WP header:
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php');
I get the following error message:
*Warning: require_once(translation_entry.class.php) [function.require-once]: failed to open stream: No such file or directory in I:Developmentwampwwwmysitewp-contentpluginswp-filebrowserslirindex.php on line 43*
Line 43 in the index.php
is:
require_once strtolower($className) . '.class.php';
For some reason the __autoload
function makes WP look for files in the SLIR directory. This is of cours wrong 🙁
UPDATE
I found one solution on the web that kind of works:
function __autoload($className)
{
if(file_exists(strtolower($className) . '.class.php')) {
require_once strtolower($className) . '.class.php';
}
}
This allows WP header file to be loaded. But for some reason it loads mainsite.no
and drops executing the URL I added at the top.
Is there any other way I can solve this problem?
UPDATE2
There is an .htaccess file in the SLIR folder. The file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule . index.php [L]
</IfModule>
# Prevent viewing of the error log file in its default location
<Files slir-error-log>
Order Deny,Allow
Deny from All
</Files>
Could it be that when I include the WP header file, it ignors the .htaccess file from SLIR?
Denis was pointing to the right direction, but just looking for if the file exists is not the whole job.
I do this by example, but you need to do this for every file that is unable to load:
Translation_Entry
and it is located in/wp-includes/pomo/entry.php
. That is some other library and not a core class.wp-load.php
got included before or while you register your autoloader.spl_autoload_register()
and register your base class autoloader. Then you can add another one upfront that is dealing with the other classes.I’ve written some sample code that might not work, it’s untested. You might not even register multiple autoloaders in the end but just one (that calls the different subroutines instead), so this is just a quick written mock-up:
autoload gets fired whenever class_exists() gets called. In your autoloader, add a check to verify that the file exists before including it.
I got the same error when writing my own plugin. I solved this issue with the following code.
This checks necessary class files under a directory
classes
and use include() only if the parsing class name matches existing file names.