Fix plugins_url() for MU-plugins when running on Windows. Fixes #12080

git-svn-id: http://svn.automattic.com/wordpress/trunk@12963 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-02-05 12:39:04 +00:00
parent 9dc63f2f43
commit 226600f5b2
1 changed files with 12 additions and 9 deletions

View File

@ -1865,20 +1865,23 @@ function content_url($path = '') {
function plugins_url($path = '', $plugin = '') {
$scheme = ( is_ssl() ? 'https' : 'http' );
if ( $plugin !== '' && preg_match('#^' . preg_quote(WPMU_PLUGIN_DIR . DIRECTORY_SEPARATOR, '#') . '#', $plugin) ) {
$url = WPMU_PLUGIN_URL;
} else {
$url = WP_PLUGIN_URL;
$mu_plugin_dir = WPMU_PLUGIN_DIR;
foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) {
$$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs
$$var = preg_replace('|/+|', '/', $$var);
}
if ( 0 === strpos($url, 'http') ) {
if ( is_ssl() )
$url = str_replace( 'http://', "{$scheme}://", $url );
}
if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) )
$url = WPMU_PLUGIN_URL;
else
$url = WP_PLUGIN_URL;
if ( 0 === strpos($url, 'http') && is_ssl() )
$url = str_replace( 'http://', "{$scheme}://", $url );
if ( !empty($plugin) && is_string($plugin) ) {
$folder = dirname(plugin_basename($plugin));
if ('.' != $folder)
if ( '.' != $folder )
$url .= '/' . ltrim($folder, '/');
}