Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Workaround for symlinked plugins when using wp_enqueue_script and __FILE__. See and for references on this.
// Fix the __FILE__ problem with symlinks.
// Now just use ___FILE___ instead of __FILE__
$___FILE___ = __FILE__;
if ( isset( $plugin ) ) {
$___FILE___ = $plugin;
else if ( isset( $mu_plugin ) ) {
$___FILE___ = $mu_plugin;
else if ( isset( $network_plugin ) ) {
$___FILE___ = $network_plugin;
define( '___FILE___', $___FILE___ );
// Here we use ___FILE___ instead of __FILE__
plugins_url('my-file.js', ___FILE___),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.