Opened 19 years ago
Closed 19 years ago
#4408 closed enhancement (duplicate)
plugin_basename() fix
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 2.2 |
| Component: | Administration | Keywords: | register_activation_hook plugin_basename |
| Focuses: | Cc: |
Description
Actual function plugin_basename() is broken and does not sanitize filenames on Win32 install. Therefore function register_(de)activation_hook() is also broken.
Example : plugin_basename('c:\wordpress\wp-content\plugins\hello\hello.php') returns 'hello\hello.php'
Here is a fix for this function :
function plugin_basename($file) {
$file = str_replace('\\','/',$file); // sanitize for Win32 installs
$file = preg_replace('|/+|','/', $file); // remove any duplicate slash
$file = preg_replace('|^.*/wp-content/plugins/|','',$file); // get relative path from plugins dir
return $file;
}
Note that this will fix the problem of failed plugin activation hook, but will probably break some plugins relying on the broken function on win32 installs.
Change History (3)
Note: See
TracTickets for help on using
tickets.
Dupe of #3002
Leaving open as has patch info.