diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php index 7f6217dedf..3972b30621 100644 --- a/src/wp-includes/plugin.php +++ b/src/wp-includes/plugin.php @@ -675,13 +675,15 @@ function remove_all_actions($tag, $priority = false) { function plugin_basename( $file ) { global $wp_plugin_paths; + // $wp_plugin_paths contains normalized paths. + $file = wp_normalize_path( $file ); + foreach ( $wp_plugin_paths as $dir => $realdir ) { if ( strpos( $file, $realdir ) === 0 ) { $file = $dir . substr( $file, strlen( $realdir ) ); } } - $file = wp_normalize_path( $file ); $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); diff --git a/tests/phpunit/tests/functions/pluginBasename.php b/tests/phpunit/tests/functions/pluginBasename.php new file mode 100644 index 0000000000..c7a90e23c3 --- /dev/null +++ b/tests/phpunit/tests/functions/pluginBasename.php @@ -0,0 +1,27 @@ +assertSame( 'a-symlinked-plugin/plugin.php', $basename ); + } +}