Created
February 7, 2018 16:20
-
-
Save wpscholar/17a50a2d658c3d67e5d1603e3901f987 to your computer and use it in GitHub Desktop.
Fix plugin URLs for plugins inside the theme
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 plugin URLs for plugins inside the theme | |
*/ | |
add_filter( 'plugins_url', function ( $url, $path, $plugin ) { | |
$theme_path = trailingslashit( wp_normalize_path( get_theme_file_path() ) ); | |
if ( 0 === strpos( $plugin, $theme_path ) ) { | |
$basename = trim( dirname( str_replace( $theme_path, '', $plugin ) ), '/' ); | |
$url = get_theme_file_uri( "$basename/$path" ); | |
} | |
return $url; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment