Last active
October 29, 2018 11:03
-
-
Save PatelUtkarsh/de1913698d6fd516f7d013161faa94bd to your computer and use it in GitHub Desktop.
Fix url when wp-content and mu-plugins are added as symlink.
This file contains 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 url when wp-content and mu-plugins are added as symlink. | |
*/ | |
add_filter( 'plugins_url', function ( $url ) { | |
// Replace wp-content absolute path. | |
if ( defined( 'WP_CONTENT_DIR' ) && is_link( WP_CONTENT_DIR ) ) { | |
$mu_content_dir_path = dirname( __DIR__ ); | |
$url = str_replace( 'plugins' . $mu_content_dir_path, '', $url ); | |
} | |
// Replace vip-mu-plugins's absolute path. | |
if ( defined( 'WP_CONTENT_DIR' ) && is_link( WP_CONTENT_DIR . '/mu-plugins' ) ) { | |
$mu_plugin_path = realpath( WP_CONTENT_DIR . '/mu-plugins' ); | |
$url = str_replace( 'plugins' . $mu_plugin_path, 'mu-plugins', $url ); | |
} | |
return $url; | |
}, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment