WordPress.org

Make WordPress Core

Ticket #16953: WP_fix_for_plugin_basename_to_allow_symlinks_2011-07-28.patch

File WP_fix_for_plugin_basename_to_allow_symlinks_2011-07-28.patch, 711 bytes (added by augustash, 4 years ago)

Fix for correctly extracting the local directory and filename regardless if the file comes from a symlink or not

  • wp-includes/plugin.php

    diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
    index 945461c..5bc475d 100644
    a b function plugin_basename($file) { 
    567567        $mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs 
    568568        $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash 
    569569        $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir 
    570         $file = trim($file, '/'); 
     570         
     571        $dir      = basename(dirname($file)); 
     572        $filename = basename($file); 
     573 
     574        $file = trim($dir . '/' . $filename, '/'); 
    571575        return $file; 
    572576} 
    573577