Skip to content

Commit

Permalink
Use network_*_url(). see #12736
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.automattic.com/wordpress/trunk@13884 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
ryan committed Mar 29, 2010
1 parent fbf3ee6 commit 8e4859a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 34 deletions.
10 changes: 5 additions & 5 deletions wp-activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function wpmu_activate_stylesheet() {
<?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?>

<h2><?php _e('Activation Key Required') ?></h2>
<form name="activateform" id="activateform" method="post" action="<?php echo 'http://' . $current_site->domain . $current_site->path ?>wp-activate.php">
<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>">
<p>
<label for="key"><?php _e('Activation Key:') ?></label>
<br /><input type="text" name="key" id="key" value="" size="50" />
Expand All @@ -64,9 +64,9 @@ function wpmu_activate_stylesheet() {
<h2><?php _e('Your account is now active!'); ?></h2>
<?php
if ( $signup->domain . $signup->path == '' ) {
printf(__('<p class="lead-in">Your account has been activated. You may now <a href="%1$s">login</a> 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 <a href="%4$s">reset your password</a>.</p>'), '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(__('<p class="lead-in">Your account has been activated. You may now <a href="%1$s">login</a> 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 <a href="%4$s">reset your password</a>.</p>'), network_site_url('wp-login.php', 'login'), $signup->user_login, $signup->user_email, network_site_url('wp-login.php?action=lostpassword', 'login'));
} else {
printf(__('<p class="lead-in">Your site at <a href="%1$s">%2$s</a> 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 <a href="%5$s">reset your password</a>.</p>'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword');
printf(__('<p class="lead-in">Your site at <a href="%1$s">%2$s</a> 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 <a href="%5$s">reset your password</a>.</p>'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url('wp-login.php?action=lostpassword'));
}
} else {
?>
Expand All @@ -86,10 +86,10 @@ function wpmu_activate_stylesheet() {
<p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $password; ?></p>
</div>

<?php if ( $url != 'http://' . $current_site->domain . $current_site->path ) : ?>
<?php if ( $url != network_home_url('', 'http') ) : ?>
<p class="view"><?php printf(__('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, $url . 'wp-login.php' ); ?></p>
<?php else: ?>
<p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.' ), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', 'http://' . $current_site->domain . $current_site->path ); ?></p>
<p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url('wp-login.php', 'login'), network_home_url() ); ?></p>
<?php endif;
}
}
Expand Down
16 changes: 7 additions & 9 deletions wp-admin/includes/ms.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
}

function update_option_new_admin_email($old_value, $value) {
global $current_site;
if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
return;

Expand All @@ -276,17 +275,17 @@ function update_option_new_admin_email($old_value, $value) {
All at ###SITENAME###
###SITEURL###"), $new_admin_email );

$content = str_replace('###ADMIN_URL###', esc_url(get_option( "siteurl" ).'/wp-admin/options.php?adminhash='.$hash), $content);
$content = str_replace('###ADMIN_URL###', esc_url(admin_url('options.php?adminhash='.$hash)), $content);
$content = str_replace('###EMAIL###', $value, $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( $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();

Expand Down Expand Up @@ -327,10 +326,10 @@ function send_confirmation_on_profile_email() {
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;
Expand Down Expand Up @@ -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' ];
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions wp-admin/ms-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
<th scope="row"><label for="admin_notice_feed"><?php _e('Admin Notice Feed') ?></label></th>
<td><input name="admin_notice_feed" class="large-text" type="text" id="admin_notice_feed" value="<?php echo esc_attr( get_site_option( 'admin_notice_feed' ) ) ?>" size="80" /><br />
<?php _e( 'Display the latest post from this RSS or Atom feed on all site dashboards. Leave blank to disable.' ); ?><br />
<?php if ( get_site_option( 'admin_notice_feed' ) != 'http://' . $current_site->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/'; ?></td>
<?php if ( get_site_option( 'admin_notice_feed' ) != network_home_url('feed/', 'http') )
echo __( "A good one to use would be the feed from your main site: " ) . network_home_url('feed/'); ?></td>
</tr>
</table>
<h3><?php _e('Registration Settings'); ?></h3>
Expand Down
8 changes: 8 additions & 0 deletions wp-includes/link-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) )
Expand Down Expand Up @@ -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')) )
Expand Down
15 changes: 6 additions & 9 deletions wp-includes/ms-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -841,19 +841,18 @@ 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;

$email = get_site_option( 'admin_email' );
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
Expand All @@ -868,8 +867,6 @@ function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
}

function newuser_notify_siteadmin( $user_id ) {
global $current_site;

if ( get_site_option( 'registrationnotification' ) != 'yes' )
return false;

Expand All @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down
12 changes: 3 additions & 9 deletions wp-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
<?php if ( !is_multisite() ) { ?>
<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>
<?php } else { ?>
<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://' . $current_site->domain . $current_site->path ); ?>" title="<?php echo apply_filters('login_headertitle', $current_site->site_name ); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1>
<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', network_home_url() ); ?>" title="<?php echo apply_filters('login_headertitle', $current_site->site_name ); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1>
<?php }

$message = apply_filters('login_message', $message);
Expand Down Expand Up @@ -184,16 +184,10 @@ function retrieve_password() {
$wpdb->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;
Expand Down

0 comments on commit 8e4859a

Please sign in to comment.