Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. Built from https://develop.svn.wordpress.org/trunk@42343 git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
373
wp-signup.php
373
wp-signup.php
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
/** Sets up the WordPress Environment. */
|
||||
require( dirname(__FILE__) . '/wp-load.php' );
|
||||
require( dirname( __FILE__ ) . '/wp-load.php' );
|
||||
|
||||
add_action( 'wp_head', 'wp_no_robots' );
|
||||
|
||||
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
|
||||
|
||||
if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) ) {
|
||||
if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ) ) ) {
|
||||
wp_redirect( network_home_url() );
|
||||
die();
|
||||
}
|
||||
@@ -27,12 +27,12 @@ function do_signup_header() {
|
||||
}
|
||||
add_action( 'wp_head', 'do_signup_header' );
|
||||
|
||||
if ( !is_multisite() ) {
|
||||
if ( ! is_multisite() ) {
|
||||
wp_redirect( wp_registration_url() );
|
||||
die();
|
||||
}
|
||||
|
||||
if ( !is_main_site() ) {
|
||||
if ( ! is_main_site() ) {
|
||||
wp_redirect( network_site_url( 'wp-signup.php' ) );
|
||||
die();
|
||||
}
|
||||
@@ -102,19 +102,23 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
|
||||
$current_network = get_network();
|
||||
// Blog name
|
||||
if ( !is_subdomain_install() )
|
||||
echo '<label for="blogname">' . __('Site Name:') . '</label>';
|
||||
else
|
||||
echo '<label for="blogname">' . __('Site Domain:') . '</label>';
|
||||
if ( ! is_subdomain_install() ) {
|
||||
echo '<label for="blogname">' . __( 'Site Name:' ) . '</label>';
|
||||
} else {
|
||||
echo '<label for="blogname">' . __( 'Site Domain:' ) . '</label>';
|
||||
}
|
||||
|
||||
if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
|
||||
<p class="error"><?php echo $errmsg ?></p>
|
||||
<?php }
|
||||
if ( $errmsg = $errors->get_error_message( 'blogname' ) ) {
|
||||
?>
|
||||
<p class="error"><?php echo $errmsg; ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( !is_subdomain_install() )
|
||||
echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
|
||||
else
|
||||
echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ) ) . '</span><br />';
|
||||
if ( ! is_subdomain_install() ) {
|
||||
echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><br />';
|
||||
} else {
|
||||
echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ) ) . '</span><br />';
|
||||
}
|
||||
|
||||
if ( ! is_user_logged_in() ) {
|
||||
if ( ! is_subdomain_install() ) {
|
||||
@@ -129,11 +133,12 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
|
||||
// Blog Title
|
||||
?>
|
||||
<label for="blog_title"><?php _e('Site Title:') ?></label>
|
||||
<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
|
||||
<p class="error"><?php echo $errmsg ?></p>
|
||||
<?php }
|
||||
echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
|
||||
<label for="blog_title"><?php _e( 'Site Title:' ); ?></label>
|
||||
<?php if ( $errmsg = $errors->get_error_message( 'blog_title' ) ) { ?>
|
||||
<p class="error"><?php echo $errmsg; ?></p>
|
||||
<?php
|
||||
}
|
||||
echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" />';
|
||||
?>
|
||||
|
||||
<?php
|
||||
@@ -157,40 +162,42 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
$lang = '';
|
||||
}
|
||||
|
||||
wp_dropdown_languages( array(
|
||||
'name' => 'WPLANG',
|
||||
'id' => 'site-language',
|
||||
'selected' => $lang,
|
||||
'languages' => $languages,
|
||||
'show_available_translations' => false,
|
||||
) );
|
||||
wp_dropdown_languages(
|
||||
array(
|
||||
'name' => 'WPLANG',
|
||||
'id' => 'site-language',
|
||||
'selected' => $lang,
|
||||
'languages' => $languages,
|
||||
'show_available_translations' => false,
|
||||
)
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
endif; // Languages.
|
||||
|
||||
$blog_public_on_checked = $blog_public_off_checked = '';
|
||||
if ( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) {
|
||||
$blog_public_off_checked = 'checked="checked"';
|
||||
} else {
|
||||
$blog_public_on_checked = 'checked="checked"';
|
||||
}
|
||||
if ( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) {
|
||||
$blog_public_off_checked = 'checked="checked"';
|
||||
} else {
|
||||
$blog_public_on_checked = 'checked="checked"';
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="privacy">
|
||||
<p class="privacy-intro">
|
||||
<label for="blog_public_on"><?php _e('Privacy:') ?></label>
|
||||
<?php _e( 'Allow search engines to index this site.' ); ?>
|
||||
<br style="clear:both" />
|
||||
<label class="checkbox" for="blog_public_on">
|
||||
<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php echo $blog_public_on_checked; ?> />
|
||||
<strong><?php _e( 'Yes' ); ?></strong>
|
||||
</label>
|
||||
<label class="checkbox" for="blog_public_off">
|
||||
<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php echo $blog_public_off_checked; ?> />
|
||||
<strong><?php _e( 'No' ); ?></strong>
|
||||
</label>
|
||||
</p>
|
||||
<p class="privacy-intro">
|
||||
<label for="blog_public_on"><?php _e( 'Privacy:' ); ?></label>
|
||||
<?php _e( 'Allow search engines to index this site.' ); ?>
|
||||
<br style="clear:both" />
|
||||
<label class="checkbox" for="blog_public_on">
|
||||
<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php echo $blog_public_on_checked; ?> />
|
||||
<strong><?php _e( 'Yes' ); ?></strong>
|
||||
</label>
|
||||
<label class="checkbox" for="blog_public_off">
|
||||
<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php echo $blog_public_off_checked; ?> />
|
||||
<strong><?php _e( 'No' ); ?></strong>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
@@ -213,10 +220,11 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
*/
|
||||
function validate_blog_form() {
|
||||
$user = '';
|
||||
if ( is_user_logged_in() )
|
||||
if ( is_user_logged_in() ) {
|
||||
$user = wp_get_current_user();
|
||||
}
|
||||
|
||||
return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
|
||||
return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,27 +236,27 @@ function validate_blog_form() {
|
||||
* @param string $user_email The entered email address.
|
||||
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string.
|
||||
*/
|
||||
function show_user_form($user_name = '', $user_email = '', $errors = '') {
|
||||
function show_user_form( $user_name = '', $user_email = '', $errors = '' ) {
|
||||
if ( ! is_wp_error( $errors ) ) {
|
||||
$errors = new WP_Error();
|
||||
}
|
||||
|
||||
// User name
|
||||
echo '<label for="user_name">' . __('Username:') . '</label>';
|
||||
if ( $errmsg = $errors->get_error_message('user_name') ) {
|
||||
echo '<p class="error">'.$errmsg.'</p>';
|
||||
echo '<label for="user_name">' . __( 'Username:' ) . '</label>';
|
||||
if ( $errmsg = $errors->get_error_message( 'user_name' ) ) {
|
||||
echo '<p class="error">' . $errmsg . '</p>';
|
||||
}
|
||||
echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr( $user_name ) .'" autocapitalize="none" autocorrect="off" maxlength="60" /><br />';
|
||||
echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" autocapitalize="none" autocorrect="off" maxlength="60" /><br />';
|
||||
_e( '(Must be at least 4 characters, letters and numbers only.)' );
|
||||
?>
|
||||
|
||||
<label for="user_email"><?php _e( 'Email Address:' ) ?></label>
|
||||
<?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
|
||||
<p class="error"><?php echo $errmsg ?></p>
|
||||
<label for="user_email"><?php _e( 'Email Address:' ); ?></label>
|
||||
<?php if ( $errmsg = $errors->get_error_message( 'user_email' ) ) { ?>
|
||||
<p class="error"><?php echo $errmsg; ?></p>
|
||||
<?php } ?>
|
||||
<input name="user_email" type="email" id="user_email" value="<?php echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('We send your registration email to this address. (Double-check your email address before continuing.)') ?>
|
||||
<input name="user_email" type="email" id="user_email" value="<?php echo esc_attr( $user_email ); ?>" maxlength="200" /><br /><?php _e( 'We send your registration email to this address. (Double-check your email address before continuing.)' ); ?>
|
||||
<?php
|
||||
if ( $errmsg = $errors->get_error_message('generic') ) {
|
||||
if ( $errmsg = $errors->get_error_message( 'generic' ) ) {
|
||||
echo '<p class="error">' . $errmsg . '</p>';
|
||||
}
|
||||
/**
|
||||
@@ -269,7 +277,7 @@ function show_user_form($user_name = '', $user_email = '', $errors = '') {
|
||||
* @return array Contains username, email, and error messages.
|
||||
*/
|
||||
function validate_user_form() {
|
||||
return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
|
||||
return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,14 +292,14 @@ function validate_user_form() {
|
||||
function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
if ( ! is_wp_error($errors) ) {
|
||||
if ( ! is_wp_error( $errors ) ) {
|
||||
$errors = new WP_Error();
|
||||
}
|
||||
|
||||
$signup_defaults = array(
|
||||
'blogname' => $blogname,
|
||||
'blog_title' => $blog_title,
|
||||
'errors' => $errors
|
||||
'errors' => $errors,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -309,9 +317,9 @@ function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
*/
|
||||
$filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults );
|
||||
|
||||
$blogname = $filtered_results['blogname'];
|
||||
$blogname = $filtered_results['blogname'];
|
||||
$blog_title = $filtered_results['blog_title'];
|
||||
$errors = $filtered_results['errors'];
|
||||
$errors = $filtered_results['errors'];
|
||||
|
||||
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
|
||||
|
||||
@@ -319,22 +327,25 @@ function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
|
||||
}
|
||||
?>
|
||||
<p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), $current_user->display_name ) ?></p>
|
||||
<p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), $current_user->display_name ); ?></p>
|
||||
|
||||
<?php
|
||||
$blogs = get_blogs_of_user($current_user->ID);
|
||||
if ( !empty($blogs) ) { ?>
|
||||
$blogs = get_blogs_of_user( $current_user->ID );
|
||||
if ( ! empty( $blogs ) ) {
|
||||
?>
|
||||
|
||||
<p><?php _e( 'Sites you are already a member of:' ) ?></p>
|
||||
<p><?php _e( 'Sites you are already a member of:' ); ?></p>
|
||||
<ul>
|
||||
<?php foreach ( $blogs as $blog ) {
|
||||
<?php
|
||||
foreach ( $blogs as $blog ) {
|
||||
$home_url = get_home_url( $blog->userblog_id );
|
||||
echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
|
||||
} ?>
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?php } ?>
|
||||
|
||||
<p><?php _e( 'If you’re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p>
|
||||
<p><?php _e( 'If you’re not going to use a great site domain, leave it for a new user. Now have at it!' ); ?></p>
|
||||
<form id="setupform" method="post" action="wp-signup.php">
|
||||
<input type="hidden" name="stage" value="gimmeanotherblog" />
|
||||
<?php
|
||||
@@ -348,8 +359,8 @@ function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
*/
|
||||
do_action( 'signup_hidden_fields', 'create-another-site' );
|
||||
?>
|
||||
<?php show_blog_form($blogname, $blog_title, $errors); ?>
|
||||
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p>
|
||||
<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
|
||||
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ); ?>" /></p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
@@ -372,14 +383,14 @@ function validate_another_blog_signup() {
|
||||
$result = validate_blog_form();
|
||||
|
||||
// Extracted values set/overwrite globals.
|
||||
$domain = $result['domain'];
|
||||
$path = $result['path'];
|
||||
$blogname = $result['blogname'];
|
||||
$domain = $result['domain'];
|
||||
$path = $result['path'];
|
||||
$blogname = $result['blogname'];
|
||||
$blog_title = $result['blog_title'];
|
||||
$errors = $result['errors'];
|
||||
$errors = $result['errors'];
|
||||
|
||||
if ( $errors->get_error_code() ) {
|
||||
signup_another_blog($blogname, $blog_title, $errors);
|
||||
signup_another_blog( $blogname, $blog_title, $errors );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -387,7 +398,7 @@ function validate_another_blog_signup() {
|
||||
|
||||
$blog_meta_defaults = array(
|
||||
'lang_id' => 1,
|
||||
'public' => $public
|
||||
'public' => $public,
|
||||
);
|
||||
|
||||
// Handle the language setting for the new site.
|
||||
@@ -402,7 +413,6 @@ function validate_another_blog_signup() {
|
||||
$blog_meta_defaults['WPLANG'] = $language;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -467,18 +477,22 @@ function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $
|
||||
$login_url = 'http://' . $domain . $path . 'wp-login.php';
|
||||
}
|
||||
|
||||
$site = sprintf( '<a href="%1$s">%2$s</a>',
|
||||
$site = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url( $home_url ),
|
||||
$blog_title
|
||||
);
|
||||
|
||||
?>
|
||||
<h2><?php
|
||||
<h2>
|
||||
<?php
|
||||
/* translators: %s: site name */
|
||||
printf( __( 'The site %s is yours.' ), $site );
|
||||
?></h2>
|
||||
?>
|
||||
</h2>
|
||||
<p>
|
||||
<?php printf(
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1: link to new site, 2: login URL, 3: username */
|
||||
__( '%1$s is your new site. <a href="%2$s">Log in</a> as “%3$s” using your existing password.' ),
|
||||
sprintf(
|
||||
@@ -488,7 +502,8 @@ function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $
|
||||
),
|
||||
esc_url( $login_url ),
|
||||
$user_name
|
||||
); ?>
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
/**
|
||||
@@ -511,10 +526,11 @@ function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $
|
||||
function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
|
||||
global $active_signup;
|
||||
|
||||
if ( !is_wp_error($errors) )
|
||||
if ( ! is_wp_error( $errors ) ) {
|
||||
$errors = new WP_Error();
|
||||
}
|
||||
|
||||
$signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog';
|
||||
$signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog';
|
||||
|
||||
$signup_user_defaults = array(
|
||||
'user_name' => $user_name,
|
||||
@@ -536,23 +552,25 @@ function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
|
||||
* }
|
||||
*/
|
||||
$filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults );
|
||||
$user_name = $filtered_results['user_name'];
|
||||
$user_email = $filtered_results['user_email'];
|
||||
$errors = $filtered_results['errors'];
|
||||
$user_name = $filtered_results['user_name'];
|
||||
$user_email = $filtered_results['user_email'];
|
||||
$errors = $filtered_results['errors'];
|
||||
|
||||
?>
|
||||
|
||||
<h2><?php
|
||||
<h2>
|
||||
<?php
|
||||
/* translators: %s: name of the network */
|
||||
printf( __( 'Get your own %s account in seconds' ), get_network()->site_name );
|
||||
?></h2>
|
||||
?>
|
||||
</h2>
|
||||
<form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate">
|
||||
<input type="hidden" name="stage" value="validate-user-signup" />
|
||||
<?php
|
||||
/** This action is documented in wp-signup.php */
|
||||
do_action( 'signup_hidden_fields', 'validate-user' );
|
||||
?>
|
||||
<?php show_user_form($user_name, $user_email, $errors); ?>
|
||||
<?php show_user_form( $user_name, $user_email, $errors ); ?>
|
||||
|
||||
<p>
|
||||
<?php if ( $active_signup == 'blog' ) { ?>
|
||||
@@ -561,14 +579,14 @@ function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
|
||||
<input id="signupblog" type="hidden" name="signup_for" value="user" />
|
||||
<?php } else { ?>
|
||||
<input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> />
|
||||
<label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label>
|
||||
<label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!' ); ?></label>
|
||||
<br />
|
||||
<input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> />
|
||||
<label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label>
|
||||
<label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.' ); ?></label>
|
||||
<?php } ?>
|
||||
</p>
|
||||
|
||||
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p>
|
||||
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Next' ); ?>" /></p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
@@ -581,25 +599,25 @@ function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
|
||||
* @return bool True if new user signup was validated, false if error
|
||||
*/
|
||||
function validate_user_signup() {
|
||||
$result = validate_user_form();
|
||||
$user_name = $result['user_name'];
|
||||
$result = validate_user_form();
|
||||
$user_name = $result['user_name'];
|
||||
$user_email = $result['user_email'];
|
||||
$errors = $result['errors'];
|
||||
$errors = $result['errors'];
|
||||
|
||||
if ( $errors->get_error_code() ) {
|
||||
signup_user($user_name, $user_email, $errors);
|
||||
signup_user( $user_name, $user_email, $errors );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'blog' == $_POST['signup_for'] ) {
|
||||
signup_blog($user_name, $user_email);
|
||||
signup_blog( $user_name, $user_email );
|
||||
return false;
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-signup.php */
|
||||
wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
|
||||
|
||||
confirm_user_signup($user_name, $user_email);
|
||||
confirm_user_signup( $user_name, $user_email );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -611,13 +629,21 @@ function validate_user_signup() {
|
||||
* @param string $user_name The username
|
||||
* @param string $user_email The user's email address
|
||||
*/
|
||||
function confirm_user_signup($user_name, $user_email) {
|
||||
function confirm_user_signup( $user_name, $user_email ) {
|
||||
?>
|
||||
<h2><?php /* translators: %s: username */
|
||||
printf( __( '%s is your new username' ), $user_name) ?></h2>
|
||||
<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p>
|
||||
<p><?php /* translators: %s: email address */
|
||||
printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p>
|
||||
<h2>
|
||||
<?php
|
||||
/* translators: %s: username */
|
||||
printf( __( '%s is your new username' ), $user_name )
|
||||
?>
|
||||
</h2>
|
||||
<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ); ?></p>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: %s: email address */
|
||||
printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' );
|
||||
?>
|
||||
</p>
|
||||
<p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p>
|
||||
<?php
|
||||
/** This action is documented in wp-signup.php */
|
||||
@@ -635,16 +661,17 @@ function confirm_user_signup($user_name, $user_email) {
|
||||
* @param string $blog_title The site title.
|
||||
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string.
|
||||
*/
|
||||
function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
|
||||
if ( !is_wp_error($errors) )
|
||||
function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
|
||||
if ( ! is_wp_error( $errors ) ) {
|
||||
$errors = new WP_Error();
|
||||
}
|
||||
|
||||
$signup_blog_defaults = array(
|
||||
'user_name' => $user_name,
|
||||
'user_email' => $user_email,
|
||||
'blogname' => $blogname,
|
||||
'blog_title' => $blog_title,
|
||||
'errors' => $errors
|
||||
'errors' => $errors,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -664,25 +691,26 @@ function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_ti
|
||||
*/
|
||||
$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
|
||||
|
||||
$user_name = $filtered_results['user_name'];
|
||||
$user_name = $filtered_results['user_name'];
|
||||
$user_email = $filtered_results['user_email'];
|
||||
$blogname = $filtered_results['blogname'];
|
||||
$blogname = $filtered_results['blogname'];
|
||||
$blog_title = $filtered_results['blog_title'];
|
||||
$errors = $filtered_results['errors'];
|
||||
$errors = $filtered_results['errors'];
|
||||
|
||||
if ( empty($blogname) )
|
||||
if ( empty( $blogname ) ) {
|
||||
$blogname = $user_name;
|
||||
}
|
||||
?>
|
||||
<form id="setupform" method="post" action="wp-signup.php">
|
||||
<input type="hidden" name="stage" value="validate-blog-signup" />
|
||||
<input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" />
|
||||
<input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" />
|
||||
<input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" />
|
||||
<input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" />
|
||||
<?php
|
||||
/** This action is documented in wp-signup.php */
|
||||
do_action( 'signup_hidden_fields', 'validate-site' );
|
||||
?>
|
||||
<?php show_blog_form($blogname, $blog_title, $errors); ?>
|
||||
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p>
|
||||
<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
|
||||
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Signup' ); ?>" /></p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
@@ -697,8 +725,8 @@ function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_ti
|
||||
function validate_blog_signup() {
|
||||
// Re-validate user info.
|
||||
$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
|
||||
$user_name = $user_result['user_name'];
|
||||
$user_email = $user_result['user_email'];
|
||||
$user_name = $user_result['user_name'];
|
||||
$user_email = $user_result['user_email'];
|
||||
$user_errors = $user_result['errors'];
|
||||
|
||||
if ( $user_errors->get_error_code() ) {
|
||||
@@ -706,20 +734,23 @@ function validate_blog_signup() {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
|
||||
$domain = $result['domain'];
|
||||
$path = $result['path'];
|
||||
$blogname = $result['blogname'];
|
||||
$result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
|
||||
$domain = $result['domain'];
|
||||
$path = $result['path'];
|
||||
$blogname = $result['blogname'];
|
||||
$blog_title = $result['blog_title'];
|
||||
$errors = $result['errors'];
|
||||
$errors = $result['errors'];
|
||||
|
||||
if ( $errors->get_error_code() ) {
|
||||
signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
|
||||
signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors );
|
||||
return false;
|
||||
}
|
||||
|
||||
$public = (int) $_POST['blog_public'];
|
||||
$signup_meta = array ('lang_id' => 1, 'public' => $public);
|
||||
$public = (int) $_POST['blog_public'];
|
||||
$signup_meta = array(
|
||||
'lang_id' => 1,
|
||||
'public' => $public,
|
||||
);
|
||||
|
||||
// Handle the language setting for the new site.
|
||||
if ( ! empty( $_POST['WPLANG'] ) ) {
|
||||
@@ -733,14 +764,13 @@ function validate_blog_signup() {
|
||||
$signup_meta['WPLANG'] = $language;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-signup.php */
|
||||
$meta = apply_filters( 'add_signup_meta', $signup_meta );
|
||||
|
||||
wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
|
||||
confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
|
||||
wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta );
|
||||
confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -758,23 +788,33 @@ function validate_blog_signup() {
|
||||
*/
|
||||
function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
|
||||
?>
|
||||
<h2><?php /* translators: %s: site address */
|
||||
printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
|
||||
<h2>
|
||||
<?php
|
||||
/* translators: %s: site address */
|
||||
printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" )
|
||||
?>
|
||||
</h2>
|
||||
|
||||
<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p>
|
||||
<p><?php /* translators: %s: email address */
|
||||
printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p>
|
||||
<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ); ?></p>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: %s: email address */
|
||||
printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' );
|
||||
?>
|
||||
</p>
|
||||
<p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p>
|
||||
<h2><?php _e( 'Still waiting for your email?' ); ?></h2>
|
||||
<p>
|
||||
<?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ) ?>
|
||||
<?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ); ?>
|
||||
<ul id="noemail-tips">
|
||||
<li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) ?></strong></p></li>
|
||||
<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li>
|
||||
<li><?php
|
||||
<li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ); ?></strong></p></li>
|
||||
<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ); ?></p></li>
|
||||
<li>
|
||||
<?php
|
||||
/* translators: %s: email address */
|
||||
printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email );
|
||||
?></li>
|
||||
?>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<?php
|
||||
@@ -855,64 +895,69 @@ if ( current_user_can( 'manage_network' ) ) {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
$newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
|
||||
$newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
if ( $active_signup == 'none' ) {
|
||||
_e( 'Registration has been disabled.' );
|
||||
} elseif ( $active_signup == 'blog' && !is_user_logged_in() ) {
|
||||
} elseif ( $active_signup == 'blog' && ! is_user_logged_in() ) {
|
||||
$login_url = wp_login_url( network_site_url( 'wp-signup.php' ) );
|
||||
/* translators: %s: login URL */
|
||||
printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
|
||||
} else {
|
||||
$stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
|
||||
$stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
|
||||
switch ( $stage ) {
|
||||
case 'validate-user-signup' :
|
||||
if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
|
||||
case 'validate-user-signup':
|
||||
if ( $active_signup == 'all' || $_POST['signup_for'] == 'blog' && $active_signup == 'blog' || $_POST['signup_for'] == 'user' && $active_signup == 'user' ) {
|
||||
validate_user_signup();
|
||||
else
|
||||
} else {
|
||||
_e( 'User registration has been disabled.' );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'validate-blog-signup':
|
||||
if ( $active_signup == 'all' || $active_signup == 'blog' )
|
||||
if ( $active_signup == 'all' || $active_signup == 'blog' ) {
|
||||
validate_blog_signup();
|
||||
else
|
||||
} else {
|
||||
_e( 'Site registration has been disabled.' );
|
||||
}
|
||||
break;
|
||||
case 'gimmeanotherblog':
|
||||
validate_another_blog_signup();
|
||||
break;
|
||||
case 'default':
|
||||
default :
|
||||
$user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
|
||||
default:
|
||||
$user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
|
||||
/**
|
||||
* Fires when the site sign-up form is sent.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'preprocess_signup_form' );
|
||||
if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
|
||||
signup_another_blog($newblogname);
|
||||
elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) )
|
||||
if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) {
|
||||
signup_another_blog( $newblogname );
|
||||
} elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) {
|
||||
signup_user( $newblogname, $user_email );
|
||||
elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) )
|
||||
} elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) {
|
||||
_e( 'Sorry, new registrations are not allowed at this time.' );
|
||||
else
|
||||
} else {
|
||||
_e( 'You are logged in already. No need to register again!' );
|
||||
}
|
||||
|
||||
if ( $newblogname ) {
|
||||
$newblog = get_blogaddress_by_name( $newblogname );
|
||||
|
||||
if ( $active_signup == 'blog' || $active_signup == 'all' )
|
||||
if ( $active_signup == 'blog' || $active_signup == 'all' ) {
|
||||
/* translators: %s: site address */
|
||||
printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
|
||||
printf(
|
||||
'<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
|
||||
'<strong>' . $newblog . '</strong>'
|
||||
);
|
||||
else
|
||||
/* translators: %s: site address */
|
||||
printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
|
||||
} else { /* translators: %s: site address */
|
||||
printf(
|
||||
'<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
|
||||
'<strong>' . $newblog . '</strong>'
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -926,6 +971,8 @@ if ( $active_signup == 'none' ) {
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'after_signup_form' ); ?>
|
||||
do_action( 'after_signup_form' );
|
||||
?>
|
||||
|
||||
<?php get_footer( 'wp-signup' );
|
||||
<?php
|
||||
get_footer( 'wp-signup' );
|
||||
|
||||
Reference in New Issue
Block a user