Skip to content

Instantly share code, notes, and snippets.

@aubreypwd
Created December 6, 2013 17:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aubreypwd/7828624 to your computer and use it in GitHub Desktop.
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