Make WordPress Core

Ticket #12119: 12119.2.diff

File 12119.2.diff, 11.4 KB (added by ryan, 15 years ago)
  • wp-includes/link-template.php

     
    17321732}
    17331733
    17341734/**
    1735  * Retrieve the home url.
     1735 * Retrieve the home url for the current site.
    17361736 *
    17371737 * Returns the 'home' option with the appropriate protocol,  'https' if
    17381738 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
    17391739 * overridden.
    17401740 *
    17411741 * @package WordPress
    1742  * @since 3.0
     1742 * @since 3.0.0
    17431743 *
     1744 * @uses get_home_url()
     1745 *
    17441746 * @param  string $path   (optional) Path relative to the home url.
    17451747 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
    17461748 * @return string Home url link with optional path appended.
    17471749*/
    17481750function home_url( $path = '', $scheme = null ) {
     1751        return get_home_url(null, $path, $scheme);
     1752}
     1753
     1754/**
     1755 * Retrieve the home url for a given site.
     1756 *
     1757 * Returns the 'home' option with the appropriate protocol,  'https' if
     1758 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
     1759 * overridden.
     1760 *
     1761 * @package WordPress
     1762 * @since 3.0.0
     1763 *
     1764 * @param  int $blog_id   (optional) Blog ID. Defaults to current blog.
     1765 * @param  string $path   (optional) Path relative to the home url.
     1766 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
     1767 * @return string Home url link with optional path appended.
     1768*/
     1769function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
    17491770        $orig_scheme = $scheme;
    17501771        $scheme      = is_ssl() && !is_admin() ? 'https' : 'http';
    1751         $url = str_replace( 'http://', "$scheme://", get_option('home') );
    17521772
     1773        if ( empty($blog_id) || !is_multisite() )
     1774                $home = get_option('home');
     1775        else
     1776                $home = untrailingslashit(get_blogaddress_by_id($blog_id));
     1777
     1778        $url = str_replace( 'http://', "$scheme://", $home );
     1779
    17531780        if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
    17541781                $url .= '/' . ltrim( $path, '/' );
    17551782
    1756         return apply_filters( 'home_url', $url, $path, $orig_scheme );
     1783        return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
    17571784}
    17581785
    17591786/**
    1760  * Retrieve the site url.
     1787 * Retrieve the site url for the current site.
    17611788 *
    17621789 * Returns the 'site_url' option with the appropriate protocol,  'https' if
    17631790 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
     
    17661793 * @package WordPress
    17671794 * @since 2.6.0
    17681795 *
     1796 * @uses get_site_url()
     1797 *
    17691798 * @param string $path Optional. Path relative to the site url.
    17701799 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'.
    17711800 * @return string Site url link with optional path appended.
    17721801*/
    1773 function site_url($path = '', $scheme = null) {
     1802function site_url( $path = '', $scheme = null ) {
     1803        return get_site_url(null, $path, $scheme);
     1804}
     1805
     1806/**
     1807 * Retrieve the site url for a given site.
     1808 *
     1809 * Returns the 'site_url' option with the appropriate protocol,  'https' if
     1810 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
     1811 * overridden.
     1812 *
     1813 * @package WordPress
     1814 * @since 3.0.0
     1815 *
     1816 * @param int $blog_id (optional) Blog ID. Defaults to current blog.
     1817 * @param string $path Optional. Path relative to the site url.
     1818 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'.
     1819 * @return string Site url link with optional path appended.
     1820*/
     1821function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
    17741822        // should the list of allowed schemes be maintained elsewhere?
    17751823        $orig_scheme = $scheme;
    17761824        if ( !in_array($scheme, array('http', 'https')) ) {
     
    17841832                        $scheme = ( is_ssl() ? 'https' : 'http' );
    17851833        }
    17861834
    1787         $url = str_replace( 'http://', "{$scheme}://", get_option('siteurl') );
     1835        if ( empty($blog_id) || !is_multisite() )
     1836                $url = get_option('siteurl');
     1837        else
     1838                $url = untrailingslashit(get_blogaddress_by_id($blog_id));
    17881839
     1840        $url = str_replace( 'http://', "{$scheme}://", $url );
     1841
    17891842        if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
    17901843                $url .= '/' . ltrim($path, '/');
    17911844
    1792         return apply_filters('site_url', $url, $path, $orig_scheme);
     1845        return apply_filters('site_url', $url, $path, $orig_scheme, $blog_id);
    17931846}
    17941847
    17951848/**
    1796  * Retrieve the url to the admin area.
     1849 * Retrieve the url to the admin area for the current site.
    17971850 *
    17981851 * @package WordPress
    17991852 * @since 2.6.0
     
    18011854 * @param string $path Optional path relative to the admin url
    18021855 * @return string Admin url link with optional path appended
    18031856*/
    1804 function admin_url($path = '') {
    1805         $url = site_url('wp-admin/', 'admin');
     1857function admin_url( $path = '' ) {
     1858        return get_admin_url(null, $path);
     1859}
    18061860
     1861/**
     1862 * Retrieve the url to the admin area for a given site.
     1863 *
     1864 * @package WordPress
     1865 * @since 3.0.0
     1866 *
     1867 * @param int $blog_id (optional) Blog ID. Defaults to current blog.
     1868 * @param string $path Optional path relative to the admin url
     1869 * @return string Admin url link with optional path appended
     1870*/
     1871function get_admin_url( $blog_id = null, $path = '' ) {
     1872        $url = get_site_url($blog_id, 'wp-admin/', 'admin');
     1873
    18071874        if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
    18081875                $url .= ltrim($path, '/');
    18091876
    1810         return apply_filters('admin_url', $url, $path);
     1877        return apply_filters('admin_url', $url, $path, $blog_id);
    18111878}
    18121879
    18131880/**
  • wp-admin/ms-edit.php

     
    204204                }
    205205
    206206                if ( $_POST['update_home_url'] == 'update' ) {
    207                         if ( get_option( 'siteurl' ) != 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] )
    208                                 update_option( 'siteurl', 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] );
     207                        $blog_address = get_blogaddress_by_domain($_POST['blog']['domain'], $_POST['blog']['path']);
     208                        if ( get_option( 'siteurl' ) !=  $blog_address )
     209                                update_option( 'siteurl', $blog_address);
    209210
    210                         if ( get_option( 'home' ) != 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] )
    211                                 update_option( 'home', 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] );
     211                        if ( get_option( 'home' ) != $blog_address )
     212                                update_option( 'home', $blog_address );
    212213                }
    213214
    214215                $wp_rewrite->flush_rules();
  • wp-admin/ms-sites.php

     
    8282                ?>
    8383                <div class="wrap">
    8484                <?php screen_icon(); ?>
    85                 <h2><?php _e('Edit Site'); ?> - <a href='http://<?php echo $details->domain . $details->path; ?>'>http://<?php echo $details->domain . $details->path; ?></a></h2>
     85                <h2><?php _e('Edit Site'); ?> - <a href='<?php echo get_home_url($id); ?>'><?php echo get_home_url($id); ?></a></h2>
    8686                <form method="post" action="ms-edit.php?action=updateblog">
    8787                        <?php wp_nonce_field('editblog'); ?>
    8888                        <input type="hidden" name="id" value="<?php echo esc_attr($id) ?>" />
     
    9393                                <table class="form-table">
    9494                                                        <tr class="form-field form-required">
    9595                                                                <th scope="row"><?php _e('Domain') ?></th>
    96                                                                 <td>http://<input name="blog[domain]" type="text" id="domain" value="<?php echo $details->domain ?>" size="33" /></td>
     96                                                                <td>http://<input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr($details->domain) ?>" size="33" /></td>
    9797                                                        </tr>
    9898                                                        <tr class="form-field form-required">
    9999                                                                <th scope="row"><?php _e('Path') ?></th>
    100100                                                                <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr($details->path) ?>" size="40" style='margin-bottom:5px;' />
    101                                                                 <br /><input type='checkbox' style='width:20px;' name='update_home_url' value='update' <?php if ( get_blog_option( $id, 'siteurl' ) == preg_replace('|/+$|', '', 'http://' . $details->domain . $details->path) || get_blog_option( $id, 'home' ) == preg_replace('|/+$|', '', 'http://' . $details->domain . $details->path) ) echo 'checked="checked"'; ?> /> <?php _e( "Update 'siteurl' and 'home' as well." ); ?></td>
     101                                                                <br /><input type='checkbox' style='width:20px;' name='update_home_url' value='update' <?php if ( get_blog_option( $id, 'siteurl' ) == untrailingslashit( get_blogaddress_by_id($id) ) || get_blog_option( $id, 'home' ) == untrailingslashit( get_blogaddress_by_id($id) ) ) echo 'checked="checked"'; ?> /> <?php _e( "Update 'siteurl' and 'home' as well." ); ?></td>
    102102                                                        </tr>
    103103                                                        <tr class="form-field">
    104104                                                                <th scope="row"><?php _e('Registered') ?></th>
     
    492492                                                                        <?php
    493493                                                                        $actions        = array();
    494494                                                                        $actions[]      = '<a href="ms-sites.php?action=editblog&amp;id=' . $blog['blog_id'] . '" class="edit">' . __('Edit') . '</a>';
    495                                                                         $actions[]      = "<a href='{$protocol}{$blog['domain']}{$blog['path']}wp-admin/' class='edit'>" . __('Backend') . '</a>';
     495                                                                        $actions[]      = "<a href='" . get_admin_url($blog['blog_id']) . "' class='edit'>" . __('Backend') . '</a>';
    496496
    497497                                                                        if ( get_blog_status( $blog['blog_id'], "deleted" ) == '1' )
    498498                                                                                $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=activateblog&amp;ref=' . urlencode( $_SERVER['REQUEST_URI'] ) . '&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to activate the blog %s" ), $blogname ) ) . '">' . __('Activate') . '</a>';
     
    511511
    512512                                                                        $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to delete the blog %s" ), $blogname ) ) . '">' . __("Delete") . '</a>';
    513513
    514                                                                         $actions[]      = "<a href='http://{$blog['domain']}{$blog['path']}' rel='permalink'>" . __('Visit') . '</a>';
     514                                                                        $actions[]      = "<a href='" . get_home_url($blog['blog_id']) . "' rel='permalink'>" . __('Visit') . '</a>';
    515515                                                                        ?>
    516516
    517517                                                                        <?php if ( count($actions) ) : ?>
     
    544544                                                                                $blogusers_warning = '';
    545545                                                                                if ( count( $blogusers ) > 5 ) {
    546546                                                                                        $blogusers = array_slice( $blogusers, 0, 5 );
    547                                                                                         $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . $protocol . $blog[ 'domain' ] . $blog[ 'path' ] . 'wp-admin/users.php">' . __( 'More' ) . '</a>';
     547                                                                                        $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . get_admin_url($blog['blog_id'], 'users.php') . '">' . __( 'More' ) . '</a>';
    548548                                                                                }
    549549                                                                                foreach ( $blogusers as $key => $val )
    550550                                                                                        echo '<a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a> ('.$val->user_email.')<br />';
  • wp-admin/ms-options.php

     
    3838                        <tr valign="top">
    3939                                <th scope="row"><?php _e('Site Admin Email') ?></th>
    4040                                <td>
    41                                         <input name="admin_email" type="text" id="admin_email" style="width: 95%" value="<?php echo esc_attr( stripslashes( get_site_option('admin_email') ) ) ?>" size="45" />
     41                                        <input name="admin_email" type="text" id="admin_email" style="width: 95%" value="<?php echo esc_attr( get_site_option('admin_email') ) ?>" size="45" />
    4242                                        <br />
    4343                                        <?php printf( __( 'Registration and support mails will come from this address. Make it generic like "support@%s"' ), $current_site->domain ); ?>
    4444                                </td>