Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

2 Answers

Does this help?:

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

OR

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

Try the Codex for plugins_url as well.

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.