Make plugin_dir() and plugin_basename() work for mu-plugins directory, props Denis-de-Bernardy, fixes #9561
git-svn-id: http://svn.automattic.com/wordpress/trunk@11069 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
91a3c4bbf4
commit
8682f79e6a
|
@ -1775,14 +1775,19 @@ function content_url($path = '') {
|
||||||
*/
|
*/
|
||||||
function plugins_url($path = '', $plugin = '') {
|
function plugins_url($path = '', $plugin = '') {
|
||||||
$scheme = ( is_ssl() ? 'https' : 'http' );
|
$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;
|
$url = WP_PLUGIN_URL;
|
||||||
|
}
|
||||||
|
|
||||||
if ( 0 === strpos($url, 'http') ) {
|
if ( 0 === strpos($url, 'http') ) {
|
||||||
if ( is_ssl() )
|
if ( is_ssl() )
|
||||||
$url = str_replace( 'http://', "{$scheme}://", $url );
|
$url = str_replace( 'http://', "{$scheme}://", $url );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($plugin) && is_string($plugin) )
|
if ( !empty($plugin) && is_string($plugin) ) {
|
||||||
{
|
|
||||||
$folder = dirname(plugin_basename($plugin));
|
$folder = dirname(plugin_basename($plugin));
|
||||||
if ('.' != $folder)
|
if ('.' != $folder)
|
||||||
$url .= '/' . ltrim($folder, '/');
|
$url .= '/' . ltrim($folder, '/');
|
||||||
|
|
|
@ -492,7 +492,9 @@ function plugin_basename($file) {
|
||||||
$file = preg_replace('|/+|','/', $file); // remove any duplicate slash
|
$file = preg_replace('|/+|','/', $file); // remove any duplicate slash
|
||||||
$plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
|
$plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
|
||||||
$plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
|
$plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
|
||||||
$file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir
|
$mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
|
||||||
|
$mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
|
||||||
|
$file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue