Using PHP functions to find the directory and url of current script might give you wrong result. However, there is a better way in WordPress to find plugin directory and URL.
In PHP,
$url = get_bloginfo('url')."/wp-content/plugins/plugin-name/images/hello.jpg";
$directory = dirname(__FILE__)."/plugin-name/images/hello.jpg";
dirname(__FILE__) might give you uncorrect result.
In WordPress,
$url = WP_PLUGIN_URL."/plugin-name/images/hello.jpg"; $directory = WP_PLUGIN_DIR."/plugin-name/images/hello.jpg";
Hope, it helps!
Leave a trackback from your own site.
Leave a Reply
You must be logged in to post a comment.

One Response to “Plugin Directory and URL in WordPress”
very nice and informative post… thanx for sharing.