[wp-trac] [WordPress Trac] #4408: plugin_basename() fix
WordPress Trac
wp-trac at lists.automattic.com
Tue Jun 5 07:52:58 GMT 2007
#4408: plugin_basename() fix
----------------------------+-----------------------------------------------
Reporter: Ozh | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Administration | Version:
Severity: normal | Keywords: register_activation_hook plugin_basename
----------------------------+-----------------------------------------------
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.
--
Ticket URL: <http://trac.wordpress.org/ticket/4408>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list