Quantcast
Channel: plugin development – Jack Reichert
Viewing all articles
Browse latest Browse all 4

Function Reference/plugin basename « WordPress Codex

$
0
0

When building a WordPress plugin it’s important to know where your plugin sits. An early plugin I release relied heavily on several files inside the plugin directory. Nothing wrong with that, only that at the end of the day, the plugin directory didn’t end up being the plugin directory I thought it would be.

Ouch! I had to redeploy the plugin with the correct path.

But not anymore! Since those early days I discovered this neat line of code hidden in the all-knowing WordPress Codex.

$pluginBase = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));

via Function Reference/plugin basename « WordPress Codex.

pop that line into your plugin at the top and you won’t have to worry about where anything is.


Viewing all articles
Browse latest Browse all 4

Trending Articles