WordPress.org

Make WordPress Core

Ticket #3002: 3002.plugin_basename.diff

File 3002.plugin_basename.diff, 680 bytes (added by DD32, 12 years ago)

plugin_basename fix from #4408

  • wp-includes/plugin.php

     
    237237 * @return string The name of a plugin.
    238238 */
    239239function plugin_basename($file) {
    240         $file = preg_replace('|\\\\+|', '\\\\', $file);
    241         $file = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
     240        $file = str_replace('\\','/',$file); // sanitize for Win32 installs
     241        $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
     242        $file = preg_replace('|^.*/wp-content/plugins/|','',$file); // get relative path from plugins dir
    242243        return $file;
    243244}
    244245