On localhost. I have the following directory structure:
/share/www/trunk/wp-content/plugins/otherfolders
/share/www/portfolio/wp-content/s
In some case its possible to change working dir and use getenv('PWD'):
$root = dirname(dirname(dirname(getenv('PWD'))));
if (file_exists($root.'/wp-load.php')) {
// WP 2.6
require_once($root.'/wp-load.php');
}
And change working directory before run this code:
cd /var/www/wp-content/themes/twenty_twelve/ && php script.php