plugins_url(”,__FILE__) != WP_PLUGIN_URL with sym links

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__)) . "https://wordpress.stackexchange.com/" . 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.

Leave a Comment

tech