From 8e4859a35c64df16580838305419758b26cacf3f Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 29 Mar 2010 21:45:31 +0000 Subject: [PATCH] Use network_*_url(). see #12736 git-svn-id: http://svn.automattic.com/wordpress/trunk@13884 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-activate.php | 10 +++++----- wp-admin/includes/ms.php | 16 +++++++--------- wp-admin/ms-options.php | 4 ++-- wp-includes/link-template.php | 8 ++++++++ wp-includes/ms-functions.php | 15 ++++++--------- wp-login.php | 12 +++--------- 6 files changed, 31 insertions(+), 34 deletions(-) diff --git a/wp-activate.php b/wp-activate.php index 92b6f98640..90021038ac 100644 --- a/wp-activate.php +++ b/wp-activate.php @@ -43,7 +43,7 @@ get_header();

-
+


@@ -64,9 +64,9 @@ get_header();

domain . $signup->path == '' ) { - printf(__('

Your account has been activated. You may now login to the site using your chosen username of "%2$s". Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.

'), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword'); + printf(__('

Your account has been activated. You may now login to the site using your chosen username of "%2$s". Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.

'), network_site_url('wp-login.php', 'login'), $signup->user_login, $signup->user_email, network_site_url('wp-login.php?action=lostpassword', 'login')); } else { - printf(__('

Your site at %2$s is active. You may now login to your site using your chosen username of "%3$s". Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.

'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword'); + printf(__('

Your site at %2$s is active. You may now login to your site using your chosen username of "%3$s". Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.

'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url('wp-login.php?action=lostpassword')); } } else { ?> @@ -86,10 +86,10 @@ get_header();

- domain . $current_site->path ) : ?> +

View your site or Login'), $url, $url . 'wp-login.php' ); ?>

-

Login or go back to the homepage.' ), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', 'http://' . $current_site->domain . $current_site->path ); ?>

+

Login or go back to the homepage.' ), network_site_url('wp-login.php', 'login'), network_home_url() ); ?>

domain . $current_site->path, $content); + $content = str_replace('###SITEURL###', network_home_url(), $content); wp_mail( $value, sprintf(__('[%s] New Admin Email Address'), get_option('blogname')), $content ); } add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2); function send_confirmation_on_profile_email() { - global $errors, $wpdb, $current_user, $current_site; + global $errors, $wpdb, $current_user; if ( ! is_object($errors) ) $errors = new WP_Error(); @@ -327,10 +326,10 @@ Regards, All at ###SITENAME### ###SITEURL###"), $new_user_email ); - $content = str_replace('###ADMIN_URL###', esc_url(get_option( "siteurl" ).'/wp-admin/profile.php?newuseremail='.$hash), $content); + $content = str_replace('###ADMIN_URL###', esc_url(admin_url('profile.php?newuseremail='.$hash)), $content); $content = str_replace('###EMAIL###', $_POST[ 'email' ], $content); $content = str_replace('###SITENAME###', get_site_option( 'site_name' ), $content); - $content = str_replace('###SITEURL###', 'http://' . $current_site->domain . $current_site->path, $content); + $content = str_replace('###SITEURL###', network_home_url(), $content); wp_mail( $_POST[ 'email' ], sprintf(__('[%s] New Email Address'), get_option('blogname')), $content ); $_POST[ 'email' ] = $current_user->user_email; @@ -534,7 +533,7 @@ function sync_category_tag_slugs( $term, $taxonomy ) { add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 ); function redirect_user_to_blog() { - global $current_user, $current_site; + global $current_user; $c = 0; if ( isset( $_GET[ 'c' ] ) ) $c = (int)$_GET[ 'c' ]; @@ -547,8 +546,7 @@ function redirect_user_to_blog() { $blog = get_active_blog_for_user( $current_user->ID ); $dashboard_blog = get_dashboard_blog(); if ( is_object( $blog ) ) { - $protocol = ( is_ssl() ? 'https://' : 'http://' ); - wp_redirect( $protocol . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case" + wp_redirect( get_admin_url($blog->blog_id, '?c=' . $c) ); // redirect and count to 5, "just in case" exit; } diff --git a/wp-admin/ms-options.php b/wp-admin/ms-options.php index 29c36e6e78..0419d97f9a 100644 --- a/wp-admin/ms-options.php +++ b/wp-admin/ms-options.php @@ -84,8 +84,8 @@ if (isset($_GET['updated'])) {

- domain . $current_site->path . 'feed/' ) - echo __( "A good one to use would be the feed from your main site: " ) . 'http://' . $current_site->domain . $current_site->path . 'feed/'; ?> +

diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index f4a8751cdd..4043d7fb66 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -2037,6 +2037,10 @@ function plugins_url($path = '', $plugin = '') { */ function network_site_url( $path = '', $scheme = null ) { global $current_site; + + if ( !is_multisite() ) + return site_url($path, $scheme); + $orig_scheme = $scheme; if ( !in_array($scheme, array('http', 'https')) ) { if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) ) @@ -2075,6 +2079,10 @@ function network_site_url( $path = '', $scheme = null ) { */ function network_home_url( $path = '', $scheme = null ) { global $current_site; + + if ( !is_multisite() ) + return home_url($path, $scheme); + $orig_scheme = $scheme; if ( !in_array($scheme, array('http', 'https')) ) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 031155dff6..1c53ff74b3 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -674,9 +674,9 @@ function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_emai // Send email with activation link. if ( !is_subdomain_install() || $current_site->id != 1 ) - $activate_url = "http://" . $current_site->domain . $current_site->path . "wp-activate.php?key=$key"; + $activate_url = network_site_url("wp-activate.php?key=$key"); else - $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; + $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API $activate_url = esc_url($activate_url); $admin_email = get_site_option( "admin_email" ); @@ -841,7 +841,6 @@ function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id } function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) { - global $current_site; if ( get_site_option( 'registrationnotification' ) != 'yes' ) return false; @@ -849,11 +848,11 @@ function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) { if ( is_email($email) == false ) return false; - $options_site_url = esc_url("http://{$current_site->domain}{$current_site->path}wp-admin/ms-options.php"); + $options_site_url = esc_url(network_admin_url('ms-options.php')); switch_to_blog( $blog_id ); $blogname = get_option( 'blogname' ); - $siteurl = get_option( 'siteurl' ); + $siteurl = site_url(); restore_current_blog(); $msg = sprintf( __( "New Blog: %1s @@ -868,8 +867,6 @@ Disable these notifications: %4s"), $blogname, $siteurl, $_SERVER['REMOTE_ADDR'] } function newuser_notify_siteadmin( $user_id ) { - global $current_site; - if ( get_site_option( 'registrationnotification' ) != 'yes' ) return false; @@ -880,7 +877,7 @@ function newuser_notify_siteadmin( $user_id ) { $user = new WP_User($user_id); - $options_site_url = esc_url("http://{$current_site->domain}{$current_site->path}wp-admin/ms-options.php"); + $options_site_url = esc_url(network_admin_url('ms-options.php')); $msg = sprintf(__("New User: %1s Remote IP: %2s @@ -1278,7 +1275,7 @@ function maybe_redirect_404() { global $current_site; if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = NOBLOGREDIRECT ) ) { if ( $destination == '%siteurl%' ) - $destination = $current_site->domain . $current_site->path; + $destination = network_home_url(); wp_redirect( $destination ); exit(); } diff --git a/wp-login.php b/wp-login.php index 16f4161ed7..ac7209fe27 100644 --- a/wp-login.php +++ b/wp-login.php @@ -85,7 +85,7 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {

-

+

update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); } $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; - if ( !is_multisite() ) - $message .= get_option('siteurl') . "\r\n\r\n"; - else - $message .= 'http://' . trailingslashit( $current_site->domain . $current_site->path ) . "\r\n\r\n"; + $message .= network_site_url() . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; - if ( !is_multisite() ) - $message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n"; - else - $message .= 'http://' . trailingslashit( $current_site->domain . $current_site->path ) . "wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login) . "\r\n"; + $message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n"; if ( is_multisite() ) $blogname = $GLOBALS['current_site']->site_name;