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
This commit is contained in:
ryan 2008-07-09 17:24:36 +00:00
parent 100ed8a62d
commit e2aa6d619c
4 changed files with 17 additions and 7 deletions

View File

@ -50,7 +50,7 @@ class WP_Scripts extends WP_Dependencies {
$ver .= '&' . $this->args[$handle]; $ver .= '&' . $this->args[$handle];
$src = $this->registered[$handle]->src; $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; $src = $this->base_url . $src;
} }

View File

@ -59,7 +59,7 @@ class WP_Styles extends WP_Dependencies {
} }
function _css_href( $src, $ver, $handle ) { 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; $src = $this->base_url . $src;
} }

View File

@ -800,8 +800,6 @@ function site_url($path = '', $scheme = null) {
} }
function admin_url($path = '') { function admin_url($path = '') {
global $_wp_admin_url;
$url = site_url('wp-admin/', 'admin'); $url = site_url('wp-admin/', 'admin');
if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
@ -811,8 +809,6 @@ function admin_url($path = '') {
} }
function includes_url($path = '') { function includes_url($path = '') {
global $_wp_includes_url;
$url = site_url() . '/' . WPINC . '/'; $url = site_url() . '/' . WPINC . '/';
if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
@ -821,4 +817,18 @@ function includes_url($path = '') {
return $url; 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;
}
?> ?>

View File

@ -337,7 +337,7 @@ function get_theme_root() {
} }
function get_theme_root_uri() { 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) { function get_query_template($type) {