[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** Sets up the WordPress Environment. */ 4 require __DIR__ . '/wp-load.php'; 5 6 add_action( 'wp_head', 'wp_no_robots' ); 7 8 require __DIR__ . '/wp-blog-header.php'; 9 10 nocache_headers(); 11 12 if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ), true ) ) { 13 wp_redirect( network_home_url() ); 14 die(); 15 } 16 17 /** 18 * Prints signup_header via wp_head 19 * 20 * @since MU (3.0.0) 21 */ 22 function do_signup_header() { 23 /** 24 * Fires within the head section of the site sign-up screen. 25 * 26 * @since 3.0.0 27 */ 28 do_action( 'signup_header' ); 29 } 30 add_action( 'wp_head', 'do_signup_header' ); 31 32 if ( ! is_multisite() ) { 33 wp_redirect( wp_registration_url() ); 34 die(); 35 } 36 37 if ( ! is_main_site() ) { 38 wp_redirect( network_site_url( 'wp-signup.php' ) ); 39 die(); 40 } 41 42 // Fix for page title. 43 $wp_query->is_404 = false; 44 45 /** 46 * Fires before the Site Signup page is loaded. 47 * 48 * @since 4.4.0 49 */ 50 do_action( 'before_signup_header' ); 51 52 /** 53 * Prints styles for front-end Multisite signup pages 54 * 55 * @since MU (3.0.0) 56 */ 57 function wpmu_signup_stylesheet() { 58 ?> 59 <style type="text/css"> 60 .mu_register { width: 90%; margin:0 auto; } 61 .mu_register form { margin-top: 2em; } 62 .mu_register .error { font-weight: 600; padding: 10px; color: #333333; background: #FFEBE8; border: 1px solid #CC0000; } 63 .mu_register input[type="submit"], 64 .mu_register #blog_title, 65 .mu_register #user_email, 66 .mu_register #blogname, 67 .mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; } 68 .mu_register #site-language { display: block; } 69 .mu_register .prefix_address, 70 .mu_register .suffix_address { font-size: 18px; display:inline; } 71 .mu_register label { font-weight: 600; font-size: 15px; display: block; margin: 10px 0; } 72 .mu_register label.checkbox { display:inline; } 73 .mu_register .mu_alert { font-weight: 600; padding: 10px; color: #333333; background: #ffffe0; border: 1px solid #e6db55; } 74 </style> 75 <?php 76 } 77 78 add_action( 'wp_head', 'wpmu_signup_stylesheet' ); 79 get_header( 'wp-signup' ); 80 81 /** 82 * Fires before the site sign-up form. 83 * 84 * @since 3.0.0 85 */ 86 do_action( 'before_signup_form' ); 87 ?> 88 <div id="signup-content" class="widecolumn"> 89 <div class="mu_register wp-signup-container" role="main"> 90 <?php 91 /** 92 * Generates and displays the Signup and Create Site forms 93 * 94 * @since MU (3.0.0) 95 * 96 * @param string $blogname The new site name. 97 * @param string $blog_title The new site title. 98 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 99 */ 100 function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 101 if ( ! is_wp_error( $errors ) ) { 102 $errors = new WP_Error(); 103 } 104 105 $current_network = get_network(); 106 // Blog name. 107 if ( ! is_subdomain_install() ) { 108 echo '<label for="blogname">' . __( 'Site Name:' ) . '</label>'; 109 } else { 110 echo '<label for="blogname">' . __( 'Site Domain:' ) . '</label>'; 111 } 112 113 $errmsg = $errors->get_error_message( 'blogname' ); 114 if ( $errmsg ) { 115 ?> 116 <p class="error"><?php echo $errmsg; ?></p> 117 <?php 118 } 119 120 if ( ! is_subdomain_install() ) { 121 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 />'; 122 } else { 123 $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ); 124 echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . esc_html( $site_domain ) . '</span><br />'; 125 } 126 127 if ( ! is_user_logged_in() ) { 128 if ( ! is_subdomain_install() ) { 129 $site = $current_network->domain . $current_network->path . __( 'sitename' ); 130 } else { 131 $site = __( 'domain' ) . '.' . $site_domain . $current_network->path; 132 } 133 134 printf( 135 '<p>(<strong>%s</strong>) %s</p>', 136 /* translators: %s: Site address. */ 137 sprintf( __( 'Your address will be %s.' ), $site ), 138 __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) 139 ); 140 } 141 142 // Site Title. 143 ?> 144 <label for="blog_title"><?php _e( 'Site Title:' ); ?></label> 145 <?php 146 $errmsg = $errors->get_error_message( 'blog_title' ); 147 if ( $errmsg ) { 148 ?> 149 <p class="error"><?php echo $errmsg; ?></p> 150 <?php 151 } 152 echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" />'; 153 ?> 154 155 <?php 156 // Site Language. 157 $languages = signup_get_available_languages(); 158 159 if ( ! empty( $languages ) ) : 160 ?> 161 <p> 162 <label for="site-language"><?php _e( 'Site Language:' ); ?></label> 163 <?php 164 // Network default. 165 $lang = get_site_option( 'WPLANG' ); 166 167 if ( isset( $_POST['WPLANG'] ) ) { 168 $lang = $_POST['WPLANG']; 169 } 170 171 // Use US English if the default isn't available. 172 if ( ! in_array( $lang, $languages, true ) ) { 173 $lang = ''; 174 } 175 176 wp_dropdown_languages( 177 array( 178 'name' => 'WPLANG', 179 'id' => 'site-language', 180 'selected' => $lang, 181 'languages' => $languages, 182 'show_available_translations' => false, 183 ) 184 ); 185 ?> 186 </p> 187 <?php 188 endif; // Languages. 189 190 $blog_public_on_checked = ''; 191 $blog_public_off_checked = ''; 192 if ( isset( $_POST['blog_public'] ) && '0' === $_POST['blog_public'] ) { 193 $blog_public_off_checked = 'checked="checked"'; 194 } else { 195 $blog_public_on_checked = 'checked="checked"'; 196 } 197 ?> 198 199 <div id="privacy"> 200 <p class="privacy-intro"> 201 <?php _e( 'Privacy:' ); ?> 202 <?php _e( 'Allow search engines to index this site.' ); ?> 203 <br style="clear:both" /> 204 <label class="checkbox" for="blog_public_on"> 205 <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php echo $blog_public_on_checked; ?> /> 206 <strong><?php _e( 'Yes' ); ?></strong> 207 </label> 208 <label class="checkbox" for="blog_public_off"> 209 <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php echo $blog_public_off_checked; ?> /> 210 <strong><?php _e( 'No' ); ?></strong> 211 </label> 212 </p> 213 </div> 214 215 <?php 216 /** 217 * Fires after the site sign-up form. 218 * 219 * @since 3.0.0 220 * 221 * @param WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. 222 */ 223 do_action( 'signup_blogform', $errors ); 224 } 225 226 /** 227 * Validate the new site signup 228 * 229 * @since MU (3.0.0) 230 * 231 * @return array Contains the new site data and error messages. 232 */ 233 function validate_blog_form() { 234 $user = ''; 235 if ( is_user_logged_in() ) { 236 $user = wp_get_current_user(); 237 } 238 239 return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user ); 240 } 241 242 /** 243 * Displays the fields for the new user account registration form. 244 * 245 * @since MU (3.0.0) 246 * 247 * @param string $user_name The entered username. 248 * @param string $user_email The entered email address. 249 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 250 */ 251 function show_user_form( $user_name = '', $user_email = '', $errors = '' ) { 252 if ( ! is_wp_error( $errors ) ) { 253 $errors = new WP_Error(); 254 } 255 256 // Username. 257 echo '<label for="user_name">' . __( 'Username:' ) . '</label>'; 258 $errmsg = $errors->get_error_message( 'user_name' ); 259 if ( $errmsg ) { 260 echo '<p class="error">' . $errmsg . '</p>'; 261 } 262 echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" autocapitalize="none" autocorrect="off" maxlength="60" /><br />'; 263 _e( '(Must be at least 4 characters, letters and numbers only.)' ); 264 ?> 265 266 <label for="user_email"><?php _e( 'Email Address:' ); ?></label> 267 <?php 268 $errmsg = $errors->get_error_message( 'user_email' ); 269 if ( $errmsg ) { 270 ?> 271 <p class="error"><?php echo $errmsg; ?></p> 272 <?php } ?> 273 <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.)' ); ?> 274 <?php 275 $errmsg = $errors->get_error_message( 'generic' ); 276 if ( $errmsg ) { 277 echo '<p class="error">' . $errmsg . '</p>'; 278 } 279 /** 280 * Fires at the end of the new user account registration form. 281 * 282 * @since 3.0.0 283 * 284 * @param WP_Error $errors A WP_Error object containing 'user_name' or 'user_email' errors. 285 */ 286 do_action( 'signup_extra_fields', $errors ); 287 } 288 289 /** 290 * Validate user signup name and email 291 * 292 * @since MU (3.0.0) 293 * 294 * @return array Contains username, email, and error messages. 295 */ 296 function validate_user_form() { 297 return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); 298 } 299 300 /** 301 * Allow returning users to sign up for another site 302 * 303 * @since MU (3.0.0) 304 * 305 * @param string $blogname The new site name 306 * @param string $blog_title The new site title. 307 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 308 */ 309 function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { 310 $current_user = wp_get_current_user(); 311 312 if ( ! is_wp_error( $errors ) ) { 313 $errors = new WP_Error(); 314 } 315 316 $signup_defaults = array( 317 'blogname' => $blogname, 318 'blog_title' => $blog_title, 319 'errors' => $errors, 320 ); 321 322 /** 323 * Filters the default site sign-up variables. 324 * 325 * @since 3.0.0 326 * 327 * @param array $signup_defaults { 328 * An array of default site sign-up variables. 329 * 330 * @type string $blogname The site blogname. 331 * @type string $blog_title The site title. 332 * @type WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. 333 * } 334 */ 335 $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); 336 337 $blogname = $filtered_results['blogname']; 338 $blog_title = $filtered_results['blog_title']; 339 $errors = $filtered_results['errors']; 340 341 /* translators: %s: Network title. */ 342 echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>'; 343 344 if ( $errors->has_errors() ) { 345 echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; 346 } 347 ?> 348 <p> 349 <?php 350 printf( 351 /* translators: %s: Current user's display name. */ 352 __( '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!' ), 353 $current_user->display_name 354 ); 355 ?> 356 </p> 357 358 <?php 359 $blogs = get_blogs_of_user( $current_user->ID ); 360 if ( ! empty( $blogs ) ) { 361 ?> 362 363 <p><?php _e( 'Sites you are already a member of:' ); ?></p> 364 <ul> 365 <?php 366 foreach ( $blogs as $blog ) { 367 $home_url = get_home_url( $blog->userblog_id ); 368 echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; 369 } 370 ?> 371 </ul> 372 <?php } ?> 373 374 <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> 375 <form id="setupform" method="post" action="wp-signup.php"> 376 <input type="hidden" name="stage" value="gimmeanotherblog" /> 377 <?php 378 /** 379 * Hidden sign-up form fields output when creating another site or user. 380 * 381 * @since MU (3.0.0) 382 * 383 * @param string $context A string describing the steps of the sign-up process. The value can be 384 * 'create-another-site', 'validate-user', or 'validate-site'. 385 */ 386 do_action( 'signup_hidden_fields', 'create-another-site' ); 387 ?> 388 <?php show_blog_form( $blogname, $blog_title, $errors ); ?> 389 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ); ?>" /></p> 390 </form> 391 <?php 392 } 393 394 /** 395 * Validate a new site signup for an existing user. 396 * 397 * @global string $blogname The new site's subdomain or directory name. 398 * @global string $blog_title The new site's title. 399 * @global WP_Error $errors Existing errors in the global scope. 400 * @global string $domain The new site's domain. 401 * @global string $path The new site's path. 402 * 403 * @since MU (3.0.0) 404 * 405 * @return null|bool True if site signup was validated, false if error. 406 * The function halts all execution if the user is not logged in. 407 */ 408 function validate_another_blog_signup() { 409 global $blogname, $blog_title, $errors, $domain, $path; 410 $current_user = wp_get_current_user(); 411 if ( ! is_user_logged_in() ) { 412 die(); 413 } 414 415 $result = validate_blog_form(); 416 417 // Extracted values set/overwrite globals. 418 $domain = $result['domain']; 419 $path = $result['path']; 420 $blogname = $result['blogname']; 421 $blog_title = $result['blog_title']; 422 $errors = $result['errors']; 423 424 if ( $errors->has_errors() ) { 425 signup_another_blog( $blogname, $blog_title, $errors ); 426 return false; 427 } 428 429 $public = (int) $_POST['blog_public']; 430 431 $blog_meta_defaults = array( 432 'lang_id' => 1, 433 'public' => $public, 434 ); 435 436 // Handle the language setting for the new site. 437 if ( ! empty( $_POST['WPLANG'] ) ) { 438 439 $languages = signup_get_available_languages(); 440 441 if ( in_array( $_POST['WPLANG'], $languages, true ) ) { 442 $language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); 443 444 if ( $language ) { 445 $blog_meta_defaults['WPLANG'] = $language; 446 } 447 } 448 } 449 450 /** 451 * Filters the new site meta variables. 452 * 453 * Use the {@see 'add_signup_meta'} filter instead. 454 * 455 * @since MU (3.0.0) 456 * @deprecated 3.0.0 Use the {@see 'add_signup_meta'} filter instead. 457 * 458 * @param array $blog_meta_defaults An array of default blog meta variables. 459 */ 460 $meta_defaults = apply_filters_deprecated( 'signup_create_blog_meta', array( $blog_meta_defaults ), '3.0.0', 'add_signup_meta' ); 461 462 /** 463 * Filters the new default site meta variables. 464 * 465 * @since 3.0.0 466 * 467 * @param array $meta { 468 * An array of default site meta variables. 469 * 470 * @type int $lang_id The language ID. 471 * @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false. 472 * } 473 */ 474 $meta = apply_filters( 'add_signup_meta', $meta_defaults ); 475 476 $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, get_current_network_id() ); 477 478 if ( is_wp_error( $blog_id ) ) { 479 return false; 480 } 481 482 confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id ); 483 return true; 484 } 485 486 /** 487 * Confirm a new site signup. 488 * 489 * @since MU (3.0.0) 490 * @since 4.4.0 Added the `$blog_id` parameter. 491 * 492 * @param string $domain The domain URL. 493 * @param string $path The site root path. 494 * @param string $blog_title The site title. 495 * @param string $user_name The username. 496 * @param string $user_email The user's email address. 497 * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup(). 498 * @param int $blog_id The site ID. 499 */ 500 function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) { 501 502 if ( $blog_id ) { 503 switch_to_blog( $blog_id ); 504 $home_url = home_url( '/' ); 505 $login_url = wp_login_url(); 506 restore_current_blog(); 507 } else { 508 $home_url = 'http://' . $domain . $path; 509 $login_url = 'http://' . $domain . $path . 'wp-login.php'; 510 } 511 512 $site = sprintf( 513 '<a href="%1$s">%2$s</a>', 514 esc_url( $home_url ), 515 $blog_title 516 ); 517 518 ?> 519 <h2> 520 <?php 521 /* translators: %s: Site title. */ 522 printf( __( 'The site %s is yours.' ), $site ); 523 ?> 524 </h2> 525 <p> 526 <?php 527 printf( 528 /* translators: 1: Link to new site, 2: Login URL, 3: Username. */ 529 __( '%1$s is your new site. <a href="%2$s">Log in</a> as “%3$s” using your existing password.' ), 530 sprintf( 531 '<a href="%s">%s</a>', 532 esc_url( $home_url ), 533 untrailingslashit( $domain . $path ) 534 ), 535 esc_url( $login_url ), 536 $user_name 537 ); 538 ?> 539 </p> 540 <?php 541 /** 542 * Fires when the site or user sign-up process is complete. 543 * 544 * @since 3.0.0 545 */ 546 do_action( 'signup_finished' ); 547 } 548 549 /** 550 * Shows a form for a visitor to sign up for a new user account. 551 * 552 * @since MU (3.0.0) 553 * 554 * @param string $user_name The username. 555 * @param string $user_email The user's email. 556 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 557 */ 558 function signup_user( $user_name = '', $user_email = '', $errors = '' ) { 559 global $active_signup; 560 561 if ( ! is_wp_error( $errors ) ) { 562 $errors = new WP_Error(); 563 } 564 565 $signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog'; 566 567 $signup_user_defaults = array( 568 'user_name' => $user_name, 569 'user_email' => $user_email, 570 'errors' => $errors, 571 ); 572 573 /** 574 * Filters the default user variables used on the user sign-up form. 575 * 576 * @since 3.0.0 577 * 578 * @param array $signup_user_defaults { 579 * An array of default user variables. 580 * 581 * @type string $user_name The user username. 582 * @type string $user_email The user email address. 583 * @type WP_Error $errors A WP_Error object with possible errors relevant to the sign-up user. 584 * } 585 */ 586 $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); 587 $user_name = $filtered_results['user_name']; 588 $user_email = $filtered_results['user_email']; 589 $errors = $filtered_results['errors']; 590 591 ?> 592 593 <h2> 594 <?php 595 /* translators: %s: Name of the network. */ 596 printf( __( 'Get your own %s account in seconds' ), get_network()->site_name ); 597 ?> 598 </h2> 599 <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> 600 <input type="hidden" name="stage" value="validate-user-signup" /> 601 <?php 602 /** This action is documented in wp-signup.php */ 603 do_action( 'signup_hidden_fields', 'validate-user' ); 604 ?> 605 <?php show_user_form( $user_name, $user_email, $errors ); ?> 606 607 <p> 608 <?php if ( 'blog' === $active_signup ) { ?> 609 <input id="signupblog" type="hidden" name="signup_for" value="blog" /> 610 <?php } elseif ( 'user' === $active_signup ) { ?> 611 <input id="signupblog" type="hidden" name="signup_for" value="user" /> 612 <?php } else { ?> 613 <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> 614 <label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!' ); ?></label> 615 <br /> 616 <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> 617 <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.' ); ?></label> 618 <?php } ?> 619 </p> 620 621 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Next' ); ?>" /></p> 622 </form> 623 <?php 624 } 625 626 /** 627 * Validate the new user signup 628 * 629 * @since MU (3.0.0) 630 * 631 * @return bool True if new user signup was validated, false if error 632 */ 633 function validate_user_signup() { 634 $result = validate_user_form(); 635 $user_name = $result['user_name']; 636 $user_email = $result['user_email']; 637 $errors = $result['errors']; 638 639 if ( $errors->has_errors() ) { 640 signup_user( $user_name, $user_email, $errors ); 641 return false; 642 } 643 644 if ( 'blog' === $_POST['signup_for'] ) { 645 signup_blog( $user_name, $user_email ); 646 return false; 647 } 648 649 /** This filter is documented in wp-signup.php */ 650 wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) ); 651 652 confirm_user_signup( $user_name, $user_email ); 653 return true; 654 } 655 656 /** 657 * New user signup confirmation 658 * 659 * @since MU (3.0.0) 660 * 661 * @param string $user_name The username 662 * @param string $user_email The user's email address 663 */ 664 function confirm_user_signup( $user_name, $user_email ) { 665 ?> 666 <h2> 667 <?php 668 /* translators: %s: Username. */ 669 printf( __( '%s is your new username' ), $user_name ) 670 ?> 671 </h2> 672 <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ); ?></p> 673 <p> 674 <?php 675 /* translators: %s: Email address. */ 676 printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); 677 ?> 678 </p> 679 <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p> 680 <?php 681 /** This action is documented in wp-signup.php */ 682 do_action( 'signup_finished' ); 683 } 684 685 /** 686 * Shows a form for a user or visitor to sign up for a new site. 687 * 688 * @since MU (3.0.0) 689 * 690 * @param string $user_name The username. 691 * @param string $user_email The user's email address. 692 * @param string $blogname The site name. 693 * @param string $blog_title The site title. 694 * @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. 695 */ 696 function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) { 697 if ( ! is_wp_error( $errors ) ) { 698 $errors = new WP_Error(); 699 } 700 701 $signup_blog_defaults = array( 702 'user_name' => $user_name, 703 'user_email' => $user_email, 704 'blogname' => $blogname, 705 'blog_title' => $blog_title, 706 'errors' => $errors, 707 ); 708 709 /** 710 * Filters the default site creation variables for the site sign-up form. 711 * 712 * @since 3.0.0 713 * 714 * @param array $signup_blog_defaults { 715 * An array of default site creation variables. 716 * 717 * @type string $user_name The user username. 718 * @type string $user_email The user email address. 719 * @type string $blogname The blogname. 720 * @type string $blog_title The title of the site. 721 * @type WP_Error $errors A WP_Error object with possible errors relevant to new site creation variables. 722 * } 723 */ 724 $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults ); 725 726 $user_name = $filtered_results['user_name']; 727 $user_email = $filtered_results['user_email']; 728 $blogname = $filtered_results['blogname']; 729 $blog_title = $filtered_results['blog_title']; 730 $errors = $filtered_results['errors']; 731 732 if ( empty( $blogname ) ) { 733 $blogname = $user_name; 734 } 735 ?> 736 <form id="setupform" method="post" action="wp-signup.php"> 737 <input type="hidden" name="stage" value="validate-blog-signup" /> 738 <input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" /> 739 <input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" /> 740 <?php 741 /** This action is documented in wp-signup.php */ 742 do_action( 'signup_hidden_fields', 'validate-site' ); 743 ?> 744 <?php show_blog_form( $blogname, $blog_title, $errors ); ?> 745 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Signup' ); ?>" /></p> 746 </form> 747 <?php 748 } 749 750 /** 751 * Validate new site signup 752 * 753 * @since MU (3.0.0) 754 * 755 * @return bool True if the site signup was validated, false if error 756 */ 757 function validate_blog_signup() { 758 // Re-validate user info. 759 $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); 760 $user_name = $user_result['user_name']; 761 $user_email = $user_result['user_email']; 762 $user_errors = $user_result['errors']; 763 764 if ( $user_errors->has_errors() ) { 765 signup_user( $user_name, $user_email, $user_errors ); 766 return false; 767 } 768 769 $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] ); 770 $domain = $result['domain']; 771 $path = $result['path']; 772 $blogname = $result['blogname']; 773 $blog_title = $result['blog_title']; 774 $errors = $result['errors']; 775 776 if ( $errors->has_errors() ) { 777 signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors ); 778 return false; 779 } 780 781 $public = (int) $_POST['blog_public']; 782 $signup_meta = array( 783 'lang_id' => 1, 784 'public' => $public, 785 ); 786 787 // Handle the language setting for the new site. 788 if ( ! empty( $_POST['WPLANG'] ) ) { 789 790 $languages = signup_get_available_languages(); 791 792 if ( in_array( $_POST['WPLANG'], $languages, true ) ) { 793 $language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); 794 795 if ( $language ) { 796 $signup_meta['WPLANG'] = $language; 797 } 798 } 799 } 800 801 /** This filter is documented in wp-signup.php */ 802 $meta = apply_filters( 'add_signup_meta', $signup_meta ); 803 804 wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta ); 805 confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta ); 806 return true; 807 } 808 809 /** 810 * Shows a message confirming that the new site has been registered and is awaiting activation. 811 * 812 * @since MU (3.0.0) 813 * 814 * @param string $domain The domain or subdomain of the site. 815 * @param string $path The path of the site. 816 * @param string $blog_title The title of the new site. 817 * @param string $user_name The user's username. 818 * @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(). 820 */ 821 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) { 822 ?> 823 <h2> 824 <?php 825 /* translators: %s: Site address. */ 826 printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) 827 ?> 828 </h2> 829 830 <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ); ?></p> 831 <p> 832 <?php 833 /* translators: %s: Email address. */ 834 printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); 835 ?> 836 </p> 837 <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p> 838 <h2><?php _e( 'Still waiting for your email?' ); ?></h2> 839 <p> 840 <?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ); ?> 841 <ul id="noemail-tips"> 842 <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> 843 <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ); ?></p></li> 844 <li> 845 <?php 846 /* translators: %s: Email address. */ 847 printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email ); 848 ?> 849 </li> 850 </ul> 851 </p> 852 <?php 853 /** This action is documented in wp-signup.php */ 854 do_action( 'signup_finished' ); 855 } 856 857 /** 858 * Retrieves languages available during the site/user signup process. 859 * 860 * @since 4.4.0 861 * 862 * @see get_available_languages() 863 * 864 * @return array List of available languages. 865 */ 866 function signup_get_available_languages() { 867 /** 868 * Filters the list of available languages for front-end site signups. 869 * 870 * Passing an empty array to this hook will disable output of the setting on the 871 * signup form, and the default language will be used when creating the site. 872 * 873 * Languages not already installed will be stripped. 874 * 875 * @since 4.4.0 876 * 877 * @param array $available_languages Available languages. 878 */ 879 $languages = (array) apply_filters( 'signup_get_available_languages', get_available_languages() ); 880 881 /* 882 * Strip any non-installed languages and return. 883 * 884 * Re-call get_available_languages() here in case a language pack was installed 885 * in a callback hooked to the 'signup_get_available_languages' filter before this point. 886 */ 887 return array_intersect_assoc( $languages, get_available_languages() ); 888 } 889 890 // Main. 891 $active_signup = get_site_option( 'registration', 'none' ); 892 893 /** 894 * Filters the type of site sign-up. 895 * 896 * @since 3.0.0 897 * 898 * @param string $active_signup String that returns registration type. The value can be 899 * 'all', 'none', 'blog', or 'user'. 900 */ 901 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); 902 903 if ( current_user_can( 'manage_network' ) ) { 904 echo '<div class="mu_alert">'; 905 _e( 'Greetings Network Administrator!' ); 906 echo ' '; 907 908 switch ( $active_signup ) { 909 case 'none': 910 _e( 'The network currently disallows registrations.' ); 911 break; 912 case 'blog': 913 _e( 'The network currently allows site registrations.' ); 914 break; 915 case 'user': 916 _e( 'The network currently allows user registrations.' ); 917 break; 918 default: 919 _e( 'The network currently allows both site and user registrations.' ); 920 break; 921 } 922 923 echo ' '; 924 925 /* translators: %s: URL to Network Settings screen. */ 926 printf( __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ), esc_url( network_admin_url( 'settings.php' ) ) ); 927 echo '</div>'; 928 } 929 930 $newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null; 931 932 $current_user = wp_get_current_user(); 933 if ( 'none' === $active_signup ) { 934 _e( 'Registration has been disabled.' ); 935 } elseif ( 'blog' === $active_signup && ! is_user_logged_in() ) { 936 $login_url = wp_login_url( network_site_url( 'wp-signup.php' ) ); 937 /* translators: %s: Login URL. */ 938 printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url ); 939 } else { 940 $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; 941 switch ( $stage ) { 942 case 'validate-user-signup': 943 if ( 'all' === $active_signup 944 || ( 'blog' === $_POST['signup_for'] && 'blog' === $active_signup ) 945 || ( 'user' === $_POST['signup_for'] && 'user' === $active_signup ) 946 ) { 947 validate_user_signup(); 948 } else { 949 _e( 'User registration has been disabled.' ); 950 } 951 break; 952 case 'validate-blog-signup': 953 if ( 'all' === $active_signup || 'blog' === $active_signup ) { 954 validate_blog_signup(); 955 } else { 956 _e( 'Site registration has been disabled.' ); 957 } 958 break; 959 case 'gimmeanotherblog': 960 validate_another_blog_signup(); 961 break; 962 case 'default': 963 default: 964 $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : ''; 965 /** 966 * Fires when the site sign-up form is sent. 967 * 968 * @since 3.0.0 969 */ 970 do_action( 'preprocess_signup_form' ); 971 if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) { 972 signup_another_blog( $newblogname ); 973 } elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) { 974 signup_user( $newblogname, $user_email ); 975 } elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) { 976 _e( 'Sorry, new registrations are not allowed at this time.' ); 977 } else { 978 _e( 'You are logged in already. No need to register again!' ); 979 } 980 981 if ( $newblogname ) { 982 $newblog = get_blogaddress_by_name( $newblogname ); 983 984 if ( 'blog' === $active_signup || 'all' === $active_signup ) { 985 printf( 986 /* 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>', 988 '<strong>' . $newblog . '</strong>' 989 ); 990 } else { 991 printf( 992 /* translators: %s: Site address. */ 993 '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>', 994 '<strong>' . $newblog . '</strong>' 995 ); 996 } 997 } 998 break; 999 } 1000 } 1001 ?> 1002 </div> 1003 </div> 1004 <?php 1005 /** 1006 * Fires after the sign-up forms, before wp_footer. 1007 * 1008 * @since 3.0.0 1009 */ 1010 do_action( 'after_signup_form' ); 1011 ?> 1012 1013 <?php 1014 get_footer( 'wp-signup' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Jan 20 01:00:03 2021 | Cross-referenced by PHPXref 0.7.1 |