wp/wp-signup.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
     1 <?php
     1 <?php
     2 
     2 
     3 /** Sets up the WordPress Environment. */
     3 /** Sets up the WordPress Environment. */
     4 require __DIR__ . '/wp-load.php';
     4 require __DIR__ . '/wp-load.php';
     5 
     5 
     6 add_action( 'wp_head', 'wp_no_robots' );
     6 add_filter( 'wp_robots', 'wp_robots_no_robots' );
     7 
     7 
     8 require __DIR__ . '/wp-blog-header.php';
     8 require __DIR__ . '/wp-blog-header.php';
     9 
     9 
    10 nocache_headers();
    10 nocache_headers();
    11 
    11 
   227  * Validate the new site signup
   227  * Validate the new site signup
   228  *
   228  *
   229  * @since MU (3.0.0)
   229  * @since MU (3.0.0)
   230  *
   230  *
   231  * @return array Contains the new site data and error messages.
   231  * @return array Contains the new site data and error messages.
       
   232  *               See wpmu_validate_blog_signup() for details.
   232  */
   233  */
   233 function validate_blog_form() {
   234 function validate_blog_form() {
   234 	$user = '';
   235 	$user = '';
   235 	if ( is_user_logged_in() ) {
   236 	if ( is_user_logged_in() ) {
   236 		$user = wp_get_current_user();
   237 		$user = wp_get_current_user();
   238 
   239 
   239 	return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user );
   240 	return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user );
   240 }
   241 }
   241 
   242 
   242 /**
   243 /**
   243  * Display user registration form
   244  * Displays the fields for the new user account registration form.
   244  *
   245  *
   245  * @since MU (3.0.0)
   246  * @since MU (3.0.0)
   246  *
   247  *
   247  * @param string          $user_name  The entered username.
   248  * @param string          $user_name  The entered username.
   248  * @param string          $user_email The entered email address.
   249  * @param string          $user_email The entered email address.
   275 	$errmsg = $errors->get_error_message( 'generic' );
   276 	$errmsg = $errors->get_error_message( 'generic' );
   276 	if ( $errmsg ) {
   277 	if ( $errmsg ) {
   277 		echo '<p class="error">' . $errmsg . '</p>';
   278 		echo '<p class="error">' . $errmsg . '</p>';
   278 	}
   279 	}
   279 	/**
   280 	/**
   280 	 * Fires at the end of the user registration form on the site sign-up form.
   281 	 * Fires at the end of the new user account registration form.
   281 	 *
   282 	 *
   282 	 * @since 3.0.0
   283 	 * @since 3.0.0
   283 	 *
   284 	 *
   284 	 * @param WP_Error $errors A WP_Error object containing 'user_name' or 'user_email' errors.
   285 	 * @param WP_Error $errors A WP_Error object containing 'user_name' or 'user_email' errors.
   285 	 */
   286 	 */
   290  * Validate user signup name and email
   291  * Validate user signup name and email
   291  *
   292  *
   292  * @since MU (3.0.0)
   293  * @since MU (3.0.0)
   293  *
   294  *
   294  * @return array Contains username, email, and error messages.
   295  * @return array Contains username, email, and error messages.
       
   296  *               See wpmu_validate_user_signup() for details.
   295  */
   297  */
   296 function validate_user_form() {
   298 function validate_user_form() {
   297 	return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
   299 	return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
   298 }
   300 }
   299 
   301 
   545 	 */
   547 	 */
   546 	do_action( 'signup_finished' );
   548 	do_action( 'signup_finished' );
   547 }
   549 }
   548 
   550 
   549 /**
   551 /**
   550  * Setup the new user signup process
   552  * Shows a form for a visitor to sign up for a new user account.
   551  *
   553  *
   552  * @since MU (3.0.0)
   554  * @since MU (3.0.0)
   553  *
   555  *
   554  * @param string          $user_name  The username.
   556  * @param string          $user_name  The username.
   555  * @param string          $user_email The user's email.
   557  * @param string          $user_email The user's email.
   681 	/** This action is documented in wp-signup.php */
   683 	/** This action is documented in wp-signup.php */
   682 	do_action( 'signup_finished' );
   684 	do_action( 'signup_finished' );
   683 }
   685 }
   684 
   686 
   685 /**
   687 /**
   686  * Setup the new site signup
   688  * Shows a form for a user or visitor to sign up for a new site.
   687  *
   689  *
   688  * @since MU (3.0.0)
   690  * @since MU (3.0.0)
   689  *
   691  *
   690  * @param string          $user_name  The username.
   692  * @param string          $user_name  The username.
   691  * @param string          $user_email The user's email address.
   693  * @param string          $user_email The user's email address.
   805 	confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta );
   807 	confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta );
   806 	return true;
   808 	return true;
   807 }
   809 }
   808 
   810 
   809 /**
   811 /**
   810  * New site signup confirmation
   812  * Shows a message confirming that the new site has been registered and is awaiting activation.
   811  *
   813  *
   812  * @since MU (3.0.0)
   814  * @since MU (3.0.0)
   813  *
   815  *
   814  * @param string $domain     The domain URL.
   816  * @param string $domain     The domain or subdomain of the site.
   815  * @param string $path       The site root path.
   817  * @param string $path       The path of the site.
   816  * @param string $blog_title The new site title.
   818  * @param string $blog_title The title of the new site.
   817  * @param string $user_name  The user's username.
   819  * @param string $user_name  The user's username.
   818  * @param string $user_email The user's email address.
   820  * @param string $user_email The user's email address.
   819  * @param array  $meta       Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup().
   821  * @param array  $meta       Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup().
   820  */
   822  */
   821 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
   823 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
   859  *
   861  *
   860  * @since 4.4.0
   862  * @since 4.4.0
   861  *
   863  *
   862  * @see get_available_languages()
   864  * @see get_available_languages()
   863  *
   865  *
   864  * @return array List of available languages.
   866  * @return string[] Array of available language codes. Language codes are formed by
       
   867  *                  stripping the .mo extension from the language file names.
   865  */
   868  */
   866 function signup_get_available_languages() {
   869 function signup_get_available_languages() {
   867 	/**
   870 	/**
   868 	 * Filters the list of available languages for front-end site signups.
   871 	 * Filters the list of available languages for front-end site signups.
   869 	 *
   872 	 *
   872 	 *
   875 	 *
   873 	 * Languages not already installed will be stripped.
   876 	 * Languages not already installed will be stripped.
   874 	 *
   877 	 *
   875 	 * @since 4.4.0
   878 	 * @since 4.4.0
   876 	 *
   879 	 *
   877 	 * @param array $available_languages Available languages.
   880 	 * @param string[] $languages Array of available language codes. Language codes are formed by
       
   881 	 *                            stripping the .mo extension from the language file names.
   878 	 */
   882 	 */
   879 	$languages = (array) apply_filters( 'signup_get_available_languages', get_available_languages() );
   883 	$languages = (array) apply_filters( 'signup_get_available_languages', get_available_languages() );
   880 
   884 
   881 	/*
   885 	/*
   882 	 * Strip any non-installed languages and return.
   886 	 * Strip any non-installed languages and return.
   982 				$newblog = get_blogaddress_by_name( $newblogname );
   986 				$newblog = get_blogaddress_by_name( $newblogname );
   983 
   987 
   984 				if ( 'blog' === $active_signup || 'all' === $active_signup ) {
   988 				if ( 'blog' === $active_signup || 'all' === $active_signup ) {
   985 					printf(
   989 					printf(
   986 						/* translators: %s: Site address. */
   990 						/* translators: %s: Site address. */
   987 						'<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
   991 						'<p>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</p>',
   988 						'<strong>' . $newblog . '</strong>'
   992 						'<strong>' . $newblog . '</strong>'
   989 					);
   993 					);
   990 				} else {
   994 				} else {
   991 					printf(
   995 					printf(
   992 						/* translators: %s: Site address. */
   996 						/* translators: %s: Site address. */
   993 						'<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
   997 						'<p>' . __( 'The site you were looking for, %s, does not exist.' ) . '</p>',
   994 						'<strong>' . $newblog . '</strong>'
   998 						'<strong>' . $newblog . '</strong>'
   995 					);
   999 					);
   996 				}
  1000 				}
   997 			}
  1001 			}
   998 			break;
  1002 			break;