From e2aa6d619c6a6265ed07ab0f9805f59d59c07a91 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 9 Jul 2008 17:24:36 +0000 Subject: [PATCH] Introduce content_url(). Don't prepend base url to content url in script loader. see #6938 #7001 git-svn-id: http://svn.automattic.com/wordpress/trunk@8301 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class.wp-scripts.php | 2 +- wp-includes/class.wp-styles.php | 2 +- wp-includes/link-template.php | 18 ++++++++++++++---- wp-includes/theme.php | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/wp-includes/class.wp-scripts.php b/wp-includes/class.wp-scripts.php index d829c8e002..7652aecef7 100644 --- a/wp-includes/class.wp-scripts.php +++ b/wp-includes/class.wp-scripts.php @@ -50,7 +50,7 @@ class WP_Scripts extends WP_Dependencies { $ver .= '&' . $this->args[$handle]; $src = $this->registered[$handle]->src; - if ( !preg_match('|^https?://|', $src) ) { + if ( !preg_match('|^https?://|', $src) && !preg_match('|^' . preg_quote(WP_CONTENT_URL) . '|', $src) ) { $src = $this->base_url . $src; } diff --git a/wp-includes/class.wp-styles.php b/wp-includes/class.wp-styles.php index f6a6d79c35..8533943c1f 100644 --- a/wp-includes/class.wp-styles.php +++ b/wp-includes/class.wp-styles.php @@ -59,7 +59,7 @@ class WP_Styles extends WP_Dependencies { } function _css_href( $src, $ver, $handle ) { - if ( !preg_match('|^https?://|', $src) ) { + if ( !preg_match('|^https?://|', $src) && !preg_match('|^' . preg_quote(WP_CONTENT_URL) . '|', $src) ) { $src = $this->base_url . $src; } diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 1a07d7298b..434faf3dae 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -800,8 +800,6 @@ function site_url($path = '', $scheme = null) { } function admin_url($path = '') { - global $_wp_admin_url; - $url = site_url('wp-admin/', 'admin'); if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) @@ -811,8 +809,6 @@ function admin_url($path = '') { } function includes_url($path = '') { - global $_wp_includes_url; - $url = site_url() . '/' . WPINC . '/'; if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) @@ -821,4 +817,18 @@ function includes_url($path = '') { return $url; } +function content_url($path = '') { + $scheme = ( is_ssl() ? 'https' : 'http' ); + $url = WP_CONTENT_URL; + if ( 0 === strpos($url, 'http') ) { + if ( is_ssl() ) + $url = str_replace( 'http://', "{$scheme}://", $url ); + } + + if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) + $url .= '/' . ltrim($path, '/'); + + return $url; +} + ?> diff --git a/wp-includes/theme.php b/wp-includes/theme.php index aa5f385f36..6376075f14 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -337,7 +337,7 @@ function get_theme_root() { } function get_theme_root_uri() { - return apply_filters('theme_root_uri', WP_CONTENT_URL . "/themes", get_option('siteurl')); + return apply_filters('theme_root_uri', content_url('themes'), get_option('siteurl')); } function get_query_template($type) {