On localhost. I have the following directory structure:
/share/www/trunk/wp-content/plugins/otherfolders
/share/www/portfolio/wp-content/s
The problem that I see with your code is that __FILE__ resolves symlinks automatically.
From the PHP Manual on Magic Constants
... Since PHP 4.0.2,
__FILE__always contains an absolute path with symlinks resolved ...
You can try using $_SERVER["SCRIPT_FILENAME"] instead.
$root = realpath(dirname(dirname(dirname(dirname($_SERVER["SCRIPT_FILENAME"])))));
if (file_exists($root.'/wp-load.php')) {
// WP 2.6
require_once($root.'/wp-load.php');
}
Note that I added the realpath() function to the root directory. Depending on your setup, you may or may not need it.
EDIT: Use $_SERVER["SCRIPT_FILENAME"] instead of $_SERVER["PHP_SELF"] for the file system path.