Changeset 42343 for trunk/src/wp-includes/ms-functions.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/ms-functions.php (modified) (98 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-functions.php
r41753 r42343 40 40 function get_active_blog_for_user( $user_id ) { 41 41 $blogs = get_blogs_of_user( $user_id ); 42 if ( empty( $blogs ) ) 42 if ( empty( $blogs ) ) { 43 43 return; 44 } 44 45 45 46 if ( ! is_multisite() ) { … … 48 49 49 50 $primary_blog = get_user_meta( $user_id, 'primary_blog', true ); 50 $first_blog = current($blogs);51 $first_blog = current( $blogs ); 51 52 if ( false !== $primary_blog ) { 52 53 if ( ! isset( $blogs[ $primary_blog ] ) ) { … … 68 69 if ( ( ! is_object( $primary ) ) || ( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) { 69 70 $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs. 70 $ret = false;71 $ret = false; 71 72 if ( is_array( $blogs ) && count( $blogs ) > 0 ) { 72 73 foreach ( (array) $blogs as $blog_id => $blog ) { 73 if ( $blog->site_id != get_current_network_id() ) 74 if ( $blog->site_id != get_current_network_id() ) { 74 75 continue; 76 } 75 77 $details = get_site( $blog_id ); 76 78 if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) { 77 79 $ret = $blog; 78 if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id )80 if ( get_user_meta( $user_id, 'primary_blog', true ) != $blog_id ) { 79 81 update_user_meta( $user_id, 'primary_blog', $blog_id ); 80 if ( !get_user_meta($user_id , 'source_domain', true) ) 82 } 83 if ( ! get_user_meta( $user_id, 'source_domain', true ) ) { 81 84 update_user_meta( $user_id, 'source_domain', $blog->domain ); 85 } 82 86 break; 83 87 } … … 153 157 */ 154 158 function add_user_to_blog( $blog_id, $user_id, $role ) { 155 switch_to_blog( $blog_id);159 switch_to_blog( $blog_id ); 156 160 157 161 $user = get_userdata( $user_id ); … … 185 189 } 186 190 187 if ( ! get_user_meta($user_id, 'primary_blog', true) ) {188 update_user_meta( $user_id, 'primary_blog', $blog_id);191 if ( ! get_user_meta( $user_id, 'primary_blog', true ) ) { 192 update_user_meta( $user_id, 'primary_blog', $blog_id ); 189 193 $site = get_site( $blog_id ); 190 194 update_user_meta( $user_id, 'source_domain', $site->domain ); 191 195 } 192 196 193 $user->set_role( $role);197 $user->set_role( $role ); 194 198 195 199 /** … … 227 231 * @return true|WP_Error 228 232 */ 229 function remove_user_from_blog( $user_id, $blog_id = '', $reassign = '') {233 function remove_user_from_blog( $user_id, $blog_id = '', $reassign = '' ) { 230 234 global $wpdb; 231 switch_to_blog( $blog_id);235 switch_to_blog( $blog_id ); 232 236 $user_id = (int) $user_id; 233 237 /** … … 243 247 // If being removed from the primary blog, set a new primary if the user is assigned 244 248 // to multiple blogs. 245 $primary_blog = get_user_meta( $user_id, 'primary_blog', true);249 $primary_blog = get_user_meta( $user_id, 'primary_blog', true ); 246 250 if ( $primary_blog == $blog_id ) { 247 $new_id = '';251 $new_id = ''; 248 252 $new_domain = ''; 249 $blogs = get_blogs_of_user($user_id);253 $blogs = get_blogs_of_user( $user_id ); 250 254 foreach ( (array) $blogs as $blog ) { 251 if ( $blog->userblog_id == $blog_id ) 255 if ( $blog->userblog_id == $blog_id ) { 252 256 continue; 253 $new_id = $blog->userblog_id; 257 } 258 $new_id = $blog->userblog_id; 254 259 $new_domain = $blog->domain; 255 260 break; 256 261 } 257 262 258 update_user_meta( $user_id, 'primary_blog', $new_id);259 update_user_meta( $user_id, 'source_domain', $new_domain);263 update_user_meta( $user_id, 'primary_blog', $new_id ); 264 update_user_meta( $user_id, 'source_domain', $new_domain ); 260 265 } 261 266 … … 264 269 if ( ! $user ) { 265 270 restore_current_blog(); 266 return new WP_Error( 'user_does_not_exist', __('That user does not exist.'));271 return new WP_Error( 'user_does_not_exist', __( 'That user does not exist.' ) ); 267 272 } 268 273 269 274 $user->remove_all_caps(); 270 275 271 $blogs = get_blogs_of_user( $user_id);272 if ( count( $blogs) == 0 ) {273 update_user_meta( $user_id, 'primary_blog', '');274 update_user_meta( $user_id, 'source_domain', '');276 $blogs = get_blogs_of_user( $user_id ); 277 if ( count( $blogs ) == 0 ) { 278 update_user_meta( $user_id, 'primary_blog', '' ); 279 update_user_meta( $user_id, 'source_domain', '' ); 275 280 } 276 281 … … 331 336 function get_blog_id_from_url( $domain, $path = '/' ) { 332 337 $domain = strtolower( $domain ); 333 $path = strtolower( $path );334 $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );335 336 if ( $id == -1 ) // blog does not exist338 $path = strtolower( $path ); 339 $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' ); 340 341 if ( $id == -1 ) { // blog does not exist 337 342 return 0; 338 elseif ( $id )343 } elseif ( $id ) { 339 344 return (int) $id; 340 341 $args = array( 345 } 346 347 $args = array( 342 348 'domain' => $domain, 343 'path' => $path,349 'path' => $path, 344 350 'fields' => 'ids', 345 351 'number' => 1, 346 352 ); 347 353 $result = get_sites( $args ); 348 $id = array_shift( $result );354 $id = array_shift( $result ); 349 355 350 356 if ( ! $id ) { … … 375 381 function is_email_address_unsafe( $user_email ) { 376 382 $banned_names = get_site_option( 'banned_email_domains' ); 377 if ( $banned_names && ! is_array( $banned_names ) ) 383 if ( $banned_names && ! is_array( $banned_names ) ) { 378 384 $banned_names = explode( "\n", $banned_names ); 385 } 379 386 380 387 $is_email_address_unsafe = false; 381 388 382 389 if ( $banned_names && is_array( $banned_names ) && false !== strpos( $user_email, '@', 1 ) ) { 383 $banned_names = array_map( 'strtolower', $banned_names );390 $banned_names = array_map( 'strtolower', $banned_names ); 384 391 $normalized_email = strtolower( $user_email ); 385 392 … … 387 394 388 395 foreach ( $banned_names as $banned_domain ) { 389 if ( ! $banned_domain ) 396 if ( ! $banned_domain ) { 390 397 continue; 398 } 391 399 392 400 if ( $email_domain == $banned_domain ) { … … 434 442 * @return array Contains username, email, and error messages. 435 443 */ 436 function wpmu_validate_user_signup( $user_name, $user_email) {444 function wpmu_validate_user_signup( $user_name, $user_email ) { 437 445 global $wpdb; 438 446 … … 440 448 441 449 $orig_username = $user_name; 442 $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );450 $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); 443 451 444 452 if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) { … … 449 457 $user_email = sanitize_email( $user_email ); 450 458 451 if ( empty( $user_name ) ) 452 $errors->add('user_name', __( 'Please enter a username.' ) ); 459 if ( empty( $user_name ) ) { 460 $errors->add( 'user_name', __( 'Please enter a username.' ) ); 461 } 453 462 454 463 $illegal_names = get_site_option( 'illegal_names' ); 455 464 if ( ! is_array( $illegal_names ) ) { 456 $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );465 $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); 457 466 add_site_option( 'illegal_names', $illegal_names ); 458 467 } 459 468 if ( in_array( $user_name, $illegal_names ) ) { 460 $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) );469 $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) ); 461 470 } 462 471 … … 465 474 466 475 if ( in_array( strtolower( $user_name ), array_map( 'strtolower', $illegal_logins ) ) ) { 467 $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) );476 $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) ); 468 477 } 469 478 … … 474 483 } 475 484 476 if ( strlen( $user_name ) < 4 ) 477 $errors->add('user_name', __( 'Username must be at least 4 characters.' ) ); 485 if ( strlen( $user_name ) < 4 ) { 486 $errors->add( 'user_name', __( 'Username must be at least 4 characters.' ) ); 487 } 478 488 479 489 if ( strlen( $user_name ) > 60 ) { … … 482 492 483 493 // all numeric? 484 if ( preg_match( '/^[0-9]*$/', $user_name ) ) 485 $errors->add('user_name', __('Sorry, usernames must have letters too!')); 494 if ( preg_match( '/^[0-9]*$/', $user_name ) ) { 495 $errors->add( 'user_name', __( 'Sorry, usernames must have letters too!' ) ); 496 } 486 497 487 498 $limited_email_domains = get_site_option( 'limited_email_domains' ); … … 489 500 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); 490 501 if ( ! in_array( $emaildomain, $limited_email_domains ) ) { 491 $errors->add( 'user_email', __('Sorry, that email address is not allowed!'));502 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!' ) ); 492 503 } 493 504 } 494 505 495 506 // Check if the username has been used already. 496 if ( username_exists( $user_name) )507 if ( username_exists( $user_name ) ) { 497 508 $errors->add( 'user_name', __( 'Sorry, that username already exists!' ) ); 509 } 498 510 499 511 // Check if the email address has been used already. 500 if ( email_exists( $user_email) )512 if ( email_exists( $user_email ) ) { 501 513 $errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) ); 514 } 502 515 503 516 // Has someone already signed up for this username? 504 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) );517 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name ) ); 505 518 if ( $signup != null ) { 506 $registered_at = mysql2date('U', $signup->registered);507 $now = current_time( 'timestamp', true );508 $diff = $now - $registered_at;519 $registered_at = mysql2date( 'U', $signup->registered ); 520 $now = current_time( 'timestamp', true ); 521 $diff = $now - $registered_at; 509 522 // If registered more than two days ago, cancel registration and let this signup go through. 510 if ( $diff > 2 * DAY_IN_SECONDS ) 523 if ( $diff > 2 * DAY_IN_SECONDS ) { 511 524 $wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) ); 512 else 513 $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); 514 } 515 516 $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) ); 525 } else { 526 $errors->add( 'user_name', __( 'That username is currently reserved but may be available in a couple of days.' ) ); 527 } 528 } 529 530 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email ) ); 517 531 if ( $signup != null ) { 518 $diff = current_time( 'timestamp', true ) - mysql2date( 'U', $signup->registered);532 $diff = current_time( 'timestamp', true ) - mysql2date( 'U', $signup->registered ); 519 533 // If registered more than two days ago, cancel registration and let this signup go through. 520 if ( $diff > 2 * DAY_IN_SECONDS ) 534 if ( $diff > 2 * DAY_IN_SECONDS ) { 521 535 $wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) ); 522 else 523 $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.')); 524 } 525 526 $result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors); 536 } else { 537 $errors->add( 'user_email', __( 'That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.' ) ); 538 } 539 } 540 541 $result = array( 542 'user_name' => $user_name, 543 'orig_username' => $orig_username, 544 'user_email' => $user_email, 545 'errors' => $errors, 546 ); 527 547 528 548 /** … … 574 594 575 595 $current_network = get_network(); 576 $base = $current_network->path;596 $base = $current_network->path; 577 597 578 598 $blog_title = strip_tags( $blog_title ); 579 599 580 $errors = new WP_Error();600 $errors = new WP_Error(); 581 601 $illegal_names = get_site_option( 'illegal_names' ); 582 602 if ( $illegal_names == false ) { … … 593 613 } 594 614 595 if ( empty( $blogname ) ) 596 $errors->add('blogname', __( 'Please enter a site name.' ) ); 615 if ( empty( $blogname ) ) { 616 $errors->add( 'blogname', __( 'Please enter a site name.' ) ); 617 } 597 618 598 619 if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) { … … 600 621 } 601 622 602 if ( in_array( $blogname, $illegal_names ) ) 603 $errors->add('blogname', __( 'That name is not allowed.' ) ); 623 if ( in_array( $blogname, $illegal_names ) ) { 624 $errors->add( 'blogname', __( 'That name is not allowed.' ) ); 625 } 604 626 605 627 /** … … 618 640 619 641 // do not allow users to create a blog that conflicts with a page on the main blog. 620 if ( ! is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )642 if ( ! is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( 'SELECT post_name FROM ' . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) { 621 643 $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) ); 644 } 622 645 623 646 // all numeric? 624 if ( preg_match( '/^[0-9]*$/', $blogname ) ) 625 $errors->add('blogname', __('Sorry, site names must have letters too!')); 647 if ( preg_match( '/^[0-9]*$/', $blogname ) ) { 648 $errors->add( 'blogname', __( 'Sorry, site names must have letters too!' ) ); 649 } 626 650 627 651 /** … … 637 661 $blogname = apply_filters( 'newblogname', $blogname ); 638 662 639 $blog_title = wp_unslash( $blog_title ); 640 641 if ( empty( $blog_title ) ) 642 $errors->add('blog_title', __( 'Please enter a site title.' ) ); 663 $blog_title = wp_unslash( $blog_title ); 664 665 if ( empty( $blog_title ) ) { 666 $errors->add( 'blog_title', __( 'Please enter a site title.' ) ); 667 } 643 668 644 669 // Check if the domain/path has been used already. 645 670 if ( is_subdomain_install() ) { 646 671 $mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain ); 647 $path = $base;672 $path = $base; 648 673 } else { 649 674 $mydomain = "$domain"; 650 $path = $base.$blogname.'/';651 } 652 if ( domain_exists( $mydomain, $path, $current_network->id) )675 $path = $base . $blogname . '/'; 676 } 677 if ( domain_exists( $mydomain, $path, $current_network->id ) ) { 653 678 $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) ); 679 } 654 680 655 681 if ( username_exists( $blogname ) ) { 656 if ( ! is_object( $user ) || ( is_object( $user) && ( $user->user_login != $blogname ) ) )682 if ( ! is_object( $user ) || ( is_object( $user ) && ( $user->user_login != $blogname ) ) ) { 657 683 $errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) ); 684 } 658 685 } 659 686 660 687 // Has someone already signed up for this domain? 661 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) ); // TODO: Check email too?662 if ( ! empty( $signup) ) {663 $diff = current_time( 'timestamp', true ) - mysql2date( 'U', $signup->registered);688 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) ); // TODO: Check email too? 689 if ( ! empty( $signup ) ) { 690 $diff = current_time( 'timestamp', true ) - mysql2date( 'U', $signup->registered ); 664 691 // If registered more than two days ago, cancel registration and let this signup go through. 665 if ( $diff > 2 * DAY_IN_SECONDS ) 666 $wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) ); 667 else 668 $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); 669 } 670 671 $result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'user' => $user, 'errors' => $errors); 692 if ( $diff > 2 * DAY_IN_SECONDS ) { 693 $wpdb->delete( 694 $wpdb->signups, array( 695 'domain' => $mydomain, 696 'path' => $path, 697 ) 698 ); 699 } else { 700 $errors->add( 'blogname', __( 'That site is currently reserved but may be available in a couple days.' ) ); 701 } 702 } 703 704 $result = array( 705 'domain' => $mydomain, 706 'path' => $path, 707 'blogname' => $blogname, 708 'blog_title' => $blog_title, 709 'user' => $user, 710 'errors' => $errors, 711 ); 672 712 673 713 /** … … 704 744 * @param array $meta Optional. Signup meta data. By default, contains the requested privacy setting and lang_id. 705 745 */ 706 function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() ) {746 function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() ) { 707 747 global $wpdb; 708 748 … … 726 766 $meta = apply_filters( 'signup_site_meta', $meta, $domain, $path, $title, $user, $user_email, $key ); 727 767 728 $wpdb->insert( $wpdb->signups, array( 729 'domain' => $domain, 730 'path' => $path, 731 'title' => $title, 732 'user_login' => $user, 733 'user_email' => $user_email, 734 'registered' => current_time('mysql', true), 735 'activation_key' => $key, 736 'meta' => serialize( $meta ) 737 ) ); 768 $wpdb->insert( 769 $wpdb->signups, array( 770 'domain' => $domain, 771 'path' => $path, 772 'title' => $title, 773 'user_login' => $user, 774 'user_email' => $user_email, 775 'registered' => current_time( 'mysql', true ), 776 'activation_key' => $key, 777 'meta' => serialize( $meta ), 778 ) 779 ); 738 780 739 781 /** … … 771 813 772 814 // Format data 773 $user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );815 $user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) ); 774 816 $user_email = sanitize_email( $user_email ); 775 $key = substr( md5( time() . wp_rand() . $user_email ), 0, 16 );817 $key = substr( md5( time() . wp_rand() . $user_email ), 0, 16 ); 776 818 777 819 /** … … 789 831 $meta = apply_filters( 'signup_user_meta', $meta, $user, $user_email, $key ); 790 832 791 $wpdb->insert( $wpdb->signups, array( 792 'domain' => '', 793 'path' => '', 794 'title' => '', 795 'user_login' => $user, 796 'user_email' => $user_email, 797 'registered' => current_time('mysql', true), 798 'activation_key' => $key, 799 'meta' => serialize( $meta ) 800 ) ); 833 $wpdb->insert( 834 $wpdb->signups, array( 835 'domain' => '', 836 'path' => '', 837 'title' => '', 838 'user_login' => $user, 839 'user_email' => $user_email, 840 'registered' => current_time( 'mysql', true ), 841 'activation_key' => $key, 842 'meta' => serialize( $meta ), 843 ) 844 ); 801 845 802 846 /** … … 857 901 858 902 // Send email with activation link. 859 if ( ! is_subdomain_install() || get_current_network_id() != 1 )860 $activate_url = network_site_url( "wp-activate.php?key=$key");861 else903 if ( ! is_subdomain_install() || get_current_network_id() != 1 ) { 904 $activate_url = network_site_url( "wp-activate.php?key=$key" ); 905 } else { 862 906 $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API 863 864 $activate_url = esc_url($activate_url); 865 $admin_email = get_site_option( 'admin_email' ); 866 if ( $admin_email == '' ) 907 } 908 909 $activate_url = esc_url( $activate_url ); 910 $admin_email = get_site_option( 'admin_email' ); 911 if ( $admin_email == '' ) { 867 912 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 868 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 869 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 870 871 $user = get_user_by( 'login', $user_login ); 913 } 914 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 915 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; 916 917 $user = get_user_by( 'login', $user_login ); 872 918 $switched_locale = switch_to_locale( get_user_locale( $user ) ); 873 919 … … 889 935 * @param array $meta Signup meta data. By default, contains the requested privacy setting and lang_id. 890 936 */ 891 apply_filters( 'wpmu_signup_blog_notification_email', 892 __( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s" ), 937 apply_filters( 938 'wpmu_signup_blog_notification_email', 939 __( "To activate your blog, please click the following link:\n\n%1\$s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%2\$s" ), 893 940 $domain, $path, $title, $user_login, $user_email, $key, $meta 894 941 ), … … 913 960 * @param array $meta Signup meta data. By default, contains the requested privacy setting and lang_id. 914 961 */ 915 apply_filters( 'wpmu_signup_blog_notification_subject', 962 apply_filters( 963 'wpmu_signup_blog_notification_subject', 916 964 /* translators: New site notification email subject. 1: Network name, 2: New site URL */ 917 965 _x( '[%1$s] Activate %2$s', 'New site notification email subject' ), … … 963 1011 * @param array $meta Signup meta data. Default empty array. 964 1012 */ 965 if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) ) 1013 if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) ) { 966 1014 return false; 967 968 $user = get_user_by( 'login', $user_login ); 1015 } 1016 1017 $user = get_user_by( 'login', $user_login ); 969 1018 $switched_locale = switch_to_locale( get_user_locale( $user ) ); 970 1019 971 1020 // Send email with activation link. 972 1021 $admin_email = get_site_option( 'admin_email' ); 973 if ( $admin_email == '' ) 1022 if ( $admin_email == '' ) { 974 1023 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 975 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 976 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 977 $message = sprintf( 1024 } 1025 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 1026 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; 1027 $message = sprintf( 978 1028 /** 979 1029 * Filters the content of the notification email for new user sign-up. … … 989 1039 * @param array $meta Signup meta data. Default empty array. 990 1040 */ 991 apply_filters( 'wpmu_signup_user_notification_email', 1041 apply_filters( 1042 'wpmu_signup_user_notification_email', 992 1043 __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ), 993 1044 $user_login, $user_email, $key, $meta … … 1008 1059 * @param array $meta Signup meta data. Default empty array. 1009 1060 */ 1010 apply_filters( 'wpmu_signup_user_notification_subject', 1061 apply_filters( 1062 'wpmu_signup_user_notification_subject', 1011 1063 /* translators: New user notification email subject. 1: Network name, 2: New user login */ 1012 1064 _x( '[%1$s] Activate %2$s', 'New user notification email subject' ), … … 1040 1092 * @return array|WP_Error An array containing information about the activated user and/or blog 1041 1093 */ 1042 function wpmu_activate_signup( $key) {1094 function wpmu_activate_signup( $key ) { 1043 1095 global $wpdb; 1044 1096 1045 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );1046 1047 if ( empty( $signup ) ) 1097 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key ) ); 1098 1099 if ( empty( $signup ) ) { 1048 1100 return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) ); 1101 } 1049 1102 1050 1103 if ( $signup->active ) { 1051 if ( empty( $signup->domain ) ) 1104 if ( empty( $signup->domain ) ) { 1052 1105 return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup ); 1053 else1106 } else { 1054 1107 return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup ); 1055 } 1056 1057 $meta = maybe_unserialize($signup->meta); 1108 } 1109 } 1110 1111 $meta = maybe_unserialize( $signup->meta ); 1058 1112 $password = wp_generate_password( 12, false ); 1059 1113 1060 $user_id = username_exists( $signup->user_login);1061 1062 if ( ! $user_id ) 1063 $user_id = wpmu_create_user( $signup->user_login, $password, $signup->user_email);1064 else1114 $user_id = username_exists( $signup->user_login ); 1115 1116 if ( ! $user_id ) { 1117 $user_id = wpmu_create_user( $signup->user_login, $password, $signup->user_email ); 1118 } else { 1065 1119 $user_already_exists = true; 1066 1067 if ( ! $user_id ) 1068 return new WP_Error('create_user', __('Could not create user'), $signup); 1069 1070 $now = current_time('mysql', true); 1071 1072 if ( empty($signup->domain) ) { 1073 $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) ); 1074 1075 if ( isset( $user_already_exists ) ) 1076 return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup); 1120 } 1121 1122 if ( ! $user_id ) { 1123 return new WP_Error( 'create_user', __( 'Could not create user' ), $signup ); 1124 } 1125 1126 $now = current_time( 'mysql', true ); 1127 1128 if ( empty( $signup->domain ) ) { 1129 $wpdb->update( 1130 $wpdb->signups, array( 1131 'active' => 1, 1132 'activated' => $now, 1133 ), array( 'activation_key' => $key ) 1134 ); 1135 1136 if ( isset( $user_already_exists ) ) { 1137 return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup ); 1138 } 1077 1139 1078 1140 /** … … 1086 1148 */ 1087 1149 do_action( 'wpmu_activate_user', $user_id, $password, $meta ); 1088 return array( 'user_id' => $user_id, 'password' => $password, 'meta' => $meta ); 1150 return array( 1151 'user_id' => $user_id, 1152 'password' => $password, 1153 'meta' => $meta, 1154 ); 1089 1155 } 1090 1156 … … 1092 1158 1093 1159 // TODO: What to do if we create a user but cannot create a blog? 1094 if ( is_wp_error( $blog_id) ) {1160 if ( is_wp_error( $blog_id ) ) { 1095 1161 // If blog is taken, that means a previous attempt to activate this blog failed in between creating the blog and 1096 1162 // setting the activation flag. Let's just set the active flag and instruct the user to reset their password. 1097 1163 if ( 'blog_taken' == $blog_id->get_error_code() ) { 1098 1164 $blog_id->add_data( $signup ); 1099 $wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) ); 1165 $wpdb->update( 1166 $wpdb->signups, array( 1167 'active' => 1, 1168 'activated' => $now, 1169 ), array( 'activation_key' => $key ) 1170 ); 1100 1171 } 1101 1172 return $blog_id; 1102 1173 } 1103 1174 1104 $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) ); 1175 $wpdb->update( 1176 $wpdb->signups, array( 1177 'active' => 1, 1178 'activated' => $now, 1179 ), array( 'activation_key' => $key ) 1180 ); 1105 1181 /** 1106 1182 * Fires immediately after a site is activated. … … 1116 1192 do_action( 'wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta ); 1117 1193 1118 return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta); 1194 return array( 1195 'blog_id' => $blog_id, 1196 'user_id' => $user_id, 1197 'password' => $password, 1198 'title' => $signup->title, 1199 'meta' => $meta, 1200 ); 1119 1201 } 1120 1202 … … 1138 1220 1139 1221 $user_id = wp_create_user( $user_name, $password, $email ); 1140 if ( is_wp_error( $user_id ) ) 1222 if ( is_wp_error( $user_id ) ) { 1141 1223 return false; 1224 } 1142 1225 1143 1226 // Newly created users have no roles or caps until they are added to a blog. … … 1188 1271 'WPLANG' => get_network_option( $network_id, 'WPLANG' ), 1189 1272 ); 1190 $meta = wp_parse_args( $meta, $defaults );1273 $meta = wp_parse_args( $meta, $defaults ); 1191 1274 1192 1275 $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) ); 1193 1276 1194 if ( is_subdomain_install() ) 1277 if ( is_subdomain_install() ) { 1195 1278 $domain = str_replace( '@', '', $domain ); 1196 1197 $title = strip_tags( $title ); 1279 } 1280 1281 $title = strip_tags( $title ); 1198 1282 $user_id = (int) $user_id; 1199 1283 1200 if ( empty( $path) )1284 if ( empty( $path ) ) { 1201 1285 $path = '/'; 1286 } 1202 1287 1203 1288 // Check if the domain has been used already. We should return an error message. 1204 if ( domain_exists( $domain, $path, $network_id) )1289 if ( domain_exists( $domain, $path, $network_id ) ) { 1205 1290 return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) ); 1291 } 1206 1292 1207 1293 if ( ! wp_installing() ) { … … 1209 1295 } 1210 1296 1211 if ( ! $blog_id = insert_blog($domain, $path, $network_id) ) 1212 return new WP_Error('insert_blog', __('Could not create site.')); 1213 1214 switch_to_blog($blog_id); 1215 install_blog($blog_id, $title); 1216 wp_install_defaults($user_id); 1217 1218 add_user_to_blog($blog_id, $user_id, 'administrator'); 1297 if ( ! $blog_id = insert_blog( $domain, $path, $network_id ) ) { 1298 return new WP_Error( 'insert_blog', __( 'Could not create site.' ) ); 1299 } 1300 1301 switch_to_blog( $blog_id ); 1302 install_blog( $blog_id, $title ); 1303 wp_install_defaults( $user_id ); 1304 1305 add_user_to_blog( $blog_id, $user_id, 'administrator' ); 1219 1306 1220 1307 foreach ( $meta as $key => $value ) { 1221 if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) 1308 if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) { 1222 1309 update_blog_status( $blog_id, $key, $value ); 1223 else1310 } else { 1224 1311 update_option( $key, $value ); 1312 } 1225 1313 } 1226 1314 1227 1315 update_option( 'blog_public', (int) $meta['public'] ); 1228 1316 1229 if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) 1317 if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) { 1230 1318 update_user_meta( $user_id, 'primary_blog', $blog_id ); 1319 } 1231 1320 1232 1321 restore_current_blog(); … … 1263 1352 */ 1264 1353 function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) { 1265 if ( get_site_option( 'registrationnotification' ) != 'yes' ) 1354 if ( get_site_option( 'registrationnotification' ) != 'yes' ) { 1266 1355 return false; 1356 } 1267 1357 1268 1358 $email = get_site_option( 'admin_email' ); 1269 if ( is_email( $email) == false )1359 if ( is_email( $email ) == false ) { 1270 1360 return false; 1271 1272 $options_site_url = esc_url(network_admin_url('settings.php')); 1361 } 1362 1363 $options_site_url = esc_url( network_admin_url( 'settings.php' ) ); 1273 1364 1274 1365 switch_to_blog( $blog_id ); 1275 1366 $blogname = get_option( 'blogname' ); 1276 $siteurl = site_url();1367 $siteurl = site_url(); 1277 1368 restore_current_blog(); 1278 1369 1279 1370 /* translators: New site notification email. 1: Site URL, 2: User IP address, 3: Settings screen URL */ 1280 $msg = sprintf( __( 'New Site: %1$s 1371 $msg = sprintf( 1372 __( 1373 'New Site: %1$s 1281 1374 URL: %2$s 1282 1375 Remote IP address: %3$s 1283 1376 1284 Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url); 1377 Disable these notifications: %4$s' 1378 ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url 1379 ); 1285 1380 /** 1286 1381 * Filters the message body of the new site activation email sent … … 1309 1404 */ 1310 1405 function newuser_notify_siteadmin( $user_id ) { 1311 if ( get_site_option( 'registrationnotification' ) != 'yes' ) 1406 if ( get_site_option( 'registrationnotification' ) != 'yes' ) { 1312 1407 return false; 1408 } 1313 1409 1314 1410 $email = get_site_option( 'admin_email' ); 1315 1411 1316 if ( is_email( $email) == false )1412 if ( is_email( $email ) == false ) { 1317 1413 return false; 1414 } 1318 1415 1319 1416 $user = get_userdata( $user_id ); 1320 1417 1321 $options_site_url = esc_url( network_admin_url('settings.php'));1418 $options_site_url = esc_url( network_admin_url( 'settings.php' ) ); 1322 1419 /* translators: New user notification email. 1: User login, 2: User IP address, 3: Settings screen URL */ 1323 $msg = sprintf(__('New User: %1$s 1420 $msg = sprintf( 1421 __( 1422 'New User: %1$s 1324 1423 Remote IP address: %2$s 1325 1424 1326 Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url); 1425 Disable these notifications: %3$s' 1426 ), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url 1427 ); 1327 1428 1328 1429 /** … … 1336 1437 */ 1337 1438 $msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user ); 1338 wp_mail( $email, sprintf( __('New User Registration: %s'), $user->user_login), $msg );1439 wp_mail( $email, sprintf( __( 'New User Registration: %s' ), $user->user_login ), $msg ); 1339 1440 return true; 1340 1441 } … … 1357 1458 */ 1358 1459 function domain_exists( $domain, $path, $network_id = 1 ) { 1359 $path = trailingslashit( $path );1360 $args = array(1460 $path = trailingslashit( $path ); 1461 $args = array( 1361 1462 'network_id' => $network_id, 1362 1463 'domain' => $domain, … … 1399 1500 * @return int|false The ID of the new row 1400 1501 */ 1401 function insert_blog( $domain, $path, $network_id) {1502 function insert_blog( $domain, $path, $network_id ) { 1402 1503 global $wpdb; 1403 1504 1404 $path = trailingslashit($path);1505 $path = trailingslashit( $path ); 1405 1506 $network_id = (int) $network_id; 1406 1507 1407 $result = $wpdb->insert( $wpdb->blogs, array('site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) ); 1408 if ( ! $result ) 1508 $result = $wpdb->insert( 1509 $wpdb->blogs, array( 1510 'site_id' => $network_id, 1511 'domain' => $domain, 1512 'path' => $path, 1513 'registered' => current_time( 'mysql' ), 1514 ) 1515 ); 1516 if ( ! $result ) { 1409 1517 return false; 1518 } 1410 1519 1411 1520 $blog_id = $wpdb->insert_id; … … 1441 1550 1442 1551 $suppress = $wpdb->suppress_errors(); 1443 if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) 1552 if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) { 1444 1553 die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' ); 1554 } 1445 1555 $wpdb->suppress_errors( $suppress ); 1446 1556 … … 1459 1569 if ( ! is_subdomain_install() ) { 1460 1570 1461 if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) { 1462 $siteurl = set_url_scheme( $siteurl, 'https' ); 1463 } 1464 if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) { 1465 $home = set_url_scheme( $home, 'https' ); 1466 } 1467 1571 if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) { 1572 $siteurl = set_url_scheme( $siteurl, 'https' ); 1573 } 1574 if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) { 1575 $home = set_url_scheme( $home, 'https' ); 1576 } 1468 1577 } 1469 1578 … … 1471 1580 update_option( 'home', $home ); 1472 1581 1473 if ( get_site_option( 'ms_files_rewriting' ) ) 1582 if ( get_site_option( 'ms_files_rewriting' ) ) { 1474 1583 update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" ); 1475 else1584 } else { 1476 1585 update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) ); 1586 } 1477 1587 1478 1588 update_option( 'blogname', wp_unslash( $blog_title ) ); … … 1481 1591 // remove all perms 1482 1592 $table_prefix = $wpdb->get_blog_prefix(); 1483 delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all1593 delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all 1484 1594 delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all 1485 1595 } … … 1499 1609 * @param int $user_id 1500 1610 */ 1501 function install_blog_defaults( $blog_id, $user_id) {1611 function install_blog_defaults( $blog_id, $user_id ) { 1502 1612 global $wpdb; 1503 1613 … … 1506 1616 $suppress = $wpdb->suppress_errors(); 1507 1617 1508 wp_install_defaults( $user_id);1618 wp_install_defaults( $user_id ); 1509 1619 1510 1620 $wpdb->suppress_errors( $suppress ); … … 1544 1654 * @param array $meta Signup meta data. By default, contains the requested privacy setting and lang_id. 1545 1655 */ 1546 if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) 1656 if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) { 1547 1657 return false; 1658 } 1548 1659 1549 1660 $user = get_userdata( $user_id ); … … 1554 1665 if ( $welcome_email == false ) { 1555 1666 /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ 1556 $welcome_email = __( 'Howdy USERNAME, 1667 $welcome_email = __( 1668 'Howdy USERNAME, 1557 1669 1558 1670 Your new SITE_NAME site has been successfully set up at: … … 1567 1679 We hope you enjoy your new site. Thanks! 1568 1680 1569 --The Team @ SITE_NAME' ); 1570 } 1571 1572 $url = get_blogaddress_by_id($blog_id); 1681 --The Team @ SITE_NAME' 1682 ); 1683 } 1684 1685 $url = get_blogaddress_by_id( $blog_id ); 1573 1686 1574 1687 $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email ); … … 1593 1706 */ 1594 1707 $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta ); 1595 $admin_email = get_site_option( 'admin_email' );1596 1597 if ( $admin_email == '' ) 1708 $admin_email = get_site_option( 'admin_email' ); 1709 1710 if ( $admin_email == '' ) { 1598 1711 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 1599 1600 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 1601 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 1602 $message = $welcome_email; 1603 1604 if ( empty( $current_network->site_name ) ) 1712 } 1713 1714 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 1715 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; 1716 $message = $welcome_email; 1717 1718 if ( empty( $current_network->site_name ) ) { 1605 1719 $current_network->site_name = 'WordPress'; 1720 } 1606 1721 1607 1722 /* translators: New site notification email subject. 1: Network name, 2: New site name */ … … 1644 1759 1645 1760 /** 1646 * Filters whether to bypass the welcome email after user activation.1761 * Filters whether to bypass the welcome email after user activation. 1647 1762 * 1648 1763 * Returning false disables the welcome email. … … 1654 1769 * @param array $meta Signup meta data. Default empty array. 1655 1770 */ 1656 if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) 1771 if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) { 1657 1772 return false; 1773 } 1658 1774 1659 1775 $welcome_email = get_site_option( 'welcome_user_email' ); … … 1683 1799 $admin_email = get_site_option( 'admin_email' ); 1684 1800 1685 if ( $admin_email == '' ) 1801 if ( $admin_email == '' ) { 1686 1802 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 1687 1688 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 1689 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 1690 $message = $welcome_email; 1691 1692 if ( empty( $current_network->site_name ) ) 1803 } 1804 1805 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 1806 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; 1807 $message = $welcome_email; 1808 1809 if ( empty( $current_network->site_name ) ) { 1693 1810 $current_network->site_name = 'WordPress'; 1811 } 1694 1812 1695 1813 /* translators: New user notification email subject. 1: Network name, 2: New user login */ … … 1703 1821 * @param string $subject Subject of the email. 1704 1822 */ 1705 $subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login ) );1823 $subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login ) ); 1706 1824 wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); 1707 1825 … … 1748 1866 global $wpdb; 1749 1867 1750 $user_blogs = get_blogs_of_user( (int) $user_id );1868 $user_blogs = get_blogs_of_user( (int) $user_id ); 1751 1869 $most_recent_post = array(); 1752 1870 … … 1754 1872 // published by $user_id 1755 1873 foreach ( (array) $user_blogs as $blog ) { 1756 $prefix = $wpdb->get_blog_prefix( $blog->userblog_id );1757 $recent_post = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A);1874 $prefix = $wpdb->get_blog_prefix( $blog->userblog_id ); 1875 $recent_post = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A ); 1758 1876 1759 1877 // Make sure we found a post 1760 if ( isset( $recent_post['ID']) ) {1761 $post_gmt_ts = strtotime( $recent_post['post_date_gmt']);1878 if ( isset( $recent_post['ID'] ) ) { 1879 $post_gmt_ts = strtotime( $recent_post['post_date_gmt'] ); 1762 1880 1763 1881 // If this is the first post checked or if this post is 1764 1882 // newer than the current recent post, make it the new 1765 1883 // most recent post. 1766 if ( ! isset($most_recent_post['post_gmt_ts']) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {1884 if ( ! isset( $most_recent_post['post_gmt_ts'] ) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) { 1767 1885 $most_recent_post = array( 1768 'blog_id' => $blog->userblog_id,1769 'post_id' => $recent_post['ID'],1770 'post_date_gmt' => $recent_post['post_date_gmt'],1771 'post_gmt_ts' => $post_gmt_ts1886 'blog_id' => $blog->userblog_id, 1887 'post_id' => $recent_post['ID'], 1888 'post_date_gmt' => $recent_post['post_date_gmt'], 1889 'post_gmt_ts' => $post_gmt_ts, 1772 1890 ); 1773 1891 } … … 1793 1911 function get_dirsize( $directory ) { 1794 1912 $dirsize = get_transient( 'dirsize_cache' ); 1795 if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) 1796 return $dirsize[ $directory ][ 'size' ]; 1797 1798 if ( ! is_array( $dirsize ) ) 1913 if ( is_array( $dirsize ) && isset( $dirsize[ $directory ]['size'] ) ) { 1914 return $dirsize[ $directory ]['size']; 1915 } 1916 1917 if ( ! is_array( $dirsize ) ) { 1799 1918 $dirsize = array(); 1919 } 1800 1920 1801 1921 // Exclude individual site directories from the total when checking the main site, 1802 1922 // as they are subdirectories and should not be counted. 1803 1923 if ( is_main_site() ) { 1804 $dirsize[ $directory ][ 'size'] = recurse_dirsize( $directory, $directory . '/sites' );1924 $dirsize[ $directory ]['size'] = recurse_dirsize( $directory, $directory . '/sites' ); 1805 1925 } else { 1806 $dirsize[ $directory ][ 'size'] = recurse_dirsize( $directory );1926 $dirsize[ $directory ]['size'] = recurse_dirsize( $directory ); 1807 1927 } 1808 1928 1809 1929 set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS ); 1810 return $dirsize[ $directory ][ 'size'];1930 return $dirsize[ $directory ]['size']; 1811 1931 } 1812 1932 … … 1833 1953 } 1834 1954 1835 if ( $handle = opendir($directory)) {1836 while (($file = readdir($handle)) !== false) {1837 $path = $directory .'/'.$file;1838 if ( $file != '.' && $file != '..') {1839 if ( is_file($path)) {1840 $size += filesize( $path);1841 } elseif ( is_dir($path)) {1955 if ( $handle = opendir( $directory ) ) { 1956 while ( ( $file = readdir( $handle ) ) !== false ) { 1957 $path = $directory . '/' . $file; 1958 if ( $file != '.' && $file != '..' ) { 1959 if ( is_file( $path ) ) { 1960 $size += filesize( $path ); 1961 } elseif ( is_dir( $path ) ) { 1842 1962 $handlesize = recurse_dirsize( $path, $exclude ); 1843 if ( $handlesize > 0)1963 if ( $handlesize > 0 ) { 1844 1964 $size += $handlesize; 1965 } 1845 1966 } 1846 1967 } 1847 1968 } 1848 closedir( $handle);1969 closedir( $handle ); 1849 1970 } 1850 1971 return $size; … … 1866 1987 */ 1867 1988 function check_upload_mimes( $mimes ) { 1868 $site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );1989 $site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) ); 1869 1990 $site_mimes = array(); 1870 1991 foreach ( $site_exts as $ext ) { 1871 1992 foreach ( $mimes as $ext_pattern => $mime ) { 1872 if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) 1873 $site_mimes[$ext_pattern] = $mime; 1993 if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) { 1994 $site_mimes[ $ext_pattern ] = $mime; 1995 } 1874 1996 } 1875 1997 } … … 1909 2031 global $wpdb; 1910 2032 $user = get_userdata( (int) $user_id ); 1911 if ( $user ) 1912 $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) ); 2033 if ( $user ) { 2034 $wpdb->insert( 2035 $wpdb->registration_log, array( 2036 'email' => $user->user_email, 2037 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 2038 'blog_id' => $blog_id, 2039 'date_registered' => current_time( 'mysql' ), 2040 ) 2041 ); 2042 } 1913 2043 } 1914 2044 … … 1931 2061 static $global_terms_recurse = null; 1932 2062 1933 if ( ! global_terms_enabled() )2063 if ( ! global_terms_enabled() ) { 1934 2064 return $term_id; 2065 } 1935 2066 1936 2067 // prevent a race condition 1937 2068 $recurse_start = false; 1938 2069 if ( $global_terms_recurse === null ) { 1939 $recurse_start = true;2070 $recurse_start = true; 1940 2071 $global_terms_recurse = 1; 1941 2072 } elseif ( 10 < $global_terms_recurse++ ) { … … 1944 2075 1945 2076 $term_id = intval( $term_id ); 1946 $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );2077 $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) ); 1947 2078 1948 2079 $global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) ); … … 1950 2081 $used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) ); 1951 2082 if ( null == $used_global_id ) { 1952 $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); 2083 $wpdb->insert( 2084 $wpdb->sitecategories, array( 2085 'cat_ID' => $term_id, 2086 'cat_name' => $c->name, 2087 'category_nicename' => $c->slug, 2088 ) 2089 ); 1953 2090 $global_id = $wpdb->insert_id; 1954 if ( empty( $global_id ) ) 2091 if ( empty( $global_id ) ) { 1955 2092 return $term_id; 2093 } 1956 2094 } else { 1957 2095 $max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" ); 1958 $max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );2096 $max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" ); 1959 2097 $new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 ); 1960 $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); 2098 $wpdb->insert( 2099 $wpdb->sitecategories, array( 2100 'cat_ID' => $new_global_id, 2101 'cat_name' => $c->name, 2102 'category_nicename' => $c->slug, 2103 ) 2104 ); 1961 2105 $global_id = $wpdb->insert_id; 1962 2106 } … … 1972 2116 1973 2117 if ( $global_id != $term_id ) { 1974 if ( get_option( 'default_category' ) == $term_id ) 2118 if ( get_option( 'default_category' ) == $term_id ) { 1975 2119 update_option( 'default_category', $global_id ); 1976 1977 $wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) ); 1978 $wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) ); 1979 $wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) ); 1980 1981 clean_term_cache($term_id); 1982 } 1983 if ( $recurse_start ) 2120 } 2121 2122 $wpdb->update( $wpdb->terms, array( 'term_id' => $global_id ), array( 'term_id' => $term_id ) ); 2123 $wpdb->update( $wpdb->term_taxonomy, array( 'term_id' => $global_id ), array( 'term_id' => $term_id ) ); 2124 $wpdb->update( $wpdb->term_taxonomy, array( 'parent' => $global_id ), array( 'parent' => $term_id ) ); 2125 2126 clean_term_cache( $term_id ); 2127 } 2128 if ( $recurse_start ) { 1984 2129 $global_terms_recurse = null; 2130 } 1985 2131 1986 2132 return $global_id; … … 2011 2157 */ 2012 2158 function upload_is_file_too_big( $upload ) { 2013 if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) 2159 if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) { 2014 2160 return $upload; 2015 2016 if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { 2161 } 2162 2163 if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { 2017 2164 return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) ); 2018 2165 } … … 2029 2176 $id = mt_rand(); 2030 2177 echo "<input type='hidden' name='signup_form_id' value='{$id}' />"; 2031 wp_nonce_field( 'signup_form_' . $id, '_signup_form', false);2178 wp_nonce_field( 'signup_form_' . $id, '_signup_form', false ); 2032 2179 } 2033 2180 … … 2041 2188 */ 2042 2189 function signup_nonce_check( $result ) { 2043 if ( ! strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )2190 if ( ! strpos( $_SERVER['PHP_SELF'], 'wp-signup.php' ) ) { 2044 2191 return $result; 2045 2046 if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] ) 2192 } 2193 2194 if ( wp_create_nonce( 'signup_form_' . $_POST['signup_form_id'] ) != $_POST['_signup_form'] ) { 2047 2195 wp_die( __( 'Please try again.' ) ); 2196 } 2048 2197 2049 2198 return $result; … … 2066 2215 */ 2067 2216 if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) { 2068 if ( $destination == '%siteurl%' ) 2217 if ( $destination == '%siteurl%' ) { 2069 2218 $destination = network_home_url(); 2219 } 2070 2220 wp_redirect( $destination ); 2071 2221 exit(); … … 2083 2233 */ 2084 2234 function maybe_add_existing_user_to_blog() { 2085 if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )2235 if ( false === strpos( $_SERVER['REQUEST_URI'], '/newbloguser/' ) ) { 2086 2236 return; 2087 2088 $parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] ); 2089 $key = array_pop( $parts ); 2090 2091 if ( $key == '' ) 2237 } 2238 2239 $parts = explode( '/', $_SERVER['REQUEST_URI'] ); 2240 $key = array_pop( $parts ); 2241 2242 if ( $key == '' ) { 2092 2243 $key = array_pop( $parts ); 2244 } 2093 2245 2094 2246 $details = get_option( 'new_user_' . $key ); 2095 if ( ! empty( $details ) )2247 if ( ! empty( $details ) ) { 2096 2248 delete_option( 'new_user_' . $key ); 2097 2098 if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) 2099 wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) ); 2100 2101 wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress › Success' ), array( 'response' => 200 ) ); 2249 } 2250 2251 if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) { 2252 wp_die( sprintf( __( 'An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.' ), home_url() ) ); 2253 } 2254 2255 wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%1$s">homepage</a> or <a href="%2$s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress › Success' ), array( 'response' => 200 ) ); 2102 2256 } 2103 2257 … … 2113 2267 if ( is_array( $details ) ) { 2114 2268 $blog_id = get_current_blog_id(); 2115 $result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role'] );2269 $result = add_user_to_blog( $blog_id, $details['user_id'], $details['role'] ); 2116 2270 2117 2271 /** … … 2144 2298 */ 2145 2299 function add_new_user_to_blog( $user_id, $password, $meta ) { 2146 if ( ! empty( $meta[ 'add_to_blog'] ) ) {2147 $blog_id = $meta[ 'add_to_blog'];2148 $role = $meta[ 'new_role'];2300 if ( ! empty( $meta['add_to_blog'] ) ) { 2301 $blog_id = $meta['add_to_blog']; 2302 $role = $meta['new_role']; 2149 2303 remove_user_from_blog( $user_id, get_network()->site_id ); // remove user from main blog. 2150 2304 … … 2174 2328 * 2175 2329 * @param string|WP_User $user Optional. Defaults to current user. WP_User object, 2176 * or user login name as a string.2330 * or user login name as a string. 2177 2331 * @return bool 2178 2332 */ 2179 2333 function is_user_spammy( $user = null ) { 2180 if ( ! ( $user instanceof WP_User ) ) {2334 if ( ! ( $user instanceof WP_User ) ) { 2181 2335 if ( $user ) { 2182 2336 $user = get_user_by( 'login', $user ); … … 2211 2365 */ 2212 2366 function users_can_register_signup_filter() { 2213 $registration = get_site_option( 'registration');2367 $registration = get_site_option( 'registration' ); 2214 2368 return ( $registration == 'all' || $registration == 'user' ); 2215 2369 } … … 2224 2378 */ 2225 2379 function welcome_user_msg_filter( $text ) { 2226 if ( ! $text ) {2380 if ( ! $text ) { 2227 2381 remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' ); 2228 2382 2229 2383 /* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */ 2230 $text = __( 'Howdy USERNAME, 2384 $text = __( 2385 'Howdy USERNAME, 2231 2386 2232 2387 Your new account is set up. … … 2239 2394 Thanks! 2240 2395 2241 --The Team @ SITE_NAME' ); 2396 --The Team @ SITE_NAME' 2397 ); 2242 2398 update_site_option( 'welcome_user_email', $text ); 2243 2399 } … … 2259 2415 2260 2416 if ( '' != $force ) { 2261 $old_forced = $forced_content;2417 $old_forced = $forced_content; 2262 2418 $forced_content = $force; 2263 2419 return $old_forced; … … 2278 2434 */ 2279 2435 function filter_SSL( $url ) { 2280 if ( ! is_string( $url ) ) 2436 if ( ! is_string( $url ) ) { 2281 2437 return get_bloginfo( 'url' ); // Return home blog url with proper scheme 2282 2283 if ( force_ssl_content() && is_ssl() ) 2438 } 2439 2440 if ( force_ssl_content() && is_ssl() ) { 2284 2441 $url = set_url_scheme( $url, 'https' ); 2442 } 2285 2443 2286 2444 return $url; … … 2293 2451 */ 2294 2452 function wp_schedule_update_network_counts() { 2295 if ( ! is_main_site() )2453 if ( ! is_main_site() ) { 2296 2454 return; 2297 2298 if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() ) 2299 wp_schedule_event(time(), 'twicedaily', 'update_network_counts'); 2455 } 2456 2457 if ( ! wp_next_scheduled( 'update_network_counts' ) && ! wp_installing() ) { 2458 wp_schedule_event( time(), 'twicedaily', 'update_network_counts' ); 2459 } 2300 2460 } 2301 2461 … … 2337 2497 * @param string $context Context. Either 'users' or 'sites'. 2338 2498 */ 2339 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) 2499 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) { 2340 2500 return; 2501 } 2341 2502 2342 2503 wp_update_network_site_counts( $network_id ); … … 2358 2519 2359 2520 /** This filter is documented in wp-includes/ms-functions.php */ 2360 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) 2521 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) { 2361 2522 return; 2523 } 2362 2524 2363 2525 wp_update_network_user_counts( $network_id ); … … 2378 2540 } 2379 2541 2380 $count = get_sites( array( 2381 'network_id' => $network_id, 2382 'spam' => 0, 2383 'deleted' => 0, 2384 'archived' => 0, 2385 'count' => true, 2386 ) ); 2542 $count = get_sites( 2543 array( 2544 'network_id' => $network_id, 2545 'spam' => 0, 2546 'deleted' => 0, 2547 'archived' => 0, 2548 'count' => true, 2549 ) 2550 ); 2387 2551 2388 2552 update_network_option( $network_id, 'blog_count', $count ); … … 2440 2604 $space_allowed = get_option( 'blog_upload_space' ); 2441 2605 2442 if ( ! is_numeric( $space_allowed ) ) 2606 if ( ! is_numeric( $space_allowed ) ) { 2443 2607 $space_allowed = get_site_option( 'blog_upload_space' ); 2444 2445 if ( ! is_numeric( $space_allowed ) ) 2608 } 2609 2610 if ( ! is_numeric( $space_allowed ) ) { 2446 2611 $space_allowed = 100; 2612 } 2447 2613 2448 2614 /** … … 2469 2635 } 2470 2636 $space_allowed = $allowed * MB_IN_BYTES; 2471 if ( get_site_option( 'upload_space_check_disabled' ) ) 2637 if ( get_site_option( 'upload_space_check_disabled' ) ) { 2472 2638 return $space_allowed; 2639 } 2473 2640 2474 2641 $space_used = get_space_used() * MB_IN_BYTES; 2475 2642 2476 if ( ( $space_allowed - $space_used ) <= 0 ) 2643 if ( ( $space_allowed - $space_used ) <= 0 ) { 2477 2644 return 0; 2645 } 2478 2646 2479 2647 return $space_allowed - $space_used; … … 2487 2655 */ 2488 2656 function is_upload_space_available() { 2489 if ( get_site_option( 'upload_space_check_disabled' ) ) 2657 if ( get_site_option( 'upload_space_check_disabled' ) ) { 2490 2658 return true; 2659 } 2491 2660 2492 2661 return (bool) get_upload_space_available(); … … 2503 2672 function upload_size_limit_filter( $size ) { 2504 2673 $fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ); 2505 if ( get_site_option( 'upload_space_check_disabled' ) ) 2674 if ( get_site_option( 'upload_space_check_disabled' ) ) { 2506 2675 return min( $size, $fileupload_maxk ); 2676 } 2507 2677 2508 2678 return min( $size, $fileupload_maxk, get_upload_space_available() ); … … 2558 2728 function get_subdirectory_reserved_names() { 2559 2729 $names = array( 2560 'page', 'comments', 'blog', 'files', 'feed', 'wp-admin', 2561 'wp-content', 'wp-includes', 'wp-json', 'embed' 2730 'page', 2731 'comments', 2732 'blog', 2733 'files', 2734 'feed', 2735 'wp-admin', 2736 'wp-content', 2737 'wp-includes', 2738 'wp-json', 2739 'embed', 2562 2740 ); 2563 2741 … … 2589 2767 } 2590 2768 2591 $hash = md5( $value . time() . mt_rand() );2769 $hash = md5( $value . time() . mt_rand() ); 2592 2770 $new_admin_email = array( 2593 2771 'hash' => $hash, … … 2599 2777 2600 2778 /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ 2601 $email_text = __( 'Howdy ###USERNAME###, 2779 $email_text = __( 2780 'Howdy ###USERNAME###, 2602 2781 2603 2782 You recently requested to have the network admin email address on … … 2614 2793 Regards, 2615 2794 All at ###SITENAME### 2616 ###SITEURL###' ); 2795 ###SITEURL###' 2796 ); 2617 2797 2618 2798 /** … … 2639 2819 2640 2820 $current_user = wp_get_current_user(); 2641 $content = str_replace( '###USERNAME###', $current_user->user_login, $content );2642 $content = str_replace( '###ADMIN_URL###', esc_url( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ), $content );2643 $content = str_replace( '###EMAIL###', $value, $content );2644 $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content );2645 $content = str_replace( '###SITEURL###', network_home_url(), $content );2821 $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); 2822 $content = str_replace( '###ADMIN_URL###', esc_url( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ), $content ); 2823 $content = str_replace( '###EMAIL###', $value, $content ); 2824 $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content ); 2825 $content = str_replace( '###SITEURL###', network_home_url(), $content ); 2646 2826 2647 2827 wp_mail( $value, sprintf( __( '[%s] New Network Admin Email Address' ), wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ) ), $content ); … … 2680 2860 2681 2861 /* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */ 2682 $email_change_text = __( 'Hi, 2862 $email_change_text = __( 2863 'Hi, 2683 2864 2684 2865 This notice confirms that the network admin email address was changed on ###SITENAME###. … … 2690 2871 Regards, 2691 2872 All at ###SITENAME### 2692 ###SITEURL###' ); 2873 ###SITEURL###' 2874 ); 2693 2875 2694 2876 $email_change_email = array( … … 2726 2908 $email_change_email = apply_filters( 'network_admin_email_change_email', $email_change_email, $old_email, $new_email, $network_id ); 2727 2909 2728 $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] ); 2729 $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] ); 2730 $email_change_email['message'] = str_replace( '###SITENAME###', $network_name, $email_change_email['message'] ); 2731 $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); 2732 2733 wp_mail( $email_change_email['to'], sprintf( 2734 $email_change_email['subject'], 2735 $network_name 2736 ), $email_change_email['message'], $email_change_email['headers'] ); 2737 } 2910 $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] ); 2911 $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] ); 2912 $email_change_email['message'] = str_replace( '###SITENAME###', $network_name, $email_change_email['message'] ); 2913 $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); 2914 2915 wp_mail( 2916 $email_change_email['to'], sprintf( 2917 $email_change_email['subject'], 2918 $network_name 2919 ), $email_change_email['message'], $email_change_email['headers'] 2920 ); 2921 }
Note: See TracChangeset
for help on using the changeset viewer.