### Eclipse Workspace Patch 1.0
#P wordpress-trunk
Index: wp-includes/category-template.php
===================================================================
--- wp-includes/category-template.php	(revision 12559)
+++ wp-includes/category-template.php	(working copy)
@@ -20,7 +20,7 @@
 	$catlink = $wp_rewrite->get_category_permastruct();
 
 	if ( empty( $catlink ) ) {
-		$file = get_option( 'home' ) . '/';
+		$file = home_url() . '/';
 		$catlink = $file . '?cat=' . $category_id;
 	} else {
 		$category = &get_category( $category_id );
Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 12559)
+++ wp-includes/rewrite.php	(working copy)
@@ -256,23 +256,23 @@
 	$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 @@
 			$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 {
Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php	(revision 12559)
+++ wp-includes/post-template.php	(working copy)
@@ -822,7 +822,7 @@
 		$class = '';
 		if ( is_front_page() && !is_paged() )
 			$class = 'class="current_page_item"';
-		$menu .= '<li ' . $class . '><a href="' . get_option('home') . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
+		$menu .= '<li ' . $class . '><a href="' . home_url() . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
 		// 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'] ) ) {
Index: wp-includes/comment.php
===================================================================
--- wp-includes/comment.php	(revision 12559)
+++ wp-includes/comment.php	(working copy)
@@ -78,7 +78,7 @@
 		if ( 'trackback' == $comment_type || 'pingback' == $comment_type ) { // check if domain is in blogroll
 			$uri = parse_url($url);
 			$domain = $uri['host'];
-			$uri = parse_url( get_option('home') );
+			$uri = parse_url( home_url() );
 			$home_domain = $uri['host'];
 			if ( $wpdb->get_var($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_url LIKE (%s) LIMIT 1", '%'.$domain.'%')) || $domain == $home_domain )
 				return true;
@@ -1819,7 +1819,7 @@
 
 	// when set to true, this outputs debug messages by itself
 	$client->debug = false;
-	$home = trailingslashit( get_option('home') );
+	$home = trailingslashit( home_url() );
 	if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
 		$client->query('weblogUpdates.ping', get_option('blogname'), $home);
 }
Index: wp-includes/pluggable.php
===================================================================
--- wp-includes/pluggable.php	(revision 12559)
+++ wp-includes/pluggable.php	(working copy)
@@ -944,7 +944,7 @@
 	$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'] : '');
 
Index: wp-includes/comment-template.php
===================================================================
--- wp-includes/comment-template.php	(revision 12559)
+++ wp-includes/comment-template.php	(working copy)
@@ -959,7 +959,7 @@
 	echo '<a href="';
 	if ( $wpcommentsjavascript ) {
 		if ( empty( $wpcommentspopupfile ) )
-			$home = get_option('home');
+			$home = home_url();
 		else
 			$home = get_option('siteurl');
 		echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
Index: wp-includes/feed.php
===================================================================
--- wp-includes/feed.php	(revision 12559)
+++ wp-includes/feed.php	(working copy)
@@ -475,7 +475,7 @@
  * @since 2.5
  */
 function self_link() {
-	$host = @parse_url(get_option('home'));
+	$host = @parse_url(home_url());
 	$host = $host['host'];
 	echo esc_url(
 		'http'
Index: wp-includes/classes.php
===================================================================
--- wp-includes/classes.php	(revision 12559)
+++ wp-includes/classes.php	(working copy)
@@ -159,7 +159,7 @@
 			$req_uri_array = explode('?', $req_uri);
 			$req_uri = $req_uri_array[0];
 			$self = $_SERVER['PHP_SELF'];
-			$home_path = parse_url(get_option('home'));
+			$home_path = parse_url(home_url());
 			if ( isset($home_path['path']) )
 				$home_path = $home_path['path'];
 			else
Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 12559)
+++ wp-includes/taxonomy.php	(working copy)
@@ -2220,7 +2220,7 @@
 	$slug = $term->slug;
 
 	if ( empty($termlink) ) {
-		$file = trailingslashit( get_option('home') );
+		$file = trailingslashit( home_url() );
 		$t = get_taxonomy($taxonomy);
 		if ( $t->query_var )
 			$termlink = "$file?$t->query_var=$slug";
@@ -2228,7 +2228,7 @@
 			$termlink = "$file?taxonomy=$taxonomy&term=$slug";
 	} 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);
 }
Index: wp-includes/author-template.php
===================================================================
--- wp-includes/author-template.php	(revision 12559)
+++ wp-includes/author-template.php	(working copy)
@@ -207,7 +207,7 @@
 	$link = $wp_rewrite->get_author_permastruct();
 
 	if ( empty($link) ) {
-		$file = get_option('home') . '/';
+		$file = home_url() . '/';
 		$link = $file . '?author=' . $auth_ID;
 	} else {
 		if ( '' == $author_nicename ) {
@@ -216,7 +216,7 @@
 				$author_nicename = $user->user_nicename;
 		}
 		$link = str_replace('%author%', $author_nicename, $link);
-		$link = get_option('home') . trailingslashit($link);
+		$link = home_url() . trailingslashit($link);
 	}
 
 	$link = apply_filters('author_link', $link, $author_id, $author_nicename);
Index: wp-includes/theme.php
===================================================================
--- wp-includes/theme.php	(revision 12559)
+++ wp-includes/theme.php	(working copy)
@@ -1098,7 +1098,7 @@
 	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/') )
 	||
Index: wp-includes/general-template.php
===================================================================
--- wp-includes/general-template.php	(revision 12559)
+++ wp-includes/general-template.php	(working copy)
@@ -121,7 +121,7 @@
 		return;
 	}
 
-	$form = '<form role="search" method="get" id="searchform" action="' . get_option('home') . '/" >
+	$form = '<form role="search" method="get" id="searchform" action="' . home_url() . '/" >
 	<div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
 	<input type="text" value="' . esc_attr(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
 	<input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
@@ -304,7 +304,7 @@
 		case 'url' :
 		case 'home' : // DEPRECATED
 		case 'siteurl' : // DEPRECATED
-			$output = get_option('home');
+			$output = home_url();
 			break;
 		case 'wpurl' :
 			$output = get_option('siteurl');
@@ -889,7 +889,7 @@
 						$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, '&amp;', '=', $arcresult->week);
+						$url  = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week);
 						$text = $arc_week_start . $archive_week_separator . $arc_week_end;
 						if ($show_post_count)
 							$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
Index: wp-includes/default-widgets.php
===================================================================
--- wp-includes/default-widgets.php	(revision 12559)
+++ wp-includes/default-widgets.php	(working copy)
@@ -447,7 +447,7 @@
 	var dropdown = document.getElementById("cat");
 	function onCatChange() {
 		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
-			location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
+			location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
 		}
 	}
 	dropdown.onchange = onCatChange;
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 12559)
+++ wp-includes/link-template.php	(working copy)
@@ -150,11 +150,11 @@
 			$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 = trailingslashit(home_url()) . '?p=' . $post->ID;
 		return apply_filters('post_link', $permalink, $post, $leavename);
 	}
 }
@@ -192,7 +192,7 @@
 		$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 );
 
@@ -225,10 +225,10 @@
 	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 = trailingslashit(home_url()) . $link;
 		$link = user_trailingslashit($link, 'page');
 	} else {
-		$link = trailingslashit(get_option('home')) . "?page_id=$id";
+		$link = trailingslashit(home_url()) . "?page_id=$id";
 	}
 
 	return apply_filters( '_get_page_link', $link, $id );
@@ -290,9 +290,9 @@
 	$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', trailingslashit(home_url()) . '?m=' . $year, $year);
 	}
 }
 
@@ -315,9 +315,9 @@
 	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', trailingslashit(home_url()) . '?m=' . $year . zeroise($month, 2), $year, $month);
 	}
 }
 
@@ -345,9 +345,9 @@
 		$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', trailingslashit(home_url()) . '?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
 	}
 }
 
@@ -374,7 +374,7 @@
 
 		$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();
@@ -382,7 +382,7 @@
 		if ( false !== strpos($feed, 'comments_') )
 			$feed = str_replace('comments_', 'comments-', $feed);
 
-		$output = trailingslashit(get_option('home')) . "?feed={$feed}";
+		$output = trailingslashit(home_url()) . "?feed={$feed}";
 	}
 
 	return apply_filters('feed_link', $output, $feed);
@@ -414,9 +414,9 @@
 	} else {
 		$type = get_post_field('post_type', $post_id);
 		if ( 'page' == $type )
-			$url = trailingslashit(get_option('home')) . "?feed=$feed&amp;page_id=$post_id";
+			$url = trailingslashit(home_url()) . "?feed=$feed&amp;page_id=$post_id";
 		else
-			$url = trailingslashit(get_option('home')) . "?feed=$feed&amp;p=$post_id";
+			$url = trailingslashit(home_url()) . "?feed=$feed&amp;p=$post_id";
 	}
 
 	return apply_filters('post_comments_feed_link', $url);
@@ -468,7 +468,7 @@
 		$feed = get_default_feed();
 
 	if ( '' == $permalink_structure ) {
-		$link = trailingslashit(get_option('home')) . "?feed=$feed&amp;author=" . $author_id;
+		$link = trailingslashit(home_url()) . "?feed=$feed&amp;author=" . $author_id;
 	} else {
 		$link = get_author_posts_url($author_id);
 		if ( $feed == get_default_feed() )
@@ -512,7 +512,7 @@
 	$permalink_structure = get_option('permalink_structure');
 
 	if ( '' == $permalink_structure ) {
-		$link = trailingslashit(get_option('home')) . "?feed=$feed&amp;cat=" . $cat_id;
+		$link = trailingslashit(home_url()) . "?feed=$feed&amp;cat=" . $cat_id;
 	} else {
 		$link = get_category_link($cat_id);
 		if( $feed == get_default_feed() )
@@ -551,7 +551,7 @@
 		$feed = get_default_feed();
 
 	if ( '' == $permalink_structure ) {
-		$link = trailingslashit(get_option('home')) . "?feed=$feed&amp;tag=" . $tag->slug;
+		$link = trailingslashit(home_url()) . "?feed=$feed&amp;tag=" . $tag->slug;
 	} else {
 		$link = get_tag_link($tag->term_id);
 		if ( $feed == get_default_feed() )
@@ -626,7 +626,7 @@
 	if ( empty($feed) )
 		$feed = get_default_feed();
 
-	$link = trailingslashit(get_option('home')) . "?s=$search&amp;feed=$feed";
+	$link = trailingslashit(home_url()) . "?s=$search&amp;feed=$feed";
 
 	$link = apply_filters('search_feed_link', $link);
 
@@ -651,7 +651,7 @@
 	if ( empty($feed) )
 		$feed = get_default_feed();
 
-	$link = trailingslashit(get_option('home')) . "?s=$search&amp;feed=comments-$feed";
+	$link = trailingslashit(home_url()) . "?s=$search&amp;feed=comments-$feed";
 
 	$link = apply_filters('search_feed_link', $link);
 
@@ -1293,7 +1293,7 @@
 
 	$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 ), '|' );
 
@@ -1727,6 +1727,31 @@
 }
 
 /**
+ * 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.
  *
  * Returns the 'site_url' option with the appropriate protocol,  'https' if
Index: wp-content/themes/default/header.php
===================================================================
--- wp-content/themes/default/header.php	(revision 12559)
+++ wp-content/themes/default/header.php	(working copy)
@@ -38,7 +38,7 @@
 
 <div id="header" role="banner">
 	<div id="headerimg">
-		<h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
+		<h1><a href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a></h1>
 		<div class="description"><?php bloginfo('description'); ?></div>
 	</div>
 </div>
Index: wp-includes/feed-atom-comments.php
===================================================================
--- wp-includes/feed-atom-comments.php	(revision 12559)
+++ wp-includes/feed-atom-comments.php	(working copy)
@@ -32,7 +32,7 @@
 	<link rel="self" type="application/atom+xml" href="<?php echo get_post_comments_feed_link('', 'atom'); ?>" />
 	<id><?php echo get_post_comments_feed_link('', 'atom'); ?></id>
 <?php } elseif(is_search()) { ?>
-	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo get_option('home') . '?s=' . esc_attr(get_search_query()); ?>" />
+	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo home_url() . '?s=' . esc_attr(get_search_query()); ?>" />
 	<link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" />
 	<id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
 <?php } else { ?>
Index: wp-includes/canonical.php
===================================================================
--- wp-includes/canonical.php	(revision 12559)
+++ wp-includes/canonical.php	(working copy)
@@ -198,7 +198,7 @@
 		$redirect = @parse_url($redirect_url);
 
 	// www.example.com vs example.com
-	$user_home = @parse_url(get_option('home'));
+	$user_home = @parse_url(home_url());
 	if ( !empty($user_home['host']) )
 		$redirect['host'] = $user_home['host'];
 	if ( empty($user_home['path']) )
