From 226600f5b294d9b101284963a67dbeb74073ad5a Mon Sep 17 00:00:00 2001 From: dd32 Date: Fri, 5 Feb 2010 12:39:04 +0000 Subject: [PATCH] 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 --- wp-includes/link-template.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index fabb50efeb..2cb8d96ece 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -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, '/'); }