Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Workaround for symlinked plugins when using wp_enqueue_script and __FILE__. See http://core.trac.wordpress.org/ticket/16953 and http://wordpress.org/support/topic/plugins_url-output-erroring?replies=5 for references on this.
<?php
// 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__
wp_enqueue_script(
'my-script',
plugins_url('my-file.js', ___FILE___),
array(),
'',
false
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment