Skip to content

Instantly share code, notes, and snippets.

@milesstewart88
Created November 11, 2014 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milesstewart88/8a40e534fcdb95db07c5 to your computer and use it in GitHub Desktop.
Save milesstewart88/8a40e534fcdb95db07c5 to your computer and use it in GitHub Desktop.
Gets the plugin basename everytime without having to add a path.
function get_plugin_basepath() {
$path = explode("/", plugin_dir_path(__FILE__));
$basePath = explode("/", plugin_basename(__FILE__));
$pathKey = array_search($basePath[0], $path);
$newArray = array_slice(array_filter($path), 0, $pathKey);
$fullBasePath = implode("/", $newArray);
return "/" . $fullBasePath;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment