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.

For one of my many sites, plugins/plugin-name is a sym link pointing to universal-install/wp-content/plugins/plugin-name.

echo WP_PLUGIN_URL displays what I expect.
echo plugins_url(); displays what I expect.
echo plugins_url('',__FILE__) displays what I expect followed immediately by the absolute path to the universal plugins directory.

Is there any way I can fix echo plugins_url('',__FILE__) to return only the expected result?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

When writing a plugin, I define a few constants including the path to the plugin's root folder, and its "name" as used in some admin hooks:

define('WPSE_102681_PLUGIN_NAME', basename(dirname(__FILE__)) . '/' . basename(__FILE__));

I've found that plugins_url() happily takes that constant, which is useful when referencing files from subfolders of the plugin, like so:

echo plugins_url('images/information.png', WPSE_102681_PLUGIN_NAME);

Maybe it'll fix your problem.

share|improve this answer
    
That's interesting, but I'd like to avoid changing the actual plugin contents so that they can still be updated. You did, however, give me an idea. The plugin directories are being stored as constants in the plugin files, so if they're already defined in the wp-config file, everything works as planned. I'll accept your answer since it does what I asked. –  ITS Alaska Jun 11 '13 at 22:55

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.