Created
December 6, 2013 17:18
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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