WordPress.org

Make WordPress Core

Changeset 12598


Ignore:
Timestamp:
01/04/2010 05:23:29 PM (9 years ago)
Author:
ryan
Message:

Introduce home_url(). Props Denis-de-Bernardy, hakre. see #9008

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/default/header.php

    r10949 r12598  
    3939<div id="header" role="banner">
    4040    <div id="headerimg">
    41         <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
     41        <h1><a href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a></h1>
    4242        <div class="description"><?php bloginfo('description'); ?></div>
    4343    </div>
  • trunk/wp-includes/author-template.php

    r12584 r12598  
    210210
    211211    if ( empty($link) ) {
    212         $file = get_option('home') . '/';
     212        $file = home_url() . '/';
    213213        $link = $file . '?author=' . $auth_ID;
    214214    } else {
     
    219219        }
    220220        $link = str_replace('%author%', $author_nicename, $link);
    221         $link = get_option('home') . trailingslashit($link);
     221        $link = home_url() . trailingslashit($link);
    222222    }
    223223
  • trunk/wp-includes/canonical.php

    r12202 r12598  
    199199
    200200    // www.example.com vs example.com
    201     $user_home = @parse_url(get_option('home'));
     201    $user_home = @parse_url(home_url());
    202202    if ( !empty($user_home['host']) )
    203203        $redirect['host'] = $user_home['host'];
  • trunk/wp-includes/category-template.php

    r12319 r12598  
    2121
    2222    if ( empty( $catlink ) ) {
    23         $file = get_option( 'home' ) . '/';
    24         $catlink = $file . '?cat=' . $category_id;
     23        $catlink = home_url('?cat=' . $category_id);
    2524    } else {
    2625        $category = &get_category( $category_id );
     
    3534
    3635        $catlink = str_replace( '%category%', $category_nicename, $catlink );
    37         $catlink = get_option( 'home' ) . user_trailingslashit( $catlink, 'category' );
     36        $catlink = home_url( user_trailingslashit( $catlink, 'category' ) );
    3837    }
    3938    return apply_filters( 'category_link', $catlink, $category_id );
  • trunk/wp-includes/classes.php

    r11930 r12598  
    160160            $req_uri = $req_uri_array[0];
    161161            $self = $_SERVER['PHP_SELF'];
    162             $home_path = parse_url(get_option('home'));
     162            $home_path = parse_url(home_url());
    163163            if ( isset($home_path['path']) )
    164164                $home_path = $home_path['path'];
  • trunk/wp-includes/comment-template.php

    r12586 r12598  
    968968    if ( $wpcommentsjavascript ) {
    969969        if ( empty( $wpcommentspopupfile ) )
    970             $home = get_option('home');
     970            $home = home_url();
    971971        else
    972972            $home = get_option('siteurl');
  • trunk/wp-includes/comment.php

    r12584 r12598  
    7979            $uri = parse_url($url);
    8080            $domain = $uri['host'];
    81             $uri = parse_url( get_option('home') );
     81            $uri = parse_url( home_url() );
    8282            $home_domain = $uri['host'];
    8383            if ( $wpdb->get_var($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_url LIKE (%s) LIMIT 1", '%'.$domain.'%')) || $domain == $home_domain )
     
    18201820    // when set to true, this outputs debug messages by itself
    18211821    $client->debug = false;
    1822     $home = trailingslashit( get_option('home') );
     1822    $home = trailingslashit( home_url() );
    18231823    if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
    18241824        $client->query('weblogUpdates.ping', get_option('blogname'), $home);
  • trunk/wp-includes/default-widgets.php

    r12475 r12598  
    448448    function onCatChange() {
    449449        if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    450             location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
     450            location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
    451451        }
    452452    }
  • trunk/wp-includes/feed-atom-comments.php

    r12587 r12598  
    3333    <id><?php echo get_post_comments_feed_link('', 'atom'); ?></id>
    3434<?php } elseif(is_search()) { ?>
    35     <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo get_option('home') . '?s=' . esc_attr(get_search_query()); ?>" />
     35    <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo home_url() . '?s=' . esc_attr(get_search_query()); ?>" />
    3636    <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" />
    3737    <id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
  • trunk/wp-includes/feed.php

    r12484 r12598  
    476476 */
    477477function self_link() {
    478     $host = @parse_url(get_option('home'));
     478    $host = @parse_url(home_url());
    479479    $host = $host['host'];
    480480    echo esc_url(
  • trunk/wp-includes/general-template.php

    r12590 r12598  
    122122    }
    123123
    124     $form = '<form role="search" method="get" id="searchform" action="' . get_option('home') . '/" >
     124    $form = '<form role="search" method="get" id="searchform" action="' . home_url() . '/" >
    125125    <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
    126126    <input type="text" value="' . esc_attr(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
     
    302302            _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' ) );
    303303        case 'url' :
    304             $output = get_option('home');
     304            $output = home_url();
    305305            break;
    306306        case 'wpurl' :
     
    887887                        $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
    888888                        $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
    889                         $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);
     889                        $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);
    890890                        $text = $arc_week_start . $archive_week_separator . $arc_week_end;
    891891                        if ($show_post_count)
  • trunk/wp-includes/link-template.php

    r12597 r12598  
    151151            $post->post_name,
    152152        );
    153         $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
     153        $permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
    154154        $permalink = user_trailingslashit($permalink, 'single');
    155155        return apply_filters('post_link', $permalink, $post, $leavename);
    156156    } else { // if they're not using the fancy permalink option
    157         $permalink = trailingslashit(get_option('home')) . '?p=' . $post->ID;
     157        $permalink = home_url('?p=' . $post->ID);
    158158        return apply_filters('post_link', $permalink, $post, $leavename);
    159159    }
     
    196196
    197197    if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
    198         $link = get_option('home');
     198        $link = home_url();
    199199    else
    200200        $link = _get_page_link( $id , $leavename, $sample );
     
    229229        $link = get_page_uri($id);
    230230        $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct);
    231         $link = trailingslashit(get_option('home')) . $link;
     231        $link = home_url($link);
    232232        $link = user_trailingslashit($link, 'page');
    233233    } else {
    234         $link = trailingslashit(get_option('home')) . "?page_id=$id";
     234        $link = home_url("?page_id=$id");
    235235    }
    236236
     
    294294    if ( !empty($yearlink) ) {
    295295        $yearlink = str_replace('%year%', $year, $yearlink);
    296         return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink, 'year'), $year);
     296        return apply_filters('year_link', home_url( user_trailingslashit($yearlink, 'year') ), $year);
    297297    } else {
    298         return apply_filters('year_link', trailingslashit(get_option('home')) . '?m=' . $year, $year);
     298        return apply_filters('year_link', home_url('?m=' . $year), $year);
    299299    }
    300300}
     
    319319        $monthlink = str_replace('%year%', $year, $monthlink);
    320320        $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
    321         return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $year, $month);
     321        return apply_filters('month_link', home_url( user_trailingslashit($monthlink, 'month') ), $year, $month);
    322322    } else {
    323         return apply_filters('month_link', trailingslashit(get_option('home')) . '?m=' . $year . zeroise($month, 2), $year, $month);
     323        return apply_filters('month_link', home_url( '?m=' . $year . zeroise($month, 2) ), $year, $month);
    324324    }
    325325}
     
    349349        $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
    350350        $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
    351         return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink, 'day'), $year, $month, $day);
     351        return apply_filters('day_link', home_url( user_trailingslashit($daylink, 'day') ), $year, $month, $day);
    352352    } else {
    353         return apply_filters('day_link', trailingslashit(get_option('home')) . '?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
     353        return apply_filters('day_link', home_url( '?m=' . $year . zeroise($month, 2) . zeroise($day, 2) ), $year, $month, $day);
    354354    }
    355355}
     
    378378        $permalink = str_replace('%feed%', $feed, $permalink);
    379379        $permalink = preg_replace('#/+#', '/', "/$permalink");
    380         $output =  get_option('home') . user_trailingslashit($permalink, 'feed');
     380        $output =  home_url( user_trailingslashit($permalink, 'feed') );
    381381    } else {
    382382        if ( empty($feed) )
     
    386386            $feed = str_replace('comments_', 'comments-', $feed);
    387387
    388         $output = trailingslashit(get_option('home')) . "?feed={$feed}";
     388        $output = home_url("?feed={$feed}");
    389389    }
    390390
     
    418418        $type = get_post_field('post_type', $post_id);
    419419        if ( 'page' == $type )
    420             $url = trailingslashit(get_option('home')) . "?feed=$feed&amp;page_id=$post_id";
     420            $url = home_url("?feed=$feed&amp;page_id=$post_id");
    421421        else
    422             $url = trailingslashit(get_option('home')) . "?feed=$feed&amp;p=$post_id";
     422            $url = home_url("?feed=$feed&amp;p=$post_id");
    423423    }
    424424
     
    472472
    473473    if ( '' == $permalink_structure ) {
    474         $link = trailingslashit(get_option('home')) . "?feed=$feed&amp;author=" . $author_id;
     474        $link = home_url("?feed=$feed&amp;author=" . $author_id);
    475475    } else {
    476476        $link = get_author_posts_url($author_id);
     
    516516
    517517    if ( '' == $permalink_structure ) {
    518         $link = trailingslashit(get_option('home')) . "?feed=$feed&amp;cat=" . $cat_id;
     518        $link = home_url("?feed=$feed&amp;cat=" . $cat_id);
    519519    } else {
    520520        $link = get_category_link($cat_id);
     
    555555
    556556    if ( '' == $permalink_structure ) {
    557         $link = trailingslashit(get_option('home')) . "?feed=$feed&amp;tag=" . $tag->slug;
     557        $link = home_url("?feed=$feed&amp;tag=" . $tag->slug);
    558558    } else {
    559559        $link = get_tag_link($tag->term_id);
     
    630630        $feed = get_default_feed();
    631631
    632     $link = trailingslashit(get_option('home')) . "?s=$search&amp;feed=$feed";
     632    $link = home_url("?s=$search&amp;feed=$feed");
    633633
    634634    $link = apply_filters('search_feed_link', $link);
     
    655655        $feed = get_default_feed();
    656656
    657     $link = trailingslashit(get_option('home')) . "?s=$search&amp;feed=comments-$feed";
     657    $link = home_url("?s=$search&amp;feed=comments-$feed");
    658658
    659659    $link = apply_filters('search_feed_link', $link);
     
    12761276    $request = remove_query_arg( 'paged' );
    12771277
    1278     $home_root = parse_url(get_option('home'));
     1278    $home_root = parse_url(home_url());
    12791279    $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
    12801280    $home_root = preg_quote( trailingslashit( $home_root ), '|' );
     
    17071707
    17081708    return apply_filters('shortcut_link', $link);
     1709}
     1710
     1711/**
     1712 * Retrieve the home url.
     1713 *
     1714 * Returns the 'home' option with the appropriate protocol,  'https' if
     1715 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
     1716 * overridden.
     1717 *
     1718 * @package WordPress
     1719 * @since 3.0
     1720 *
     1721 * @param  string $path   (optional) Path relative to the home url.
     1722 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
     1723 * @return string Home url link with optional path appended.
     1724*/
     1725function home_url( $path = '', $scheme = null ) {
     1726    $orig_scheme = $scheme;
     1727    $scheme      = is_ssl() && !is_admin() ? 'https' : 'http';
     1728    $url = str_replace( 'http://', "$scheme://", get_option('home') );
     1729
     1730    if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
     1731        $url .= '/' . ltrim( $path, '/' );
     1732
     1733    return apply_filters( 'home_url', $url, $path, $orig_scheme );
    17091734}
    17101735
  • trunk/wp-includes/pluggable.php

    r12408 r12598  
    945945
    946946    $lp  = parse_url($test);
    947     $wpp = parse_url(get_option('home'));
     947    $wpp = parse_url(home_url());
    948948
    949949    $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
  • trunk/wp-includes/post-template.php

    r12584 r12598  
    823823        if ( is_front_page() && !is_paged() )
    824824            $class = 'class="current_page_item"';
    825         $menu .= '<li ' . $class . '><a href="' . get_option('home') . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
     825        $menu .= '<li ' . $class . '><a href="' . home_url() . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
    826826        // If the front page is a page, add it to the exclude list
    827827        if (get_option('show_on_front') == 'page') {
  • trunk/wp-includes/rewrite.php

    r12520 r12598  
    257257
    258258    // Add 'www.' if it is absent and should be there
    259     if ( false !== strpos(get_option('home'), '://www.') && false === strpos($url, '://www.') )
     259    if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') )
    260260        $url = str_replace('://', '://www.', $url);
    261261
    262262    // Strip 'www.' if it is present and shouldn't be
    263     if ( false === strpos(get_option('home'), '://www.') )
     263    if ( false === strpos(home_url(), '://www.') )
    264264        $url = str_replace('://www.', '://', $url);
    265265
     
    268268        $url = str_replace('index.php/', '', $url);
    269269
    270     if ( false !== strpos($url, get_option('home')) ) {
     270    if ( false !== strpos($url, home_url()) ) {
    271271        // Chop off http://domain.com
    272         $url = str_replace(get_option('home'), '', $url);
     272        $url = str_replace(home_url(), '', $url);
    273273    } else {
    274274        // Chop off /path/to/blog
    275         $home_path = parse_url(get_option('home'));
     275        $home_path = parse_url(home_url());
    276276        $home_path = $home_path['path'];
    277277        $url = str_replace($home_path, '', $url);
     
    16461646        }
    16471647
    1648         $home_root = parse_url(get_option('home'));
     1648        $home_root = parse_url(home_url());
    16491649        if ( isset( $home_root['path'] ) ) {
    16501650            $home_root = trailingslashit($home_root['path']);
  • trunk/wp-includes/taxonomy.php

    r12597 r12598  
    22472247
    22482248    if ( empty($termlink) ) {
    2249         $file = trailingslashit( get_option('home') );
    22502249        $t = get_taxonomy($taxonomy);
    22512250        if ( $t->query_var )
    2252             $termlink = "$file?$t->query_var=$slug";
     2251            $termlink = "?$t->query_var=$slug";
    22532252        else
    2254             $termlink = "$file?taxonomy=$taxonomy&term=$slug";
     2253            $termlink = "?taxonomy=$taxonomy&term=$slug";
     2254        $termlink = home_url($termlink);
    22552255    } else {
    22562256        $termlink = str_replace("%$taxonomy%", $slug, $termlink);
    2257         $termlink = get_option('home') . user_trailingslashit($termlink, 'category');
     2257        $termlink = home_url( user_trailingslashit($termlink, 'category') );
    22582258    }
    22592259    return apply_filters('term_link', $termlink, $term, $taxonomy);
  • trunk/wp-includes/theme.php

    r12434 r12598  
    10991099        ( false !== strpos($matches[3], '/wp-admin/') )
    11001100    ||
    1101         ( false !== strpos($matches[3], '://') && 0 !== strpos($matches[3], get_option('home')) )
     1101        ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )
    11021102    ||
    11031103        ( false !== strpos($matches[3], '/feed/') )
Note: See TracChangeset for help on using the changeset viewer.