Created
July 28, 2011 15:49
-
-
Save grafikchaos/1111795 to your computer and use it in GitHub Desktop.
patch for WordPress plugin_basename() to correctly handle local files and symlinked files
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
EDIT: removed the first patch b/c it wasn't completely correct. Below is the complete patch that should be applied. | |
diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php | |
index 5bc475d..5b5e693 100644 | |
--- a/wp-includes/plugin.php | |
+++ b/wp-includes/plugin.php | |
@@ -568,10 +568,12 @@ function plugin_basename($file) { | |
$mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash | |
$file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir | |
- $file = trim($file, '/'); | |
+ | |
+ $dir = basename(dirname($file)); | |
+ $filename = basename($file); | |
+ $filepath = ($dir == '.') ? $filename : $dir . '/' . $filename; | |
+ | |
+ $file = trim($filepath, '/'); | |
- | |
return $file; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment