WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the method below to try and build a URL for a script I wish to load:

class WPSM_SuperMail {

    public static function scriptUrl($scriptPath) {
        return plugin_dir_url ( __FILE__ ) . '/js/' . $scriptPath;

However, the WPSM_SuperMail class is located in the code sub-folder of my plugin, and this folder is a sibling of my js sub-folder. How can I find my plugin base folder and sub-folders of that without the damned 'code' intrusion?

share|improve this question

Does this help?:

return plugins_url('/js/'. $scriptPath, '__FILE__');


return plugins_url('/code/<your php file name here>', '__FILE__');

Try the Codex for plugins_url as well.

share|improve this answer

this is a line i often use in plugins:

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

That gives you the path to the plugin file.

Snagged it from wordpress codex a while back.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.