@@ -301,7 +301,7 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
case 'siteurl' : // DEPRECATED
_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The \'%1$s\' option is deprecated for the family of bloginfo() functions. Use the \'%2$s\' option instead.'), $show, 'url' ) );
case 'url' :
- $output = get_option('home');
+ $output = home_url();
break;
case 'wpurl' :
$output = get_option('siteurl');
@@ -886,7 +886,7 @@ function wp_get_archives($args = '') {
$arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
- $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
+ $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
$text = $arc_week_start . $archive_week_separator . $arc_week_end;
if ($show_post_count)
$after = ' ('.$arcresult->posts.')'.$afterafter;
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index 0937e818ed..944b2c3602 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -150,11 +150,11 @@ function get_permalink($id = 0, $leavename = false) {
$author,
$post->post_name,
);
- $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
+ $permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
$permalink = user_trailingslashit($permalink, 'single');
return apply_filters('post_link', $permalink, $post, $leavename);
} else { // if they're not using the fancy permalink option
- $permalink = trailingslashit(get_option('home')) . '?p=' . $post->ID;
+ $permalink = home_url('?p=' . $post->ID);
return apply_filters('post_link', $permalink, $post, $leavename);
}
}
@@ -195,7 +195,7 @@ function get_page_link( $id = false, $leavename = false, $sample = false ) {
$id = (int) $post->ID;
if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
- $link = get_option('home');
+ $link = home_url();
else
$link = _get_page_link( $id , $leavename, $sample );
@@ -228,10 +228,10 @@ function _get_page_link( $id = false, $leavename = false, $sample = false ) {
if ( '' != $pagestruct && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) || $sample ) ) {
$link = get_page_uri($id);
$link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct);
- $link = trailingslashit(get_option('home')) . $link;
+ $link = home_url($link);
$link = user_trailingslashit($link, 'page');
} else {
- $link = trailingslashit(get_option('home')) . "?page_id=$id";
+ $link = home_url("?page_id=$id");
}
return apply_filters( '_get_page_link', $link, $id );
@@ -293,9 +293,9 @@ function get_year_link($year) {
$yearlink = $wp_rewrite->get_year_permastruct();
if ( !empty($yearlink) ) {
$yearlink = str_replace('%year%', $year, $yearlink);
- return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink, 'year'), $year);
+ return apply_filters('year_link', home_url( user_trailingslashit($yearlink, 'year') ), $year);
} else {
- return apply_filters('year_link', trailingslashit(get_option('home')) . '?m=' . $year, $year);
+ return apply_filters('year_link', home_url('?m=' . $year), $year);
}
}
@@ -318,9 +318,9 @@ function get_month_link($year, $month) {
if ( !empty($monthlink) ) {
$monthlink = str_replace('%year%', $year, $monthlink);
$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
- return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $year, $month);
+ return apply_filters('month_link', home_url( user_trailingslashit($monthlink, 'month') ), $year, $month);
} else {
- return apply_filters('month_link', trailingslashit(get_option('home')) . '?m=' . $year . zeroise($month, 2), $year, $month);
+ return apply_filters('month_link', home_url( '?m=' . $year . zeroise($month, 2) ), $year, $month);
}
}
@@ -348,9 +348,9 @@ function get_day_link($year, $month, $day) {
$daylink = str_replace('%year%', $year, $daylink);
$daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
$daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
- return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink, 'day'), $year, $month, $day);
+ return apply_filters('day_link', home_url( user_trailingslashit($daylink, 'day') ), $year, $month, $day);
} else {
- return apply_filters('day_link', trailingslashit(get_option('home')) . '?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
+ return apply_filters('day_link', home_url( '?m=' . $year . zeroise($month, 2) . zeroise($day, 2) ), $year, $month, $day);
}
}
@@ -377,7 +377,7 @@ function get_feed_link($feed = '') {
$permalink = str_replace('%feed%', $feed, $permalink);
$permalink = preg_replace('#/+#', '/', "/$permalink");
- $output = get_option('home') . user_trailingslashit($permalink, 'feed');
+ $output = home_url( user_trailingslashit($permalink, 'feed') );
} else {
if ( empty($feed) )
$feed = get_default_feed();
@@ -385,7 +385,7 @@ function get_feed_link($feed = '') {
if ( false !== strpos($feed, 'comments_') )
$feed = str_replace('comments_', 'comments-', $feed);
- $output = trailingslashit(get_option('home')) . "?feed={$feed}";
+ $output = home_url("?feed={$feed}");
}
return apply_filters('feed_link', $output, $feed);
@@ -417,9 +417,9 @@ function get_post_comments_feed_link($post_id = '', $feed = '') {
} else {
$type = get_post_field('post_type', $post_id);
if ( 'page' == $type )
- $url = trailingslashit(get_option('home')) . "?feed=$feed&page_id=$post_id";
+ $url = home_url("?feed=$feed&page_id=$post_id");
else
- $url = trailingslashit(get_option('home')) . "?feed=$feed&p=$post_id";
+ $url = home_url("?feed=$feed&p=$post_id");
}
return apply_filters('post_comments_feed_link', $url);
@@ -471,7 +471,7 @@ function get_author_feed_link( $author_id, $feed = '' ) {
$feed = get_default_feed();
if ( '' == $permalink_structure ) {
- $link = trailingslashit(get_option('home')) . "?feed=$feed&author=" . $author_id;
+ $link = home_url("?feed=$feed&author=" . $author_id);
} else {
$link = get_author_posts_url($author_id);
if ( $feed == get_default_feed() )
@@ -515,7 +515,7 @@ function get_category_feed_link($cat_id, $feed = '') {
$permalink_structure = get_option('permalink_structure');
if ( '' == $permalink_structure ) {
- $link = trailingslashit(get_option('home')) . "?feed=$feed&cat=" . $cat_id;
+ $link = home_url("?feed=$feed&cat=" . $cat_id);
} else {
$link = get_category_link($cat_id);
if( $feed == get_default_feed() )
@@ -554,7 +554,7 @@ function get_tag_feed_link($tag_id, $feed = '') {
$feed = get_default_feed();
if ( '' == $permalink_structure ) {
- $link = trailingslashit(get_option('home')) . "?feed=$feed&tag=" . $tag->slug;
+ $link = home_url("?feed=$feed&tag=" . $tag->slug);
} else {
$link = get_tag_link($tag->term_id);
if ( $feed == get_default_feed() )
@@ -629,7 +629,7 @@ function get_search_feed_link($search_query = '', $feed = '') {
if ( empty($feed) )
$feed = get_default_feed();
- $link = trailingslashit(get_option('home')) . "?s=$search&feed=$feed";
+ $link = home_url("?s=$search&feed=$feed");
$link = apply_filters('search_feed_link', $link);
@@ -654,7 +654,7 @@ function get_search_comments_feed_link($search_query = '', $feed = '') {
if ( empty($feed) )
$feed = get_default_feed();
- $link = trailingslashit(get_option('home')) . "?s=$search&feed=comments-$feed";
+ $link = home_url("?s=$search&feed=comments-$feed");
$link = apply_filters('search_feed_link', $link);
@@ -1275,7 +1275,7 @@ function get_pagenum_link($pagenum = 1) {
$request = remove_query_arg( 'paged' );
- $home_root = parse_url(get_option('home'));
+ $home_root = parse_url(home_url());
$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
$home_root = preg_quote( trailingslashit( $home_root ), '|' );
@@ -1708,6 +1708,31 @@ function get_shortcut_link() {
return apply_filters('shortcut_link', $link);
}
+/**
+ * Retrieve the home url.
+ *
+ * Returns the 'home' option with the appropriate protocol, 'https' if
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
+ * overridden.
+ *
+ * @package WordPress
+ * @since 3.0
+ *
+ * @param string $path (optional) Path relative to the home url.
+ * @param string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
+ * @return string Home url link with optional path appended.
+*/
+function home_url( $path = '', $scheme = null ) {
+ $orig_scheme = $scheme;
+ $scheme = is_ssl() && !is_admin() ? 'https' : 'http';
+ $url = str_replace( 'http://', "$scheme://", get_option('home') );
+
+ if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+ $url .= '/' . ltrim( $path, '/' );
+
+ return apply_filters( 'home_url', $url, $path, $orig_scheme );
+}
+
/**
* Retrieve the site url.
*
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 0946f8f238..997ae10c3e 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -944,7 +944,7 @@ function wp_validate_redirect($location, $default = '') {
$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
$lp = parse_url($test);
- $wpp = parse_url(get_option('home'));
+ $wpp = parse_url(home_url());
$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 85258018b8..a0d1e309ce 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -822,7 +822,7 @@ function wp_page_menu( $args = array() ) {
$class = '';
if ( is_front_page() && !is_paged() )
$class = 'class="current_page_item"';
- $menu .= '
' . $args['link_before'] . $text . $args['link_after'] . '';
+ $menu .= '
' . $args['link_before'] . $text . $args['link_after'] . '';
// If the front page is a page, add it to the exclude list
if (get_option('show_on_front') == 'page') {
if ( !empty( $list_args['exclude'] ) ) {
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index b2aebe199d..9c808139e5 100644
--- a/wp-includes/rewrite.php
+++ b/wp-includes/rewrite.php
@@ -256,23 +256,23 @@ function url_to_postid($url) {
$url = $url_split[0];
// Add 'www.' if it is absent and should be there
- if ( false !== strpos(get_option('home'), '://www.') && false === strpos($url, '://www.') )
+ if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') )
$url = str_replace('://', '://www.', $url);
// Strip 'www.' if it is present and shouldn't be
- if ( false === strpos(get_option('home'), '://www.') )
+ if ( false === strpos(home_url(), '://www.') )
$url = str_replace('://www.', '://', $url);
// Strip 'index.php/' if we're not using path info permalinks
if ( !$wp_rewrite->using_index_permalinks() )
$url = str_replace('index.php/', '', $url);
- if ( false !== strpos($url, get_option('home')) ) {
+ if ( false !== strpos($url, home_url()) ) {
// Chop off http://domain.com
- $url = str_replace(get_option('home'), '', $url);
+ $url = str_replace(home_url(), '', $url);
} else {
// Chop off /path/to/blog
- $home_path = parse_url(get_option('home'));
+ $home_path = parse_url(home_url());
$home_path = $home_path['path'];
$url = str_replace($home_path, '', $url);
}
@@ -1645,7 +1645,7 @@ class WP_Rewrite {
$site_root = trailingslashit($site_root['path']);
}
- $home_root = parse_url(get_option('home'));
+ $home_root = parse_url(home_url());
if ( isset( $home_root['path'] ) ) {
$home_root = trailingslashit($home_root['path']);
} else {
diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
index d88374bbf0..2d47bc9076 100644
--- a/wp-includes/taxonomy.php
+++ b/wp-includes/taxonomy.php
@@ -2246,15 +2246,15 @@ function get_term_link( $term, $taxonomy ) {
$slug = $term->slug;
if ( empty($termlink) ) {
- $file = trailingslashit( get_option('home') );
$t = get_taxonomy($taxonomy);
if ( $t->query_var )
- $termlink = "$file?$t->query_var=$slug";
+ $termlink = "?$t->query_var=$slug";
else
- $termlink = "$file?taxonomy=$taxonomy&term=$slug";
+ $termlink = "?taxonomy=$taxonomy&term=$slug";
+ $termlink = home_url($termlink);
} else {
$termlink = str_replace("%$taxonomy%", $slug, $termlink);
- $termlink = get_option('home') . user_trailingslashit($termlink, 'category');
+ $termlink = home_url( user_trailingslashit($termlink, 'category') );
}
return apply_filters('term_link', $termlink, $term, $taxonomy);
}
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index ddea5cb817..d1eef3c74b 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -1098,7 +1098,7 @@ function preview_theme_ob_filter_callback( $matches ) {
if (
( false !== strpos($matches[3], '/wp-admin/') )
||
- ( false !== strpos($matches[3], '://') && 0 !== strpos($matches[3], get_option('home')) )
+ ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )
||
( false !== strpos($matches[3], '/feed/') )
||