Ticket #31928: 31928.diff
File 31928.diff, 83.5 KB (added by , 6 years ago) |
---|
-
src/wp-activate.php
diff --git src/wp-activate.php src/wp-activate.php index b13279a..afb6d17 100644
if ( !is_multisite() ) { 18 18 die(); 19 19 } 20 20 21 if ( is_object( $wp_object_cache ) ) 21 if ( is_object( $wp_object_cache ) ) { 22 22 $wp_object_cache->cache_enabled = false; 23 } 23 24 24 25 // Fix for page title 25 26 $wp_query->is_404 = false; 26 27 28 // Handle signup stage 29 signup_handle_stage( 'activate' ); 30 27 31 /** 28 32 * Fires before the Site Activation page is loaded. 29 33 * … … $wp_query->is_404 = false; 31 35 */ 32 36 do_action( 'activate_header' ); 33 37 34 /** 35 * Adds an action hook specific to this page. 36 * 37 * Fires on {@see 'wp_head'}. 38 * 39 * @since MU 40 */ 41 function do_activate_header() { 42 /** 43 * Fires before the Site Activation page is loaded. 44 * 45 * Fires on the {@see 'wp_head'} action. 46 * 47 * @since 3.0.0 48 */ 49 do_action( 'activate_wp_head' ); 50 } 51 add_action( 'wp_head', 'do_activate_header' ); 52 53 /** 54 * Loads styles specific to this page. 55 * 56 * @since MU 57 */ 58 function wpmu_activate_stylesheet() { 59 ?> 60 <style type="text/css"> 61 form { margin-top: 2em; } 62 #submit, #key { width: 90%; font-size: 24px; } 63 #language { margin-top: .5em; } 64 .error { background: #f66; } 65 span.h3 { padding: 0 8px; font-size: 1.3em; font-weight: bold; } 66 </style> 67 <?php 68 } 69 add_action( 'wp_head', 'wpmu_activate_stylesheet' ); 38 // Add activate headers 39 activate_head_actions(); 70 40 41 // Load the activate header 71 42 get_header( 'wp-activate' ); 72 ?>73 74 <div id="signup-content" class="widecolumn">75 <div class="wp-activate-container">76 <?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?>77 78 <h2><?php _e('Activation Key Required') ?></h2>79 <form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>">80 <p>81 <label for="key"><?php _e('Activation Key:') ?></label>82 <br /><input type="text" name="key" id="key" value="" size="50" />83 </p>84 <p class="submit">85 <input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e('Activate') ?>" />86 </p>87 </form>88 89 <?php } else {90 91 $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];92 $result = wpmu_activate_signup( $key );93 if ( is_wp_error($result) ) {94 if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {95 $signup = $result->get_error_data();96 ?>97 <h2><?php _e('Your account is now active!'); ?></h2>98 <?php99 echo '<p class="lead-in">';100 if ( $signup->domain . $signup->path == '' ) {101 printf(102 /* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */103 __( 'Your account has been activated. You may now <a href="%1$s">log in</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>.' ),104 network_site_url( 'wp-login.php', 'login' ),105 $signup->user_login,106 $signup->user_email,107 wp_lostpassword_url()108 );109 } else {110 printf(111 /* translators: 1: site URL, 2: site domain, 3: username, 4: user email, 5: lost password URL */112 __( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in 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>.' ),113 'http://' . $signup->domain,114 $signup->domain,115 $signup->user_login,116 $signup->user_email,117 wp_lostpassword_url()118 );119 }120 echo '</p>';121 } else {122 ?>123 <h2><?php _e( 'An error occurred during the activation' ); ?></h2>124 <p><?php echo $result->get_error_message(); ?></p>125 <?php126 }127 } else {128 $url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';129 $user = get_userdata( (int) $result['user_id'] );130 ?>131 <h2><?php _e('Your account is now active!'); ?></h2>132 43 133 <div id="signup-welcome"> 134 <p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p> 135 <p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $result['password']; ?></p> 136 </div> 44 // Display the signup template 45 get_template_part( 'signup' ); 137 46 138 <?php if ( $url && $url != network_home_url( '', 'http' ) ) : 139 switch_to_blog( (int) $result['blog_id'] ); 140 $login_url = wp_login_url(); 141 restore_current_blog(); 142 ?> 143 <p class="view"><?php 144 /* translators: 1: site URL, 2: login URL */ 145 printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) ); 146 ?></p> 147 <?php else: ?> 148 <p class="view"><?php 149 /* translators: 1: login URL, 2: network home URL */ 150 printf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() ); 151 ?></p> 152 <?php endif; 153 } 154 } 155 ?> 156 </div> 157 </div> 158 <script type="text/javascript"> 159 var key_input = document.getElementById('key'); 160 key_input && key_input.focus(); 161 </script> 162 <?php get_footer( 'wp-activate' ); 47 get_footer( 'wp-activate' ); -
src/wp-includes/css/wp-signup.css
diff --git src/wp-includes/css/wp-signup.css src/wp-includes/css/wp-signup.css index e69de29..debcbd7 100644
1 .mu_register { 2 width: 90%; 3 margin:0 auto; 4 } 5 6 .mu_register form { 7 margin-top: 2em; 8 } 9 10 .mu_register .error { 11 font-weight: 700; 12 padding: 10px; 13 color: #333333; 14 background: #FFEBE8; 15 border: 1px solid #CC0000; 16 } 17 18 .mu_register input[type="submit"], 19 .mu_register #blog_title, 20 .mu_register #user_email, 21 .mu_register #blogname, 22 .mu_register #user_name { 23 width: 100%; 24 font-size: 24px; 25 margin: 5px 0; 26 } 27 28 .mu_register #site-language { 29 display: block; 30 } 31 32 .mu_register .prefix_address, 33 .mu_register .suffix_address { 34 font-size: 18px; 35 display: inline; 36 } 37 38 .mu_register label { 39 font-weight: 700; 40 font-size: 15px; 41 display: block; 42 margin: 10px 0; 43 } 44 45 .mu_register label.checkbox { 46 display: inline; 47 } 48 49 .mu_register .mu_alert { 50 font-weight: 700; 51 padding: 10px; 52 color: #333333; 53 background: #ffffe0; 54 border: 1px solid #e6db55; 55 } 56 57 .wp-activate-container form { 58 margin-top: 2em; 59 } 60 61 .wp-activate-container form #submit, 62 .wp-activate-container form #key { 63 width: 90%; 64 font-size: 24px; 65 } 66 67 .wp-activate-container #language { 68 margin-top: .5em; 69 } 70 71 .wp-activate-container .error { 72 background: #f66; 73 } 74 75 .wp-activate-container span.h3 { 76 padding: 0 8px; 77 font-size: 1.3em; 78 font-weight: bold; 79 } -
src/wp-includes/ms-default-filters.php
diff --git src/wp-includes/ms-default-filters.php src/wp-includes/ms-default-filters.php index 08d752a..94ac7b2 100644
add_action( 'after_signup_site', 'wpmu_signup_blog_notification', 10, 7 ); 42 42 // Register Nonce 43 43 add_action( 'signup_hidden_fields', 'signup_nonce_fields' ); 44 44 45 /** 46 * Add actions to the 'wp_head' hook for the signup page. 47 * 48 * This function is used in wp-signup.php to 49 * make sure the signup page is beeing displayed. 50 * 51 * @since ? 52 */ 53 function signup_head_actions() { 54 add_action( 'wp_head', 'wp_no_robots' ); 55 add_action( 'wp_head', 'do_signup_header' ); 56 add_action( 'wp_head', 'wpmu_signup_stylesheet' ); 57 } 58 59 /** 60 * Add actions to the 'wp_head' hook for the activate page. 61 * 62 * This function is used in wp-activate.php to 63 * make sure the activate page is beeing displayed. 64 * 65 * @since ? 66 */ 67 function activate_head_actions() { 68 add_action( 'wp_head', 'do_activate_header' ); 69 add_action( 'wp_head', 'wpmu_activate_stylesheet' ); 70 } 71 45 72 // Template 46 73 add_action( 'template_redirect', 'maybe_redirect_404' ); 47 74 add_filter( 'allowed_redirect_hosts', 'redirect_this_site' ); -
src/wp-includes/ms-deprecated.php
diff --git src/wp-includes/ms-deprecated.php src/wp-includes/ms-deprecated.php index cd35f55..697ad27 100644
function wp_get_sites( $args = array() ) { 513 513 514 514 return $results; 515 515 } 516 517 /** 518 * Validate user signup name and email 519 * 520 * @since MU 521 * @deprecated ? 522 * 523 * @return array Contains username, email, and error messages. 524 */ 525 function validate_user_form() { 526 _deprecated_function( __FUNCTION__, '?' ); 527 528 return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); 529 } 530 531 /** 532 * Validate the new site signup 533 * 534 * @since MU 535 * @deprecated ? 536 * 537 * @return array Contains the new site data and error messages. 538 */ 539 function validate_blog_form() { 540 _deprecated_function( __FUNCTION__, '?' ); 541 542 $user = ''; 543 if ( is_user_logged_in() ) { 544 $user = wp_get_current_user(); 545 } 546 547 return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user ); 548 } -
src/wp-includes/ms-functions.php
diff --git src/wp-includes/ms-functions.php src/wp-includes/ms-functions.php index b2b37d5..dcb72ec 100644
function is_email_address_unsafe( $user_email ) { 388 388 } 389 389 390 390 /** 391 * Retrieves languages available during the site/user signup process. 392 * 393 * @since 4.4.0 394 * 395 * @see get_available_languages() 396 * 397 * @return array List of available languages. 398 */ 399 function signup_get_available_languages() { 400 /** 401 * Filters the list of available languages for front-end site signups. 402 * 403 * Passing an empty array to this hook will disable output of the setting on the 404 * signup form, and the default language will be used when creating the site. 405 * 406 * Languages not already installed will be stripped. 407 * 408 * @since 4.4.0 409 * 410 * @param array $available_languages Available languages. 411 */ 412 $languages = (array) apply_filters( 'signup_get_available_languages', get_available_languages() ); 413 414 /* 415 * Strip any non-installed languages and return. 416 * 417 * Re-call get_available_languages() here in case a language pack was installed 418 * in a callback hooked to the 'signup_get_available_languages' filter before this point. 419 */ 420 return array_intersect_assoc( $languages, get_available_languages() ); 421 } 422 423 /** 424 * Handle the signup stage and act accordingly. 425 * 426 * @since ? 427 * 428 * @param string $page The page being displayed between the signup and the activate page. 429 */ 430 function signup_handle_stage( $page = 'signup' ) { 431 global $stage_errors, $active_signup, $signup_action; 432 433 $stage_errors = new WP_Error(); 434 $signup_action = array(); 435 436 // Activation 437 if ( 'activate' === $page ) { 438 if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { 439 $signup_action['action'] = 'activate_form'; 440 } else { 441 if ( ! empty( $_GET['key'] ) ) { 442 $key = $_GET['key']; 443 } else { 444 $key = $_POST['key']; 445 } 446 447 $signup_action = array( 448 'action' => 'process_activation', 449 'key' => $key, 450 ); 451 } 452 return; 453 } 454 455 // Registration 456 $signup_stage = 'default'; 457 if ( isset( $_POST['stage'] ) ) { 458 $signup_stage = $_POST['stage']; 459 } 460 461 $signup_for = ''; 462 if ( ! empty( $_POST[ 'signup_for' ] ) ) { 463 $signup_for = $_POST[ 'signup_for' ]; 464 } 465 466 $newblogname = null; 467 if ( isset( $_GET['new'] ) ) { 468 $newblogname = strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ); 469 } 470 471 // Signup is disabled 472 if ( 'none' === $active_signup ) { 473 $stage_errors->add( 'registration_closed', __( 'Registration has been disabled.' ) ); 474 475 // Loggedin users can add new sites. 476 } elseif ( 'blog' === $active_signup && ! is_user_logged_in() ) { 477 $stage_errors->add( 'blog_registration_not_logged_in', sprintf( 478 /* translators: %s: login URL */ 479 __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), 480 esc_url( wp_login_url( network_site_url( 'wp-signup.php' ) ) ) 481 ) ); 482 483 // User validate stage reached although user registration is disabled. 484 } elseif ( 'validate-user-signup' === $signup_stage && ! ( 485 'all' === $active_signup || 486 'blog' === $signup_for && 'blog' === $active_signup || 487 'user' === $signup_for && 'user' === $active_signup 488 ) ) { 489 $stage_errors->add( 'wrong_validate_user_stage', __( 'User registration has been disabled.' ) ); 490 491 // Blog validate stage reached although blog registration is disabled. 492 } elseif ( 'validate-blog-signup' === $signup_stage && ! ( 493 'all' === $active_signup || 'blog' === $active_signup 494 ) ) { 495 $stage_errors->add( 'wrong_validate_blog_stage', __( 'Site registration has been disabled.' ) ); 496 497 // Default stage reached but.. 498 } elseif ( 'default' === $signup_stage ) { 499 // Users can't register accounts. 500 if ( ! is_user_logged_in() && 'blog' === $active_signup ) { 501 $stage_errors->add( 'wrong_default_blog_stage', __( 'Sorry, new registrations are not allowed at this time.' ) ); 502 503 // Users is already regitered. 504 } elseif ( is_user_logged_in() && 'user' === $active_signup ) { 505 $stage_errors->add( 'wrong_default_user_stage', __( 'You are logged in already. No need to register again!' ) ); 506 } 507 } 508 509 // Only process stages if no errors 510 if ( ! $stage_errors->get_error_code() ) { 511 switch ( $signup_stage ) { 512 case 'validate-user-signup' : 513 case 'validate-blog-signup' : 514 $user_name = ''; 515 if ( isset( $_POST['user_name'] ) ) { 516 $user_name = $_POST['user_name']; 517 } 518 519 $user_email = ''; 520 if ( isset( $_POST['user_email'] ) ) { 521 $user_email = $_POST['user_email']; 522 } 523 524 $signup_for = 'blog'; 525 if ( isset( $_POST['signup_for'] ) ) { 526 $signup_for = $_POST['signup_for']; 527 } 528 529 // Always Validate user. 530 $result = wpmu_validate_user_signup( $user_name, $user_email ); 531 532 $signup_action = array( 533 'type' => $signup_for, 534 'action' => 'validate', 535 'result' => $result['errors'], 536 'user_name' => $result['user_name'], 537 'user_email' => $result['user_email'], 538 ); 539 540 if ( $result['errors']->get_error_code() ) { 541 $signup_action['action'] = 'form'; 542 $signup_action['type'] = 'user'; 543 544 // Validate site only if needed. 545 } elseif ( 'blog' === $signup_for ) { 546 $signup_action['action'] = 'form'; 547 548 $signup_action['blogname'] = ''; 549 if ( isset( $_POST['blogname'] ) ) { 550 $signup_action['blogname'] = $_POST['blogname']; 551 } 552 553 $signup_action['blog_title'] = ''; 554 if ( isset( $_POST['blog_title'] ) ) { 555 $signup_action['blog_title'] = $_POST['blog_title']; 556 } 557 558 if ( 'validate-blog-signup' === $signup_stage ) { 559 $result = wpmu_validate_blog_signup( $signup_action['blogname'], $signup_action['blog_title'] ); 560 if ( $result['errors']->get_error_code() ) { 561 $signup_action['result'] = $result['errors']; 562 } else { 563 $signup_action = array_merge( $signup_action, $result ); 564 565 $signup_action['action'] = 'validate'; 566 $signup_action['blog_public'] = 1; 567 568 if ( isset( $_POST['blog_public'] ) ) { 569 $signup_action['blog_public'] = (int) $_POST['blog_public']; 570 } 571 } 572 } 573 } 574 break; 575 576 case 'gimmeanotherblog' : 577 $blogname = ''; 578 if ( isset( $_POST['blogname'] ) ) { 579 $blogname = $_POST['blogname']; 580 } 581 582 $blog_title = ''; 583 if ( isset( $_POST['blog_title'] ) ) { 584 $blog_title = $_POST['blog_title']; 585 } 586 587 $result = wpmu_validate_blog_signup( $blogname, $blog_title, wp_get_current_user() ); 588 589 $signup_action = array( 590 'type' => 'blog', 591 'action' => 'validate', 592 'result' => $result['errors'], 593 'blogname' => $result['blogname'], 594 'blog_title' => $result['blog_title'], 595 ); 596 597 if ( $result['errors']->get_error_code() ) { 598 $signup_action['action'] = 'form'; 599 } else { 600 $signup_action = array_merge( $signup_action, $result ); 601 $signup_action['blog_public'] = 1; 602 603 if ( isset( $_POST['blog_public'] ) ) { 604 $signup_action['blog_public'] = (int) $_POST['blog_public']; 605 } 606 } 607 break; 608 609 case 'default': 610 default : 611 $user_email = ''; 612 613 if ( isset( $_POST[ 'user_email' ] ) ) { 614 $user_email = $_POST[ 'user_email' ]; 615 } 616 617 // User exists and is registering a new site. 618 if ( ( 'all' === $active_signup || 'blog' === $active_signup ) && is_user_logged_in() ) { 619 $signup_action = array( 620 'type' => 'blog', 621 'action' => 'form', 622 'result' => null, 623 'blogname' => $newblogname, 624 ); 625 626 // It's a new user. 627 } elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) { 628 $signup_action = array( 629 'type' => 'user', 630 'action' => 'form', 631 'result' => null, 632 'user_name' => $newblogname, 633 'user_email' => $user_email, 634 ); 635 } 636 break; 637 } 638 } 639 640 // Add the user notice if needed. 641 if ( $newblogname && 'default' === $signup_stage ) { 642 $newblog = get_blogaddress_by_name( $newblogname ); 643 644 if ( 'blog' === $active_signup || 'all' === $active_signup ) { 645 $signup_action['notice'] = sprintf( 646 /* translators: %s: site address */ 647 '<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>', 648 '<strong>' . $newblog . '</strong>' 649 ); 650 } elseif ( 'none' !== $active_signup ) { 651 $signup_action['notice'] = sprintf( 652 /* translators: %s: site address */ 653 '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>', 654 '<strong>' . $newblog . '</strong>' 655 ); 656 } 657 } 658 } 659 660 /** 391 661 * Sanitize and validate data required for a user sign-up. 392 662 * 393 663 * Verifies the validity and uniqueness of user names and user email addresses, … … function wpmu_validate_user_signup($user_name, $user_email) { 520 790 } 521 791 522 792 /** 793 * Validate the new user signup 794 * 795 * @since MU 796 * 797 * @return bool True if new user signup was validated, false if error 798 */ 799 function validate_user_signup() { 800 global $signup_action; 801 802 if ( ! isset( $signup_action['user_name'] ) || ! isset( $signup_action['user_email'] ) ) { 803 return false; 804 } 805 806 $user_name = $signup_action['user_name']; 807 $user_email = $signup_action['user_email']; 808 809 /** This filter is documented in wp-signup.php */ 810 wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) ); 811 812 // The user successfully signed up 813 confirm_user_signup( $user_name, $user_email ); 814 return true; 815 } 816 817 /** 523 818 * Processes new site registrations. 524 819 * 525 820 * Checks the data provided by the user during blog signup. Verifies … … function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { 653 948 } 654 949 655 950 /** 951 * Validate new site signup 952 * 953 * @since MU 954 * 955 * @return bool True if the site signup was validated, false if error 956 */ 957 function validate_blog_signup() { 958 global $signup_action; 959 960 if ( ! isset( $signup_action['user_name'] ) || ! isset( $signup_action['blogname'] ) ) { 961 return false; 962 } 963 964 $user_name = $signup_action['user_name']; 965 $user_email = $signup_action['user_email']; 966 $domain = $signup_action['domain']; 967 $path = $signup_action['path']; 968 $blogname = $signup_action['blogname']; 969 $blog_title = $signup_action['blog_title']; 970 $public = (int) $signup_action['blog_public']; 971 972 $signup_meta = array ('lang_id' => 1, 'public' => $public); 973 974 // Handle the language setting for the new site. 975 if ( ! empty( $_POST['WPLANG'] ) ) { 976 977 $languages = signup_get_available_languages(); 978 979 if ( in_array( $_POST['WPLANG'], $languages ) ) { 980 $language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); 981 982 if ( $language ) { 983 $signup_meta['WPLANG'] = $language; 984 } 985 } 986 } 987 988 /** This filter is documented in wp-signup.php */ 989 $meta = apply_filters( 'add_signup_meta', $signup_meta ); 990 991 wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta ); 992 993 // Attention ça est dans le template 994 confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta ); 995 return true; 996 } 997 998 /** 999 * Validate a new site signup. 1000 * 1001 * @since MU 1002 * 1003 * @return null|bool True if site signup was validated, false if error. 1004 * The function halts all execution if the user is not logged in. 1005 */ 1006 function validate_another_blog_signup() { 1007 global $wpdb, $signup_action; 1008 1009 $current_user = wp_get_current_user(); 1010 1011 if ( ! is_user_logged_in() || ! isset( $signup_action['blogname'] ) ) { 1012 die(); 1013 } 1014 1015 // Extracted values set/overwrite globals. 1016 $domain = $signup_action['domain']; 1017 $path = $signup_action['path']; 1018 $blogname = $signup_action['blogname']; 1019 $blog_title = $signup_action['blog_title']; 1020 $public = (int) $signup_action['blog_public']; 1021 1022 $blog_meta_defaults = array( 1023 'lang_id' => 1, 1024 'public' => $public 1025 ); 1026 1027 // Handle the language setting for the new site. 1028 if ( ! empty( $_POST['WPLANG'] ) ) { 1029 1030 $languages = signup_get_available_languages(); 1031 1032 if ( in_array( $_POST['WPLANG'], $languages ) ) { 1033 $language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); 1034 1035 if ( $language ) { 1036 $blog_meta_defaults['WPLANG'] = $language; 1037 } 1038 } 1039 } 1040 1041 /** 1042 * Filters the new site meta variables. 1043 * 1044 * Use the {@see 'add_signup_meta'} filter instead. 1045 * 1046 * @since MU 1047 * @deprecated 3.0.0 Use the {@see 'add_signup_meta'} filter instead. 1048 * 1049 * @param array $blog_meta_defaults An array of default blog meta variables. 1050 */ 1051 $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults ); 1052 1053 /** 1054 * Filters the new default site meta variables. 1055 * 1056 * @since 3.0.0 1057 * 1058 * @param array $meta { 1059 * An array of default site meta variables. 1060 * 1061 * @type int $lang_id The language ID. 1062 * @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false. 1063 * } 1064 */ 1065 $meta = apply_filters( 'add_signup_meta', $meta_defaults ); 1066 1067 $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid ); 1068 1069 if ( is_wp_error( $blog_id ) ) { 1070 return false; 1071 } 1072 1073 // Display the confirmation. 1074 confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id ); 1075 return true; 1076 } 1077 1078 /** 656 1079 * Record site signup information for future activation. 657 1080 * 658 1081 * @since MU -
src/wp-includes/ms-template.php
diff --git src/wp-includes/ms-template.php src/wp-includes/ms-template.php index e69de29..206d95d 100644
1 <?php 2 /** 3 * Multisite specific Template functions 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 */ 8 9 /** 10 * Prints signup_header via wp_head 11 * 12 * @since MU 13 */ 14 function do_signup_header() { 15 /** 16 * Fires within the head section of the site sign-up screen. 17 * 18 * @since 3.0.0 19 */ 20 do_action( 'signup_header' ); 21 } 22 23 /** 24 * Adds an action hook specific to this page. 25 * 26 * Fires on {@see 'wp_head'}. 27 * 28 * @since MU 29 */ 30 function do_activate_header() { 31 /** 32 * Fires before the Site Activation page is loaded. 33 * 34 * Fires on the {@see 'wp_head'} action. 35 * 36 * @since 3.0.0 37 */ 38 do_action( 'activate_wp_head' ); 39 } 40 41 /** 42 * Output the style rules to format the signup and the activate form. 43 * 44 * @since ? 45 */ 46 function wpmu_signup_stylesheet() { 47 ?> 48 <style type="text/css"> 49 <?php 50 if ( SCRIPT_DEBUG ) { 51 readfile( ABSPATH . WPINC . "/css/wp-signup.css" ); 52 } else { 53 /* 54 * If you're looking at a src version of this file, you'll see an "include" 55 * statement below. This is used by the `grunt build` process to directly 56 * include a minified version of wp-signup.css, instead of using the 57 * readfile() method from above. 58 * 59 * If you're looking at a build version of this file, you'll see a string of 60 * minified CSS. If you need to debug it, please turn on SCRIPT_DEBUG 61 * and edit wp-signup.css directly. 62 */ 63 print( 'include "css/wp-signup.min.css"'); 64 } 65 ?> 66 </style> 67 <?php 68 } 69 70 /** 71 * Loads styles specific to this page. 72 * 73 * The function is kept so that it's still possible 74 * to unhook 'wpmu_activate_stylesheet' from 'wp_head' 75 * 76 * @since MU 77 * @since ? Share the style rules of the signup page. 78 */ 79 function wpmu_activate_stylesheet() { 80 return wpmu_signup_stylesheet(); 81 } 82 83 /** 84 * Output the classes for the signup and activate forms. 85 * 86 * @since ? 87 */ 88 function signup_classes() { 89 global $active_signup; 90 91 if ( is_null( $active_signup ) ) { 92 $signup_classes = array( 'wp-activate-container' ); 93 } else { 94 $signup_classes = array( 'mu_register', 'wp-signup-container' ); 95 } 96 97 /** 98 * Filter here to edit signup/activate classes. 99 * 100 * @since ? 101 * 102 * @param array $signup_classes An array of CSS classes. 103 */ 104 $signup_classes = (array) apply_filters( 'signup_classes', $signup_classes ); 105 106 echo join( ' ', array_map( 'sanitize_html_class', $signup_classes ) ); 107 } 108 109 /** 110 * Displays Administrator's notices if any. 111 * 112 * @since ? 113 */ 114 function do_signup_admin_notice() { 115 global $active_signup; 116 117 if ( ! current_user_can( 'manage_network' ) || is_null( $active_signup ) ) { 118 return; 119 } 120 121 $notice = ''; 122 switch ( $active_signup ) { 123 case 'none': 124 $notice = __( 'The network currently disallows registrations.' ); 125 break; 126 127 case 'blog': 128 $notice = __( 'The network currently allows site registrations.' ); 129 break; 130 131 case 'user': 132 $notice = __( 'The network currently allows user registrations.' ); 133 break; 134 135 default: 136 $notice = __( 'The network currently allows both site and user registrations.' ); 137 break; 138 } 139 140 printf( ' 141 <div class="mu_alert"> 142 %1$s %2$s %3$s 143 </div> 144 ', 145 esc_html__( 'Greetings Network Administrator!' ), 146 esc_html( $notice ), 147 /* translators: %s: network settings URL */ 148 sprintf( __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ), esc_url( network_admin_url( 'settings.php' ) ) ) 149 ); 150 } 151 152 /** 153 * Displays user notices if any. 154 * 155 * @since ? 156 */ 157 function do_signup_user_notice() { 158 global $signup_action; 159 160 if ( ! isset( $signup_action['notice'] ) ) { 161 return; 162 } 163 164 echo wp_kses( $signup_action['notice'], wp_kses_allowed_html() ); 165 } 166 167 /** 168 * Checks if there are signup errors. 169 * 170 * @since ? 171 * 172 * @return bool True if signup errors were found. False otherwise. 173 */ 174 function signup_has_errors() { 175 global $stage_errors; 176 177 return (bool) $stage_errors->get_error_code(); 178 } 179 180 /** 181 * Displays signup errors. 182 * 183 * @since ? 184 */ 185 function print_signup_errors() { 186 global $stage_errors; 187 188 echo '<p>' . join( '</p><p>', $stage_errors->get_error_messages() ) . '</p>'; 189 } 190 191 /** 192 * Output the right signup form according to parameters. 193 * 194 * @since ? 195 * 196 * @param array $args { 197 * Form arguments. Optional. 198 * 199 * @type string $type Whether it's a 'user' or a 'blog' to create. Default empty. 200 * @type string $action Whether it's a 'validate' or a 'form' action. Default empty. 201 * @type null|WP_Error $echo The result of the form validation. Default null. 202 * @type string $user_name The user name to create. Default empty. 203 * @type string $blogname The site name to create. Default empty. 204 * @type string $blog_title The site title to create. Default empty. 205 * } 206 */ 207 function do_signup_form( $args = array() ) { 208 global $signup_action; 209 210 if ( ! $args ) { 211 $args = (array) $signup_action; 212 } 213 214 $signup_args = wp_parse_args( $args, array( 215 'type' => '', 216 'action' => '', 217 'result' => null, 218 'user_name' => '', 219 'user_email' => '', 220 'blogname' => '', 221 'blog_title' => '', 222 ) ); 223 224 // Forms. 225 if ( 'form' === $signup_args['action'] ) { 226 /** 227 * Fires when the site sign-up form is sent. 228 * 229 * @since 3.0.0 230 */ 231 do_action( 'preprocess_signup_form' ); 232 233 // User form 234 if ( 'user' === $signup_args['type'] ) { 235 signup_user( $signup_args['user_name'], $signup_args['user_email'], $signup_args['result'] ); 236 237 // Site forms 238 } elseif ( 'blog' === $signup_args['type'] ) { 239 240 // A new user is registering a site. 241 if ( ! is_user_logged_in() ) { 242 signup_blog( $signup_args['user_name'], $signup_args['user_email'], $signup_args['blogname'], $signup_args['blog_title'], $signup_args['result'] ); 243 244 // An existing user is registering a new site. 245 } else { 246 signup_another_blog( $signup_args['blogname'], $signup_args['blog_title'], $signup_args['result'] ); 247 } 248 } 249 250 // Confirmations. 251 } elseif ( 'validate' === $signup_args['action'] ) { 252 // User validation. 253 if ( 'user' === $signup_args['type'] ) { 254 validate_user_signup(); 255 256 // Site validation. 257 } elseif ( 'blog' === $signup_args['type'] ) { 258 259 // Validate the site of the new user. 260 if ( ! is_user_logged_in() ) { 261 validate_blog_signup(); 262 263 // Validate the site of the existing user. 264 } else { 265 validate_another_blog_signup(); 266 } 267 } 268 269 // Account activation. 270 } elseif ( 'activate_form' === $signup_args['action'] ) { 271 activate_user_form(); 272 } elseif ( 'process_activation' === $signup_args['action'] ) { 273 activate_user(); 274 } 275 } 276 277 /** 278 * Generates and displays the Signup and Create Site forms 279 * 280 * @since MU 281 * 282 * @param string $blogname The new site name. 283 * @param string $blog_title The new site title. 284 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 285 */ 286 function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 287 if ( ! is_wp_error( $errors ) ) { 288 $errors = new WP_Error(); 289 } 290 291 $current_network = get_network(); 292 293 // Blog name 294 if ( !is_subdomain_install() ) { 295 echo '<label for="blogname">' . __('Site Name:') . '</label>'; 296 } else { 297 echo '<label for="blogname">' . __('Site Domain:') . '</label>'; 298 } 299 300 if ( $errmsg = $errors->get_error_message('blogname') ) { ?> 301 <p class="error"><?php echo $errmsg ?></p> 302 <?php } 303 304 if ( !is_subdomain_install() ) { 305 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 />'; 306 } else { 307 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 />'; 308 } 309 310 if ( ! is_user_logged_in() ) { 311 if ( ! is_subdomain_install() ) { 312 $site = $current_network->domain . $current_network->path . __( 'sitename' ); 313 } else { 314 $site = __( 'domain' ) . '.' . $site_domain . $current_network->path; 315 } 316 317 /* translators: %s: site address */ 318 echo '<p>(<strong>' . sprintf( __( 'Your address will be %s.' ), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>'; 319 } 320 321 // Blog Title 322 ?> 323 <label for="blog_title"><?php _e('Site Title:') ?></label> 324 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> 325 <p class="error"><?php echo $errmsg ?></p> 326 <?php } 327 echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />'; 328 329 // Site Language. 330 $languages = signup_get_available_languages(); 331 332 if ( ! empty( $languages ) ) : 333 ?> 334 <p> 335 <label for="site-language"><?php _e( 'Site Language:' ); ?></label> 336 <?php 337 // Network default. 338 $lang = get_site_option( 'WPLANG' ); 339 340 if ( isset( $_POST['WPLANG'] ) ) { 341 $lang = $_POST['WPLANG']; 342 } 343 344 // Use US English if the default isn't available. 345 if ( ! in_array( $lang, $languages ) ) { 346 $lang = ''; 347 } 348 349 wp_dropdown_languages( array( 350 'name' => 'WPLANG', 351 'id' => 'site-language', 352 'selected' => $lang, 353 'languages' => $languages, 354 'show_available_translations' => false, 355 ) ); 356 ?> 357 </p> 358 <?php endif; // Languages. ?> 359 360 <div id="privacy"> 361 <p class="privacy-intro"> 362 <label for="blog_public_on"><?php _e('Privacy:') ?></label> 363 <?php _e( 'Allow search engines to index this site.' ); ?> 364 <br style="clear:both" /> 365 <label class="checkbox" for="blog_public_on"> 366 <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> /> 367 <strong><?php _e( 'Yes' ); ?></strong> 368 </label> 369 <label class="checkbox" for="blog_public_off"> 370 <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> /> 371 <strong><?php _e( 'No' ); ?></strong> 372 </label> 373 </p> 374 </div> 375 376 <?php 377 /** 378 * Fires after the site sign-up form. 379 * 380 * @since 3.0.0 381 * 382 * @param WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. 383 */ 384 do_action( 'signup_blogform', $errors ); 385 } 386 387 /** 388 * Display user registration form 389 * 390 * @since MU 391 * 392 * @param string $user_name The entered username. 393 * @param string $user_email The entered email address. 394 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 395 */ 396 function show_user_form($user_name = '', $user_email = '', $errors = '') { 397 if ( ! is_wp_error( $errors ) ) { 398 $errors = new WP_Error(); 399 } 400 401 // User name 402 echo '<label for="user_name">' . __('Username:') . '</label>'; 403 if ( $errmsg = $errors->get_error_message('user_name') ) { 404 echo '<p class="error">'.$errmsg.'</p>'; 405 } 406 echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr( $user_name ) .'" autocapitalize="none" autocorrect="off" maxlength="60" /><br />'; 407 _e( '(Must be at least 4 characters, letters and numbers only.)' ); 408 ?> 409 410 <label for="user_email"><?php _e( 'Email Address:' ) ?></label> 411 <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?> 412 <p class="error"><?php echo $errmsg ?></p> 413 <?php } ?> 414 <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.)') ?> 415 <?php 416 if ( $errmsg = $errors->get_error_message('generic') ) { 417 echo '<p class="error">' . $errmsg . '</p>'; 418 } 419 /** 420 * Fires at the end of the user registration form on the site sign-up form. 421 * 422 * @since 3.0.0 423 * 424 * @param WP_Error $errors A WP_Error object containing containing 'user_name' or 'user_email' errors. 425 */ 426 do_action( 'signup_extra_fields', $errors ); 427 } 428 429 /** 430 * Setup the new user signup process 431 * 432 * @since MU 433 * 434 * @param string $user_name The username. 435 * @param string $user_email The user's email. 436 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 437 */ 438 function signup_user( $user_name = '', $user_email = '', $errors = '' ) { 439 global $active_signup; 440 441 if ( !is_wp_error($errors) ) 442 $errors = new WP_Error(); 443 444 $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog'; 445 446 $signup_user_defaults = array( 447 'user_name' => $user_name, 448 'user_email' => $user_email, 449 'errors' => $errors, 450 ); 451 452 /** 453 * Filters the default user variables used on the user sign-up form. 454 * 455 * @since 3.0.0 456 * 457 * @param array $signup_user_defaults { 458 * An array of default user variables. 459 * 460 * @type string $user_name The user username. 461 * @type string $user_email The user email address. 462 * @type WP_Error $errors A WP_Error object with possible errors relevant to the sign-up user. 463 * } 464 */ 465 $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); 466 $user_name = $filtered_results['user_name']; 467 $user_email = $filtered_results['user_email']; 468 $errors = $filtered_results['errors']; 469 470 ?> 471 472 <h2><?php 473 /* translators: %s: name of the network */ 474 printf( __( 'Get your own %s account in seconds' ), get_network()->site_name ); 475 ?></h2> 476 <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> 477 <input type="hidden" name="stage" value="validate-user-signup" /> 478 <?php 479 /** This action is documented in wp-signup.php */ 480 do_action( 'signup_hidden_fields', 'validate-user' ); 481 ?> 482 <?php show_user_form($user_name, $user_email, $errors); ?> 483 484 <p> 485 <?php if ( $active_signup == 'blog' ) { ?> 486 <input id="signupblog" type="hidden" name="signup_for" value="blog" /> 487 <?php } elseif ( $active_signup == 'user' ) { ?> 488 <input id="signupblog" type="hidden" name="signup_for" value="user" /> 489 <?php } else { ?> 490 <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> 491 <label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label> 492 <br /> 493 <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> 494 <label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label> 495 <?php } ?> 496 </p> 497 498 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p> 499 </form> 500 <?php 501 } 502 503 /** 504 * New user signup confirmation 505 * 506 * @since MU 507 * 508 * @param string $user_name The username 509 * @param string $user_email The user's email address 510 */ 511 function confirm_user_signup($user_name, $user_email) { 512 ?> 513 <h2><?php /* translators: %s: username */ 514 printf( __( '%s is your new username' ), $user_name) ?></h2> 515 <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p> 516 <p><?php /* translators: %s: email address */ 517 printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p> 518 <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p> 519 <?php 520 /** This action is documented in wp-signup.php */ 521 do_action( 'signup_finished' ); 522 } 523 524 /** 525 * Setup the new site signup 526 * 527 * @since MU 528 * 529 * @param string $user_name The username. 530 * @param string $user_email The user's email address. 531 * @param string $blogname The site name. 532 * @param string $blog_title The site title. 533 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 534 */ 535 function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') { 536 if ( !is_wp_error($errors) ) 537 $errors = new WP_Error(); 538 539 $signup_blog_defaults = array( 540 'user_name' => $user_name, 541 'user_email' => $user_email, 542 'blogname' => $blogname, 543 'blog_title' => $blog_title, 544 'errors' => $errors 545 ); 546 547 /** 548 * Filters the default site creation variables for the site sign-up form. 549 * 550 * @since 3.0.0 551 * 552 * @param array $signup_blog_defaults { 553 * An array of default site creation variables. 554 * 555 * @type string $user_name The user username. 556 * @type string $user_email The user email address. 557 * @type string $blogname The blogname. 558 * @type string $blog_title The title of the site. 559 * @type WP_Error $errors A WP_Error object with possible errors relevant to new site creation variables. 560 * } 561 */ 562 $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults ); 563 564 $user_name = $filtered_results['user_name']; 565 $user_email = $filtered_results['user_email']; 566 $blogname = $filtered_results['blogname']; 567 $blog_title = $filtered_results['blog_title']; 568 $errors = $filtered_results['errors']; 569 570 if ( empty($blogname) ) 571 $blogname = $user_name; 572 ?> 573 <form id="setupform" method="post" action="wp-signup.php"> 574 <input type="hidden" name="stage" value="validate-blog-signup" /> 575 <input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" /> 576 <input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" /> 577 <?php 578 /** This action is documented in wp-signup.php */ 579 do_action( 'signup_hidden_fields', 'validate-site' ); 580 ?> 581 <?php show_blog_form($blogname, $blog_title, $errors); ?> 582 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p> 583 </form> 584 <?php 585 } 586 587 /** 588 * New site signup confirmation 589 * 590 * @since MU 591 * 592 * @param string $domain The domain URL 593 * @param string $path The site root path 594 * @param string $blog_title The new site title 595 * @param string $user_name The user's username 596 * @param string $user_email The user's email address 597 * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup() 598 */ 599 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) { 600 ?> 601 <h2><?php /* translators: %s: site address */ 602 printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2> 603 604 <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p> 605 <p><?php /* translators: %s: email address */ 606 printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p> 607 <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p> 608 <h2><?php _e( 'Still waiting for your email?' ); ?></h2> 609 <p> 610 <?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ) ?> 611 <ul id="noemail-tips"> 612 <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> 613 <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li> 614 <li><?php 615 /* translators: %s: email address */ 616 printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email ); 617 ?></li> 618 </ul> 619 </p> 620 <?php 621 /** This action is documented in wp-signup.php */ 622 do_action( 'signup_finished' ); 623 } 624 625 /** 626 * Allow returning users to sign up for another site 627 * 628 * @since MU 629 * 630 * @param string $blogname The new site name 631 * @param string $blog_title The new site title. 632 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 633 */ 634 function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { 635 $current_user = wp_get_current_user(); 636 637 if ( ! is_wp_error($errors) ) { 638 $errors = new WP_Error(); 639 } 640 641 $signup_defaults = array( 642 'blogname' => $blogname, 643 'blog_title' => $blog_title, 644 'errors' => $errors 645 ); 646 647 /** 648 * Filters the default site sign-up variables. 649 * 650 * @since 3.0.0 651 * 652 * @param array $signup_defaults { 653 * An array of default site sign-up variables. 654 * 655 * @type string $blogname The site blogname. 656 * @type string $blog_title The site title. 657 * @type WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. 658 * } 659 */ 660 $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); 661 662 $blogname = $filtered_results['blogname']; 663 $blog_title = $filtered_results['blog_title']; 664 $errors = $filtered_results['errors']; 665 666 echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>'; 667 668 if ( $errors->get_error_code() ) { 669 echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; 670 } 671 ?> 672 <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> 673 674 <?php 675 $blogs = get_blogs_of_user($current_user->ID); 676 if ( !empty($blogs) ) { ?> 677 678 <p><?php _e( 'Sites you are already a member of:' ) ?></p> 679 <ul> 680 <?php foreach ( $blogs as $blog ) { 681 $home_url = get_home_url( $blog->userblog_id ); 682 echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; 683 } ?> 684 </ul> 685 <?php } ?> 686 687 <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> 688 <form id="setupform" method="post" action="wp-signup.php"> 689 <input type="hidden" name="stage" value="gimmeanotherblog" /> 690 <?php 691 /** 692 * Hidden sign-up form fields output when creating another site or user. 693 * 694 * @since MU 695 * 696 * @param string $context A string describing the steps of the sign-up process. The value can be 697 * 'create-another-site', 'validate-user', or 'validate-site'. 698 */ 699 do_action( 'signup_hidden_fields', 'create-another-site' ); 700 ?> 701 <?php show_blog_form($blogname, $blog_title, $errors); ?> 702 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p> 703 </form> 704 <?php 705 } 706 707 /** 708 * Confirm a new site signup. 709 * 710 * @since MU 711 * @since 4.4.0 Added the `$blog_id` parameter. 712 * 713 * @param string $domain The domain URL. 714 * @param string $path The site root path. 715 * @param string $blog_title The site title. 716 * @param string $user_name The username. 717 * @param string $user_email The user's email address. 718 * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup(). 719 * @param int $blog_id The site ID. 720 */ 721 function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) { 722 723 if ( $blog_id ) { 724 switch_to_blog( $blog_id ); 725 $home_url = home_url( '/' ); 726 $login_url = wp_login_url(); 727 restore_current_blog(); 728 } else { 729 $home_url = 'http://' . $domain . $path; 730 $login_url = 'http://' . $domain . $path . 'wp-login.php'; 731 } 732 733 $site = sprintf( '<a href="%1$s">%2$s</a>', 734 esc_url( $home_url ), 735 $blog_title 736 ); 737 738 ?> 739 <h2><?php 740 /* translators: %s: site name */ 741 printf( __( 'The site %s is yours.' ), $site ); 742 ?></h2> 743 <p> 744 <?php printf( 745 /* translators: 1: home URL, 2: site address, 3: login URL, 4: username */ 746 __( '<a href="%1$s">%2$s</a> is your new site. <a href="%3$s">Log in</a> as “%4$s” using your existing password.' ), 747 esc_url( $home_url ), 748 untrailingslashit( $domain . $path ), 749 esc_url( $login_url ), 750 $user_name 751 ); ?> 752 </p> 753 <?php 754 /** 755 * Fires when the site or user sign-up process is complete. 756 * 757 * @since 3.0.0 758 */ 759 do_action( 'signup_finished' ); 760 } 761 762 /** 763 * Displays the activate form. 764 * 765 * @since ? 766 */ 767 function activate_user_form() { 768 ?> 769 <h2><?php esc_html_e('Activation Key Required') ?></h2> 770 <form name="activateform" id="activateform" method="post" action="<?php echo esc_url( network_site_url( 'wp-activate.php' ) ); ?>"> 771 <p> 772 <label for="key"><?php esc_html_e( 'Activation Key:' ) ?></label> 773 <br /><input type="text" name="key" id="key" value="" size="50" /> 774 </p> 775 <p class="submit"> 776 <input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e( 'Activate' ) ?>" /> 777 </p> 778 </form> 779 780 <script type="text/javascript"> 781 var key_input = document.getElementById('key'); 782 key_input && key_input.focus(); 783 </script> 784 <?php 785 } 786 787 /** 788 * Displays the activation result. 789 * 790 * @since ? 791 * 792 * @return bool|string False if the signup key is not set. 793 * The HTML output of the activation's result otherwise. 794 */ 795 function activate_user() { 796 global $signup_action; 797 798 if ( ! isset( $signup_action['key'] ) ) { 799 return false; 800 } 801 802 // Activate the signup. 803 $result = wpmu_activate_signup( $signup_action['key'] ); 804 805 if ( is_wp_error( $result ) ) { 806 if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) { 807 $signup = $result->get_error_data(); 808 ?> 809 <h2><?php esc_html_e( 'Your account is now active!' ); ?></h2> 810 <?php 811 echo '<p class="lead-in">'; 812 if ( $signup->domain . $signup->path == '' ) { 813 printf( 814 /* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */ 815 __( 'Your account has been activated. You may now <a href="%1$s">log in</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>.' ), 816 network_site_url( 'wp-login.php', 'login' ), 817 $signup->user_login, 818 $signup->user_email, 819 wp_lostpassword_url() 820 ); 821 } else { 822 printf( 823 /* translators: 1: site URL, 2: site domain, 3: username, 4: user email, 5: lost password URL */ 824 __( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in 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>.' ), 825 'http://' . $signup->domain, 826 $signup->domain, 827 $signup->user_login, 828 $signup->user_email, 829 wp_lostpassword_url() 830 ); 831 } 832 echo '</p>'; 833 } else { 834 ?> 835 <h2><?php esc_html_e( 'An error occurred during the activation' ); ?></h2> 836 <p><?php echo $result->get_error_message(); ?></p> 837 <?php 838 } 839 } else { 840 $url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : ''; 841 $user = get_userdata( (int) $result['user_id'] ); 842 ?> 843 <h2><?php esc_html_e( 'Your account is now active!' ); ?></h2> 844 845 <div id="signup-welcome"> 846 <p><span class="h3"><?php esc_html_e( 'Username:' ); ?></span> <?php echo esc_html( $user->user_login ); ?></p> 847 <p><span class="h3"><?php esc_html_e( 'Password:' ); ?></span> <?php echo esc_html( $result['password'] ); ?></p> 848 </div> 849 850 <?php if ( $url && $url != network_home_url( '', 'http' ) ) : 851 switch_to_blog( (int) $result['blog_id'] ); 852 $login_url = wp_login_url(); 853 restore_current_blog(); 854 ?> 855 <p class="view"><?php 856 /* translators: 1: site URL, 2: login URL */ 857 printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) ); 858 ?></p> 859 <?php else: ?> 860 <p class="view"><?php 861 /* translators: 1: login URL, 2: network home URL */ 862 printf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() ); 863 ?></p> 864 <?php endif; 865 } 866 } -
src/wp-includes/theme-compat/signup.php
diff --git src/wp-includes/theme-compat/signup.php src/wp-includes/theme-compat/signup.php index e69de29..c55ae98 100644
1 <?php 2 /** 3 * Contains the Multisite signup base template 4 * 5 * When user accounts/sites registration is open, this file is used to create the output 6 * if the active theme does not include an signup.php template. 7 * 8 * @package WordPress 9 * @subpackage Multisite 10 */ 11 ?> 12 13 <div id="signup-content" class="widecolumn"> 14 <div class="<?php signup_classes(); ?>"> 15 16 <?php do_signup_admin_notice() ; 17 18 if ( signup_has_errors() ) : 19 20 print_signup_errors(); 21 22 else : 23 24 do_signup_form(); 25 26 endif ; 27 28 do_signup_user_notice(); ?> 29 30 </div> 31 </div> -
src/wp-settings.php
diff --git src/wp-settings.php src/wp-settings.php index 8dd0f40..25bdd33 100644
$GLOBALS['wp_embed'] = new WP_Embed(); 246 246 // Load multisite-specific files. 247 247 if ( is_multisite() ) { 248 248 require( ABSPATH . WPINC . '/ms-functions.php' ); 249 require( ABSPATH . WPINC . '/ms-template.php' ); 249 250 require( ABSPATH . WPINC . '/ms-default-filters.php' ); 250 251 require( ABSPATH . WPINC . '/ms-deprecated.php' ); 251 252 } -
src/wp-signup.php
diff --git src/wp-signup.php src/wp-signup.php index 156de61..fb703c4 100644
3 3 /** Sets up the WordPress Environment. */ 4 4 require( dirname(__FILE__) . '/wp-load.php' ); 5 5 6 add_action( 'wp_head', 'wp_no_robots' );7 8 6 require( dirname( __FILE__ ) . '/wp-blog-header.php' ); 9 7 10 8 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' ] ) && 12 10 die(); 13 11 } 14 12 15 /** 16 * Prints signup_header via wp_head 17 * 18 * @since MU 19 */ 20 function do_signup_header() { 21 /** 22 * Fires within the head section of the site sign-up screen. 23 * 24 * @since 3.0.0 25 */ 26 do_action( 'signup_header' ); 27 } 28 add_action( 'wp_head', 'do_signup_header' ); 29 30 if ( !is_multisite() ) { 13 if ( ! is_multisite() ) { 31 14 wp_redirect( wp_registration_url() ); 32 15 die(); 33 16 } 34 17 35 if ( ! is_main_site() ) {18 if ( ! is_main_site() ) { 36 19 wp_redirect( network_site_url( 'wp-signup.php' ) ); 37 20 die(); 38 21 } … … if ( !is_main_site() ) { 41 24 $wp_query->is_404 = false; 42 25 43 26 /** 44 * Fires before the Site Signup page is loaded. 45 * 46 * @since 4.4.0 47 */ 48 do_action( 'before_signup_header' ); 49 50 /** 51 * Prints styles for front-end Multisite signup pages 52 * 53 * @since MU 54 */ 55 function wpmu_signup_stylesheet() { 56 ?> 57 <style type="text/css"> 58 .mu_register { width: 90%; margin:0 auto; } 59 .mu_register form { margin-top: 2em; } 60 .mu_register .error { font-weight:700; padding:10px; color:#333333; background:#FFEBE8; border:1px solid #CC0000; } 61 .mu_register input[type="submit"], 62 .mu_register #blog_title, 63 .mu_register #user_email, 64 .mu_register #blogname, 65 .mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; } 66 .mu_register #site-language { display: block; } 67 .mu_register .prefix_address, 68 .mu_register .suffix_address {font-size: 18px;display:inline; } 69 .mu_register label { font-weight:700; font-size:15px; display:block; margin:10px 0; } 70 .mu_register label.checkbox { display:inline; } 71 .mu_register .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; } 72 </style> 73 <?php 74 } 75 76 add_action( 'wp_head', 'wpmu_signup_stylesheet' ); 77 get_header( 'wp-signup' ); 78 79 /** 80 * Fires before the site sign-up form. 27 * Filters the type of site sign-up. 81 28 * 82 29 * @since 3.0.0 83 */84 do_action( 'before_signup_form' );85 ?>86 <div id="signup-content" class="widecolumn">87 <div class="mu_register wp-signup-container">88 <?php89 /**90 * Generates and displays the Signup and Create Site forms91 *92 * @since MU93 *94 * @param string $blogname The new site name.95 * @param string $blog_title The new site title.96 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string.97 */98 function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {99 if ( ! is_wp_error( $errors ) ) {100 $errors = new WP_Error();101 }102 103 $current_network = get_network();104 // Blog name105 if ( !is_subdomain_install() )106 echo '<label for="blogname">' . __('Site Name:') . '</label>';107 else108 echo '<label for="blogname">' . __('Site Domain:') . '</label>';109 110 if ( $errmsg = $errors->get_error_message('blogname') ) { ?>111 <p class="error"><?php echo $errmsg ?></p>112 <?php }113 114 if ( !is_subdomain_install() )115 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 />';116 else117 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 />';118 119 if ( ! is_user_logged_in() ) {120 if ( ! is_subdomain_install() ) {121 $site = $current_network->domain . $current_network->path . __( 'sitename' );122 } else {123 $site = __( 'domain' ) . '.' . $site_domain . $current_network->path;124 }125 126 /* translators: %s: site address */127 echo '<p>(<strong>' . sprintf( __( 'Your address will be %s.' ), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';128 }129 130 // Blog Title131 ?>132 <label for="blog_title"><?php _e('Site Title:') ?></label>133 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>134 <p class="error"><?php echo $errmsg ?></p>135 <?php }136 echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';137 ?>138 139 <?php140 // Site Language.141 $languages = signup_get_available_languages();142 143 if ( ! empty( $languages ) ) :144 ?>145 <p>146 <label for="site-language"><?php _e( 'Site Language:' ); ?></label>147 <?php148 // Network default.149 $lang = get_site_option( 'WPLANG' );150 151 if ( isset( $_POST['WPLANG'] ) ) {152 $lang = $_POST['WPLANG'];153 }154 155 // Use US English if the default isn't available.156 if ( ! in_array( $lang, $languages ) ) {157 $lang = '';158 }159 160 wp_dropdown_languages( array(161 'name' => 'WPLANG',162 'id' => 'site-language',163 'selected' => $lang,164 'languages' => $languages,165 'show_available_translations' => false,166 ) );167 ?>168 </p>169 <?php endif; // Languages. ?>170 171 <div id="privacy">172 <p class="privacy-intro">173 <label for="blog_public_on"><?php _e('Privacy:') ?></label>174 <?php _e( 'Allow search engines to index this site.' ); ?>175 <br style="clear:both" />176 <label class="checkbox" for="blog_public_on">177 <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />178 <strong><?php _e( 'Yes' ); ?></strong>179 </label>180 <label class="checkbox" for="blog_public_off">181 <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />182 <strong><?php _e( 'No' ); ?></strong>183 </label>184 </p>185 </div>186 187 <?php188 /**189 * Fires after the site sign-up form.190 *191 * @since 3.0.0192 *193 * @param WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors.194 */195 do_action( 'signup_blogform', $errors );196 }197 198 /**199 * Validate the new site signup200 *201 * @since MU202 30 * 203 * @return array Contains the new site data and error messages. 204 */ 205 function validate_blog_form() { 206 $user = ''; 207 if ( is_user_logged_in() ) 208 $user = wp_get_current_user(); 209 210 return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user); 211 } 212 213 /** 214 * Display user registration form 215 * 216 * @since MU 217 * 218 * @param string $user_name The entered username. 219 * @param string $user_email The entered email address. 220 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 221 */ 222 function show_user_form($user_name = '', $user_email = '', $errors = '') { 223 if ( ! is_wp_error( $errors ) ) { 224 $errors = new WP_Error(); 225 } 226 227 // User name 228 echo '<label for="user_name">' . __('Username:') . '</label>'; 229 if ( $errmsg = $errors->get_error_message('user_name') ) { 230 echo '<p class="error">'.$errmsg.'</p>'; 231 } 232 echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr( $user_name ) .'" autocapitalize="none" autocorrect="off" maxlength="60" /><br />'; 233 _e( '(Must be at least 4 characters, letters and numbers only.)' ); 234 ?> 235 236 <label for="user_email"><?php _e( 'Email Address:' ) ?></label> 237 <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?> 238 <p class="error"><?php echo $errmsg ?></p> 239 <?php } ?> 240 <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.)') ?> 241 <?php 242 if ( $errmsg = $errors->get_error_message('generic') ) { 243 echo '<p class="error">' . $errmsg . '</p>'; 244 } 245 /** 246 * Fires at the end of the user registration form on the site sign-up form. 247 * 248 * @since 3.0.0 249 * 250 * @param WP_Error $errors A WP_Error object containing containing 'user_name' or 'user_email' errors. 251 */ 252 do_action( 'signup_extra_fields', $errors ); 253 } 254 255 /** 256 * Validate user signup name and email 257 * 258 * @since MU 259 * 260 * @return array Contains username, email, and error messages. 261 */ 262 function validate_user_form() { 263 return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); 264 } 265 266 /** 267 * Allow returning users to sign up for another site 268 * 269 * @since MU 270 * 271 * @param string $blogname The new site name 272 * @param string $blog_title The new site title. 273 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 274 */ 275 function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { 276 $current_user = wp_get_current_user(); 277 278 if ( ! is_wp_error($errors) ) { 279 $errors = new WP_Error(); 280 } 281 282 $signup_defaults = array( 283 'blogname' => $blogname, 284 'blog_title' => $blog_title, 285 'errors' => $errors 286 ); 287 288 /** 289 * Filters the default site sign-up variables. 290 * 291 * @since 3.0.0 292 * 293 * @param array $signup_defaults { 294 * An array of default site sign-up variables. 295 * 296 * @type string $blogname The site blogname. 297 * @type string $blog_title The site title. 298 * @type WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. 299 * } 300 */ 301 $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); 302 303 $blogname = $filtered_results['blogname']; 304 $blog_title = $filtered_results['blog_title']; 305 $errors = $filtered_results['errors']; 306 307 echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>'; 308 309 if ( $errors->get_error_code() ) { 310 echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; 311 } 312 ?> 313 <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> 314 315 <?php 316 $blogs = get_blogs_of_user($current_user->ID); 317 if ( !empty($blogs) ) { ?> 318 319 <p><?php _e( 'Sites you are already a member of:' ) ?></p> 320 <ul> 321 <?php foreach ( $blogs as $blog ) { 322 $home_url = get_home_url( $blog->userblog_id ); 323 echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; 324 } ?> 325 </ul> 326 <?php } ?> 327 328 <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> 329 <form id="setupform" method="post" action="wp-signup.php"> 330 <input type="hidden" name="stage" value="gimmeanotherblog" /> 331 <?php 332 /** 333 * Hidden sign-up form fields output when creating another site or user. 334 * 335 * @since MU 336 * 337 * @param string $context A string describing the steps of the sign-up process. The value can be 338 * 'create-another-site', 'validate-user', or 'validate-site'. 339 */ 340 do_action( 'signup_hidden_fields', 'create-another-site' ); 341 ?> 342 <?php show_blog_form($blogname, $blog_title, $errors); ?> 343 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p> 344 </form> 345 <?php 346 } 347 348 /** 349 * Validate a new site signup. 350 * 351 * @since MU 352 * 353 * @return null|bool True if site signup was validated, false if error. 354 * The function halts all execution if the user is not logged in. 355 */ 356 function validate_another_blog_signup() { 357 global $wpdb, $blogname, $blog_title, $errors, $domain, $path; 358 $current_user = wp_get_current_user(); 359 if ( ! is_user_logged_in() ) { 360 die(); 361 } 362 363 $result = validate_blog_form(); 364 365 // Extracted values set/overwrite globals. 366 $domain = $result['domain']; 367 $path = $result['path']; 368 $blogname = $result['blogname']; 369 $blog_title = $result['blog_title']; 370 $errors = $result['errors']; 371 372 if ( $errors->get_error_code() ) { 373 signup_another_blog($blogname, $blog_title, $errors); 374 return false; 375 } 376 377 $public = (int) $_POST['blog_public']; 378 379 $blog_meta_defaults = array( 380 'lang_id' => 1, 381 'public' => $public 382 ); 383 384 // Handle the language setting for the new site. 385 if ( ! empty( $_POST['WPLANG'] ) ) { 386 387 $languages = signup_get_available_languages(); 388 389 if ( in_array( $_POST['WPLANG'], $languages ) ) { 390 $language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); 391 392 if ( $language ) { 393 $blog_meta_defaults['WPLANG'] = $language; 394 } 395 } 396 397 } 398 399 /** 400 * Filters the new site meta variables. 401 * 402 * Use the {@see 'add_signup_meta'} filter instead. 403 * 404 * @since MU 405 * @deprecated 3.0.0 Use the {@see 'add_signup_meta'} filter instead. 406 * 407 * @param array $blog_meta_defaults An array of default blog meta variables. 408 */ 409 $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults ); 410 411 /** 412 * Filters the new default site meta variables. 413 * 414 * @since 3.0.0 415 * 416 * @param array $meta { 417 * An array of default site meta variables. 418 * 419 * @type int $lang_id The language ID. 420 * @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false. 421 * } 422 */ 423 $meta = apply_filters( 'add_signup_meta', $meta_defaults ); 424 425 $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid ); 426 427 if ( is_wp_error( $blog_id ) ) { 428 return false; 429 } 430 431 confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id ); 432 return true; 433 } 434 435 /** 436 * Confirm a new site signup. 437 * 438 * @since MU 439 * @since 4.4.0 Added the `$blog_id` parameter. 440 * 441 * @param string $domain The domain URL. 442 * @param string $path The site root path. 443 * @param string $blog_title The site title. 444 * @param string $user_name The username. 445 * @param string $user_email The user's email address. 446 * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup(). 447 * @param int $blog_id The site ID. 448 */ 449 function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) { 450 451 if ( $blog_id ) { 452 switch_to_blog( $blog_id ); 453 $home_url = home_url( '/' ); 454 $login_url = wp_login_url(); 455 restore_current_blog(); 456 } else { 457 $home_url = 'http://' . $domain . $path; 458 $login_url = 'http://' . $domain . $path . 'wp-login.php'; 459 } 460 461 $site = sprintf( '<a href="%1$s">%2$s</a>', 462 esc_url( $home_url ), 463 $blog_title 464 ); 465 466 ?> 467 <h2><?php 468 /* translators: %s: site name */ 469 printf( __( 'The site %s is yours.' ), $site ); 470 ?></h2> 471 <p> 472 <?php printf( 473 /* translators: 1: home URL, 2: site address, 3: login URL, 4: username */ 474 __( '<a href="%1$s">%2$s</a> is your new site. <a href="%3$s">Log in</a> as “%4$s” using your existing password.' ), 475 esc_url( $home_url ), 476 untrailingslashit( $domain . $path ), 477 esc_url( $login_url ), 478 $user_name 479 ); ?> 480 </p> 481 <?php 482 /** 483 * Fires when the site or user sign-up process is complete. 484 * 485 * @since 3.0.0 486 */ 487 do_action( 'signup_finished' ); 488 } 489 490 /** 491 * Setup the new user signup process 492 * 493 * @since MU 494 * 495 * @param string $user_name The username. 496 * @param string $user_email The user's email. 497 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 498 */ 499 function signup_user( $user_name = '', $user_email = '', $errors = '' ) { 500 global $active_signup; 501 502 if ( !is_wp_error($errors) ) 503 $errors = new WP_Error(); 504 505 $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog'; 506 507 $signup_user_defaults = array( 508 'user_name' => $user_name, 509 'user_email' => $user_email, 510 'errors' => $errors, 511 ); 512 513 /** 514 * Filters the default user variables used on the user sign-up form. 515 * 516 * @since 3.0.0 517 * 518 * @param array $signup_user_defaults { 519 * An array of default user variables. 520 * 521 * @type string $user_name The user username. 522 * @type string $user_email The user email address. 523 * @type WP_Error $errors A WP_Error object with possible errors relevant to the sign-up user. 524 * } 525 */ 526 $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); 527 $user_name = $filtered_results['user_name']; 528 $user_email = $filtered_results['user_email']; 529 $errors = $filtered_results['errors']; 530 531 ?> 532 533 <h2><?php 534 /* translators: %s: name of the network */ 535 printf( __( 'Get your own %s account in seconds' ), get_network()->site_name ); 536 ?></h2> 537 <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> 538 <input type="hidden" name="stage" value="validate-user-signup" /> 539 <?php 540 /** This action is documented in wp-signup.php */ 541 do_action( 'signup_hidden_fields', 'validate-user' ); 542 ?> 543 <?php show_user_form($user_name, $user_email, $errors); ?> 544 545 <p> 546 <?php if ( $active_signup == 'blog' ) { ?> 547 <input id="signupblog" type="hidden" name="signup_for" value="blog" /> 548 <?php } elseif ( $active_signup == 'user' ) { ?> 549 <input id="signupblog" type="hidden" name="signup_for" value="user" /> 550 <?php } else { ?> 551 <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> 552 <label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label> 553 <br /> 554 <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> 555 <label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label> 556 <?php } ?> 557 </p> 558 559 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p> 560 </form> 561 <?php 562 } 563 564 /** 565 * Validate the new user signup 566 * 567 * @since MU 568 * 569 * @return bool True if new user signup was validated, false if error 570 */ 571 function validate_user_signup() { 572 $result = validate_user_form(); 573 $user_name = $result['user_name']; 574 $user_email = $result['user_email']; 575 $errors = $result['errors']; 576 577 if ( $errors->get_error_code() ) { 578 signup_user($user_name, $user_email, $errors); 579 return false; 580 } 581 582 if ( 'blog' == $_POST['signup_for'] ) { 583 signup_blog($user_name, $user_email); 584 return false; 585 } 586 587 /** This filter is documented in wp-signup.php */ 588 wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) ); 589 590 confirm_user_signup($user_name, $user_email); 591 return true; 592 } 593 594 /** 595 * New user signup confirmation 596 * 597 * @since MU 598 * 599 * @param string $user_name The username 600 * @param string $user_email The user's email address 601 */ 602 function confirm_user_signup($user_name, $user_email) { 603 ?> 604 <h2><?php /* translators: %s: username */ 605 printf( __( '%s is your new username' ), $user_name) ?></h2> 606 <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p> 607 <p><?php /* translators: %s: email address */ 608 printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p> 609 <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p> 610 <?php 611 /** This action is documented in wp-signup.php */ 612 do_action( 'signup_finished' ); 613 } 614 615 /** 616 * Setup the new site signup 617 * 618 * @since MU 619 * 620 * @param string $user_name The username. 621 * @param string $user_email The user's email address. 622 * @param string $blogname The site name. 623 * @param string $blog_title The site title. 624 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 625 */ 626 function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') { 627 if ( !is_wp_error($errors) ) 628 $errors = new WP_Error(); 629 630 $signup_blog_defaults = array( 631 'user_name' => $user_name, 632 'user_email' => $user_email, 633 'blogname' => $blogname, 634 'blog_title' => $blog_title, 635 'errors' => $errors 636 ); 637 638 /** 639 * Filters the default site creation variables for the site sign-up form. 640 * 641 * @since 3.0.0 642 * 643 * @param array $signup_blog_defaults { 644 * An array of default site creation variables. 645 * 646 * @type string $user_name The user username. 647 * @type string $user_email The user email address. 648 * @type string $blogname The blogname. 649 * @type string $blog_title The title of the site. 650 * @type WP_Error $errors A WP_Error object with possible errors relevant to new site creation variables. 651 * } 652 */ 653 $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults ); 654 655 $user_name = $filtered_results['user_name']; 656 $user_email = $filtered_results['user_email']; 657 $blogname = $filtered_results['blogname']; 658 $blog_title = $filtered_results['blog_title']; 659 $errors = $filtered_results['errors']; 660 661 if ( empty($blogname) ) 662 $blogname = $user_name; 663 ?> 664 <form id="setupform" method="post" action="wp-signup.php"> 665 <input type="hidden" name="stage" value="validate-blog-signup" /> 666 <input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" /> 667 <input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" /> 668 <?php 669 /** This action is documented in wp-signup.php */ 670 do_action( 'signup_hidden_fields', 'validate-site' ); 671 ?> 672 <?php show_blog_form($blogname, $blog_title, $errors); ?> 673 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p> 674 </form> 675 <?php 676 } 677 678 /** 679 * Validate new site signup 680 * 681 * @since MU 682 * 683 * @return bool True if the site signup was validated, false if error 684 */ 685 function validate_blog_signup() { 686 // Re-validate user info. 687 $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); 688 $user_name = $user_result['user_name']; 689 $user_email = $user_result['user_email']; 690 $user_errors = $user_result['errors']; 691 692 if ( $user_errors->get_error_code() ) { 693 signup_user( $user_name, $user_email, $user_errors ); 694 return false; 695 } 696 697 $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] ); 698 $domain = $result['domain']; 699 $path = $result['path']; 700 $blogname = $result['blogname']; 701 $blog_title = $result['blog_title']; 702 $errors = $result['errors']; 703 704 if ( $errors->get_error_code() ) { 705 signup_blog($user_name, $user_email, $blogname, $blog_title, $errors); 706 return false; 707 } 708 709 $public = (int) $_POST['blog_public']; 710 $signup_meta = array ('lang_id' => 1, 'public' => $public); 711 712 // Handle the language setting for the new site. 713 if ( ! empty( $_POST['WPLANG'] ) ) { 714 715 $languages = signup_get_available_languages(); 716 717 if ( in_array( $_POST['WPLANG'], $languages ) ) { 718 $language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); 719 720 if ( $language ) { 721 $signup_meta['WPLANG'] = $language; 722 } 723 } 724 725 } 726 727 /** This filter is documented in wp-signup.php */ 728 $meta = apply_filters( 'add_signup_meta', $signup_meta ); 729 730 wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta); 731 confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta); 732 return true; 733 } 734 735 /** 736 * New site signup confirmation 737 * 738 * @since MU 739 * 740 * @param string $domain The domain URL 741 * @param string $path The site root path 742 * @param string $blog_title The new site title 743 * @param string $user_name The user's username 744 * @param string $user_email The user's email address 745 * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup() 31 * @param string $active_signup String that returns registration type. The value can be 32 * 'all', 'none', 'blog', or 'user'. 746 33 */ 747 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) { 748 ?> 749 <h2><?php /* translators: %s: site address */ 750 printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2> 34 $active_signup = apply_filters( 'wpmu_active_signup', get_site_option( 'registration', 'none' ) ); 751 35 752 <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p> 753 <p><?php /* translators: %s: email address */ 754 printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p> 755 <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p> 756 <h2><?php _e( 'Still waiting for your email?' ); ?></h2> 757 <p> 758 <?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ) ?> 759 <ul id="noemail-tips"> 760 <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> 761 <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li> 762 <li><?php 763 /* translators: %s: email address */ 764 printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email ); 765 ?></li> 766 </ul> 767 </p> 768 <?php 769 /** This action is documented in wp-signup.php */ 770 do_action( 'signup_finished' ); 771 } 36 // Handle signup stage 37 signup_handle_stage(); 772 38 773 39 /** 774 * Retrieves languages available during the site/user signup process.40 * Fires before the Site Signup page is loaded. 775 41 * 776 42 * @since 4.4.0 777 *778 * @see get_available_languages()779 *780 * @return array List of available languages.781 43 */ 782 function signup_get_available_languages() { 783 /** 784 * Filters the list of available languages for front-end site signups. 785 * 786 * Passing an empty array to this hook will disable output of the setting on the 787 * signup form, and the default language will be used when creating the site. 788 * 789 * Languages not already installed will be stripped. 790 * 791 * @since 4.4.0 792 * 793 * @param array $available_languages Available languages. 794 */ 795 $languages = (array) apply_filters( 'signup_get_available_languages', get_available_languages() ); 44 do_action( 'before_signup_header' ); 796 45 797 /* 798 * Strip any non-installed languages and return. 799 * 800 * Re-call get_available_languages() here in case a language pack was installed 801 * in a callback hooked to the 'signup_get_available_languages' filter before this point. 802 */ 803 return array_intersect_assoc( $languages, get_available_languages() ); 804 } 46 // Add signup headers. 47 signup_head_actions(); 805 48 806 // Main807 $active_signup = get_site_option( 'registration', 'none' );49 // Load the signup header 50 get_header( 'wp-signup' ); 808 51 809 52 /** 810 * Fi lters the type of site sign-up.53 * Fires before the site sign-up form. 811 54 * 812 55 * @since 3.0.0 813 *814 * @param string $active_signup String that returns registration type. The value can be815 * 'all', 'none', 'blog', or 'user'.816 56 */ 817 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); 818 819 if ( current_user_can( 'manage_network' ) ) { 820 echo '<div class="mu_alert">'; 821 _e( 'Greetings Network Administrator!' ); 822 echo ' '; 823 824 switch ( $active_signup ) { 825 case 'none': 826 _e( 'The network currently disallows registrations.' ); 827 break; 828 case 'blog': 829 _e( 'The network currently allows site registrations.' ); 830 break; 831 case 'user': 832 _e( 'The network currently allows user registrations.' ); 833 break; 834 default: 835 _e( 'The network currently allows both site and user registrations.' ); 836 break; 837 } 838 839 echo ' '; 840 841 /* translators: %s: network settings URL */ 842 printf( __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ), esc_url( network_admin_url( 'settings.php' ) ) ); 843 echo '</div>'; 844 } 845 846 $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; 847 848 $current_user = wp_get_current_user(); 849 if ( $active_signup == 'none' ) { 850 _e( 'Registration has been disabled.' ); 851 } elseif ( $active_signup == 'blog' && !is_user_logged_in() ) { 852 $login_url = wp_login_url( network_site_url( 'wp-signup.php' ) ); 853 /* translators: %s: login URL */ 854 printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url ); 855 } else { 856 $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; 857 switch ( $stage ) { 858 case 'validate-user-signup' : 859 if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) 860 validate_user_signup(); 861 else 862 _e( 'User registration has been disabled.' ); 863 break; 864 case 'validate-blog-signup': 865 if ( $active_signup == 'all' || $active_signup == 'blog' ) 866 validate_blog_signup(); 867 else 868 _e( 'Site registration has been disabled.' ); 869 break; 870 case 'gimmeanotherblog': 871 validate_another_blog_signup(); 872 break; 873 case 'default': 874 default : 875 $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : ''; 876 /** 877 * Fires when the site sign-up form is sent. 878 * 879 * @since 3.0.0 880 */ 881 do_action( 'preprocess_signup_form' ); 882 if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) 883 signup_another_blog($newblogname); 884 elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) 885 signup_user( $newblogname, $user_email ); 886 elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) 887 _e( 'Sorry, new registrations are not allowed at this time.' ); 888 else 889 _e( 'You are logged in already. No need to register again!' ); 57 do_action( 'before_signup_form' ); 890 58 891 if ( $newblogname ) { 892 $newblog = get_blogaddress_by_name( $newblogname);59 // Display the signup template 60 get_template_part( 'signup' ); 893 61 894 if ( $active_signup == 'blog' || $active_signup == 'all' )895 /* translators: %s: site address */896 printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',897 '<strong>' . $newblog . '</strong>'898 );899 else900 /* translators: %s: site address */901 printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',902 '<strong>' . $newblog . '</strong>'903 );904 }905 break;906 }907 }908 ?>909 </div>910 </div>911 <?php912 62 /** 913 63 * Fires after the sign-up forms, before wp_footer. 914 64 * 915 65 * @since 3.0.0 916 66 */ 917 do_action( 'after_signup_form' ); ?>67 do_action( 'after_signup_form' ); 918 68 919 <?php get_footer( 'wp-signup' ); 69 // Load the signup footer 70 get_footer( 'wp-signup' );