I need to do require_once for my wp plugin development. It seems to me that I need to use absolute path.
my current solution is
$delimiter = strpos(dirname(__FILE__), "/")!==false?"/":"\\"; //win or unix?
$path = explode($delimiter, dirname(__FILE__));
require_once join(array_slice($path,0,count($path)-3),$delimiter) . "/wp-admin/includes/plugin.php";
I wonder if there is a better way to handle this, kind of general approach.
What if the wp plugin directory structure changes. So this part count($path)-3 won’t be valid any more ….
Try:
Or replace
__DIR__withdirname(__FILE__)if you are on < PHP 5.3Or you could try: