49 } |
47 } |
50 |
48 |
51 /** |
49 /** |
52 * Get one of a user's active blogs |
50 * Get one of a user's active blogs |
53 * |
51 * |
54 * Returns the user's primary blog, if she has one and |
52 * Returns the user's primary blog, if they have one and |
55 * it is active. If it's inactive, function returns another |
53 * it is active. If it's inactive, function returns another |
56 * active blog of the user. If none are found, the user |
54 * active blog of the user. If none are found, the user |
57 * is added as a Subscriber to the Dashboard Blog and that blog |
55 * is added as a Subscriber to the Dashboard Blog and that blog |
58 * is returned. |
56 * is returned. |
59 * |
57 * |
60 * @since MU 1.0 |
58 * @since MU 1.0 |
61 * @uses get_blogs_of_user() |
|
62 * @uses add_user_to_blog() |
|
63 * @uses get_blog_details() |
|
64 * |
59 * |
65 * @param int $user_id The unique ID of the user |
60 * @param int $user_id The unique ID of the user |
66 * @return object The blog object |
61 * @return object The blog object |
67 */ |
62 */ |
68 function get_active_blog_for_user( $user_id ) { |
63 function get_active_blog_for_user( $user_id ) { |
192 update_user_meta($user_id, 'source_domain', $details->domain); |
187 update_user_meta($user_id, 'source_domain', $details->domain); |
193 } |
188 } |
194 |
189 |
195 $user->set_role($role); |
190 $user->set_role($role); |
196 |
191 |
197 do_action('add_user_to_blog', $user_id, $role, $blog_id); |
192 /** |
|
193 * Fires immediately after a user is added to a site. |
|
194 * |
|
195 * @since MU |
|
196 * |
|
197 * @param int $user_id User ID. |
|
198 * @param string $role User role. |
|
199 * @param int $blog_id Blog ID. |
|
200 */ |
|
201 do_action( 'add_user_to_blog', $user_id, $role, $blog_id ); |
198 wp_cache_delete( $user_id, 'users' ); |
202 wp_cache_delete( $user_id, 'users' ); |
199 restore_current_blog(); |
203 restore_current_blog(); |
200 return true; |
204 return true; |
201 } |
205 } |
202 |
206 |
218 */ |
222 */ |
219 function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') { |
223 function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') { |
220 global $wpdb; |
224 global $wpdb; |
221 switch_to_blog($blog_id); |
225 switch_to_blog($blog_id); |
222 $user_id = (int) $user_id; |
226 $user_id = (int) $user_id; |
223 do_action('remove_user_from_blog', $user_id, $blog_id); |
227 /** |
|
228 * Fires before a user is removed from a site. |
|
229 * |
|
230 * @since MU |
|
231 * |
|
232 * @param int $user_id User ID. |
|
233 * @param int $blog_id Blog ID. |
|
234 */ |
|
235 do_action( 'remove_user_from_blog', $user_id, $blog_id ); |
224 |
236 |
225 // If being removed from the primary blog, set a new primary if the user is assigned |
237 // If being removed from the primary blog, set a new primary if the user is assigned |
226 // to multiple blogs. |
238 // to multiple blogs. |
227 $primary_blog = get_user_meta($user_id, 'primary_blog', true); |
239 $primary_blog = get_user_meta($user_id, 'primary_blog', true); |
228 if ( $primary_blog == $blog_id ) { |
240 if ( $primary_blog == $blog_id ) { |
256 update_user_meta($user_id, 'source_domain', ''); |
268 update_user_meta($user_id, 'source_domain', ''); |
257 } |
269 } |
258 |
270 |
259 if ( $reassign != '' ) { |
271 if ( $reassign != '' ) { |
260 $reassign = (int) $reassign; |
272 $reassign = (int) $reassign; |
261 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id) ); |
273 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) ); |
262 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id) ); |
274 $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id ) ); |
|
275 |
|
276 if ( ! empty( $post_ids ) ) { |
|
277 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id ) ); |
|
278 array_walk( $post_ids, 'clean_post_cache' ); |
|
279 } |
|
280 |
|
281 if ( ! empty( $link_ids ) ) { |
|
282 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id ) ); |
|
283 array_walk( $link_ids, 'clean_bookmark_cache' ); |
|
284 } |
263 } |
285 } |
264 |
286 |
265 restore_current_blog(); |
287 restore_current_blog(); |
266 |
288 |
267 return true; |
289 return true; |
399 break; |
420 break; |
400 } |
421 } |
401 } |
422 } |
402 } |
423 } |
403 |
424 |
|
425 /** |
|
426 * Filter whether an email address is unsafe. |
|
427 * |
|
428 * @since 3.5.0 |
|
429 * |
|
430 * @param bool $is_email_address_unsafe Whether the email address is "unsafe". Default false. |
|
431 * @param string $user_email User email address. |
|
432 */ |
404 return apply_filters( 'is_email_address_unsafe', $is_email_address_unsafe, $user_email ); |
433 return apply_filters( 'is_email_address_unsafe', $is_email_address_unsafe, $user_email ); |
405 } |
434 } |
406 |
435 |
407 /** |
436 /** |
408 * Processes new user registrations. |
437 * Sanitize and validate data required for a user sign-up. |
409 * |
438 * |
410 * Checks the data provided by the user during signup. Verifies |
439 * Verifies the validity and uniqueness of user names and user email addresses, |
411 * the validity and uniqueness of user names and user email addresses, |
440 * and checks email addresses against admin-provided domain whitelists and blacklists. |
412 * and checks email addresses against admin-provided domain |
441 * |
413 * whitelists and blacklists. |
442 * The {@see 'wpmu_validate_user_signup'} hook provides an easy way to modify the sign-up |
414 * |
443 * process. The value $result, which is passed to the hook, contains both the user-provided |
415 * The hook 'wpmu_validate_user_signup' provides an easy way |
444 * info and the error messages created by the function. {@see 'wpmu_validate_user_signup'} |
416 * to modify the signup process. The value $result, which is passed |
445 * allows you to process the data in any way you'd like, and unset the relevant errors if |
417 * to the hook, contains both the user-provided info and the error |
446 * necessary. |
418 * messages created by the function. 'wpmu_validate_user_signup' allows |
447 * |
419 * you to process the data in any way you'd like, and unset the |
448 * @since MU |
420 * relevant errors if necessary. |
449 * |
421 * |
450 * @param string $user_name The login name provided by the user. |
422 * @since MU |
|
423 * @uses is_email_address_unsafe() |
|
424 * @uses username_exists() |
|
425 * @uses email_exists() |
|
426 * |
|
427 * @param string $user_name The login name provided by the user. |
|
428 * @param string $user_email The email provided by the user. |
451 * @param string $user_email The email provided by the user. |
429 * @return array Contains username, email, and error messages. |
452 * @return array Contains username, email, and error messages. |
430 */ |
453 */ |
431 function wpmu_validate_user_signup($user_name, $user_email) { |
454 function wpmu_validate_user_signup($user_name, $user_email) { |
432 global $wpdb; |
455 global $wpdb; |
508 $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.')); |
531 $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.')); |
509 } |
532 } |
510 |
533 |
511 $result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors); |
534 $result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors); |
512 |
535 |
513 return apply_filters('wpmu_validate_user_signup', $result); |
536 /** |
|
537 * Filter the validated user registration details. |
|
538 * |
|
539 * This does not allow you to override the username or email of the user during |
|
540 * registration. The values are solely used for validation and error handling. |
|
541 * |
|
542 * @since MU |
|
543 * |
|
544 * @param array $result { |
|
545 * The array of user name, email and the error messages. |
|
546 * |
|
547 * @type string $user_name Sanitized and unique username. |
|
548 * @type string $orig_username Original username. |
|
549 * @type string $user_email User email address. |
|
550 * @type WP_Error $errors WP_Error object containing any errors found. |
|
551 * } |
|
552 */ |
|
553 return apply_filters( 'wpmu_validate_user_signup', $result ); |
514 } |
554 } |
515 |
555 |
516 /** |
556 /** |
517 * Processes new site registrations. |
557 * Processes new site registrations. |
518 * |
558 * |
526 * |
566 * |
527 * Filter 'wpmu_validate_blog_signup' if you want to modify |
567 * Filter 'wpmu_validate_blog_signup' if you want to modify |
528 * the way that WordPress validates new site signups. |
568 * the way that WordPress validates new site signups. |
529 * |
569 * |
530 * @since MU |
570 * @since MU |
531 * @uses domain_exists() |
|
532 * @uses username_exists() |
|
533 * |
571 * |
534 * @param string $blogname The blog name provided by the user. Must be unique. |
572 * @param string $blogname The blog name provided by the user. Must be unique. |
535 * @param string $blog_title The blog title provided by the user. |
573 * @param string $blog_title The blog title provided by the user. |
536 * @return array Contains the new site data and error messages. |
574 * @return array Contains the new site data and error messages. |
537 */ |
575 */ |
538 function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') { |
576 function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { |
539 global $wpdb, $domain, $current_site; |
577 global $wpdb, $domain; |
540 |
578 |
|
579 $current_site = get_current_site(); |
541 $base = $current_site->path; |
580 $base = $current_site->path; |
542 |
581 |
543 $blog_title = strip_tags( $blog_title ); |
582 $blog_title = strip_tags( $blog_title ); |
544 $blog_title = substr( $blog_title, 0, 50 ); |
583 $blog_title = substr( $blog_title, 0, 50 ); |
545 |
584 |
548 if ( $illegal_names == false ) { |
587 if ( $illegal_names == false ) { |
549 $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); |
588 $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); |
550 add_site_option( 'illegal_names', $illegal_names ); |
589 add_site_option( 'illegal_names', $illegal_names ); |
551 } |
590 } |
552 |
591 |
553 // On sub dir installs, Some names are so illegal, only a filter can spring them from jail |
592 /* |
554 if (! is_subdomain_install() ) |
593 * On sub dir installs, some names are so illegal, only a filter can |
555 $illegal_names = array_merge($illegal_names, apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ) ); |
594 * spring them from jail. |
|
595 */ |
|
596 if ( ! is_subdomain_install() ) { |
|
597 $illegal_names = array_merge( |
|
598 $illegal_names, |
|
599 /** |
|
600 * Filter reserved site names on a sub-directory Multisite install. |
|
601 * |
|
602 * @since 3.0.0 |
|
603 * |
|
604 * @param array $subdirectory_reserved_names Array of reserved names. |
|
605 */ |
|
606 apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ) |
|
607 ); |
|
608 } |
556 |
609 |
557 if ( empty( $blogname ) ) |
610 if ( empty( $blogname ) ) |
558 $errors->add('blogname', __( 'Please enter a site name.' ) ); |
611 $errors->add('blogname', __( 'Please enter a site name.' ) ); |
559 |
612 |
560 if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) |
613 if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) |
575 |
628 |
576 // all numeric? |
629 // all numeric? |
577 if ( preg_match( '/^[0-9]*$/', $blogname ) ) |
630 if ( preg_match( '/^[0-9]*$/', $blogname ) ) |
578 $errors->add('blogname', __('Sorry, site names must have letters too!')); |
631 $errors->add('blogname', __('Sorry, site names must have letters too!')); |
579 |
632 |
|
633 /** |
|
634 * Filter the new site name during registration. |
|
635 * |
|
636 * The name is the site's subdomain or the site's subdirectory |
|
637 * path depending on the network settings. |
|
638 * |
|
639 * @since MU |
|
640 * |
|
641 * @param string $blogname Site name. |
|
642 */ |
580 $blogname = apply_filters( 'newblogname', $blogname ); |
643 $blogname = apply_filters( 'newblogname', $blogname ); |
581 |
644 |
582 $blog_title = wp_unslash( $blog_title ); |
645 $blog_title = wp_unslash( $blog_title ); |
583 |
646 |
584 if ( empty( $blog_title ) ) |
647 if ( empty( $blog_title ) ) |
610 else |
673 else |
611 $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); |
674 $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); |
612 } |
675 } |
613 |
676 |
614 $result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'user' => $user, 'errors' => $errors); |
677 $result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'user' => $user, 'errors' => $errors); |
615 return apply_filters('wpmu_validate_blog_signup', $result); |
678 |
|
679 /** |
|
680 * Filter site details and error messages following registration. |
|
681 * |
|
682 * @since MU |
|
683 * |
|
684 * @param array $result { |
|
685 * Array of domain, path, blog name, blog title, user and error messages. |
|
686 * |
|
687 * @type string $domain Domain for the site. |
|
688 * @type string $path Path for the site. Used in subdirectory installs. |
|
689 * @type string $blogname The unique site name (slug). |
|
690 * @type string $blog_title Blog title. |
|
691 * @type string $user User email address. |
|
692 * @type WP_Error $errors WP_Error containing any errors found. |
|
693 * } |
|
694 */ |
|
695 return apply_filters( 'wpmu_validate_blog_signup', $result ); |
616 } |
696 } |
617 |
697 |
618 /** |
698 /** |
619 * Record site signup information for future activation. |
699 * Record site signup information for future activation. |
620 * |
700 * |
621 * @since MU |
701 * @since MU |
622 * @uses wpmu_signup_blog_notification() |
|
623 * |
702 * |
624 * @param string $domain The requested domain. |
703 * @param string $domain The requested domain. |
625 * @param string $path The requested path. |
704 * @param string $path The requested path. |
626 * @param string $title The requested site title. |
705 * @param string $title The requested site title. |
627 * @param string $user The user's requested login name. |
706 * @param string $user The user's requested login name. |
707 * @param string $key The activation key created in wpmu_signup_blog() |
785 * @param string $key The activation key created in wpmu_signup_blog() |
708 * @param array $meta By default, contains the requested privacy setting and lang_id. |
786 * @param array $meta By default, contains the requested privacy setting and lang_id. |
709 * @return bool |
787 * @return bool |
710 */ |
788 */ |
711 function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta = array() ) { |
789 function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta = array() ) { |
712 global $current_site; |
790 /** |
713 |
791 * Filter whether to bypass the new site email notification. |
714 if ( !apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta) ) |
792 * |
|
793 * @since MU |
|
794 * |
|
795 * @param string|bool $domain Site domain. |
|
796 * @param string $path Site path. |
|
797 * @param string $title Site title. |
|
798 * @param string $user User login name. |
|
799 * @param string $user_email User email address. |
|
800 * @param string $key Activation key created in wpmu_signup_blog(). |
|
801 * @param array $meta By default, contains the requested privacy setting and lang_id. |
|
802 */ |
|
803 if ( ! apply_filters( 'wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta ) ) { |
715 return false; |
804 return false; |
|
805 } |
716 |
806 |
717 // Send email with activation link. |
807 // Send email with activation link. |
718 if ( !is_subdomain_install() || $current_site->id != 1 ) |
808 if ( !is_subdomain_install() || get_current_site()->id != 1 ) |
719 $activate_url = network_site_url("wp-activate.php?key=$key"); |
809 $activate_url = network_site_url("wp-activate.php?key=$key"); |
720 else |
810 else |
721 $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API |
811 $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API |
722 |
812 |
723 $activate_url = esc_url($activate_url); |
813 $activate_url = esc_url($activate_url); |
725 if ( $admin_email == '' ) |
815 if ( $admin_email == '' ) |
726 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
816 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
727 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
817 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
728 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
818 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
729 $message = sprintf( |
819 $message = sprintf( |
|
820 /** |
|
821 * Filter the message content of the new blog notification email. |
|
822 * |
|
823 * Content should be formatted for transmission via wp_mail(). |
|
824 * |
|
825 * @since MU |
|
826 * |
|
827 * @param string $content Content of the notification email. |
|
828 * @param string $domain Site domain. |
|
829 * @param string $path Site path. |
|
830 * @param string $title Site title. |
|
831 * @param string $user User login name. |
|
832 * @param string $user_email User email address. |
|
833 * @param string $key Activation key created in wpmu_signup_blog(). |
|
834 * @param array $meta By default, contains the requested privacy setting and lang_id. |
|
835 */ |
730 apply_filters( 'wpmu_signup_blog_notification_email', |
836 apply_filters( 'wpmu_signup_blog_notification_email', |
731 __( "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" ), |
837 __( "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" ), |
732 $domain, $path, $title, $user, $user_email, $key, $meta |
838 $domain, $path, $title, $user, $user_email, $key, $meta |
733 ), |
839 ), |
734 $activate_url, |
840 $activate_url, |
735 esc_url( "http://{$domain}{$path}" ), |
841 esc_url( "http://{$domain}{$path}" ), |
736 $key |
842 $key |
737 ); |
843 ); |
738 // TODO: Don't hard code activation link. |
844 // TODO: Don't hard code activation link. |
739 $subject = sprintf( |
845 $subject = sprintf( |
|
846 /** |
|
847 * Filter the subject of the new blog notification email. |
|
848 * |
|
849 * @since MU |
|
850 * |
|
851 * @param string $subject Subject of the notification email. |
|
852 * @param string $domain Site domain. |
|
853 * @param string $path Site path. |
|
854 * @param string $title Site title. |
|
855 * @param string $user User login name. |
|
856 * @param string $user_email User email address. |
|
857 * @param string $key Activation key created in wpmu_signup_blog(). |
|
858 * @param array $meta By default, contains the requested privacy setting and lang_id. |
|
859 */ |
740 apply_filters( 'wpmu_signup_blog_notification_subject', |
860 apply_filters( 'wpmu_signup_blog_notification_subject', |
741 __( '[%1$s] Activate %2$s' ), |
861 __( '[%1$s] Activate %2$s' ), |
742 $domain, $path, $title, $user, $user_email, $key, $meta |
862 $domain, $path, $title, $user, $user_email, $key, $meta |
743 ), |
863 ), |
744 $from_name, |
864 $from_name, |
745 esc_url( 'http://' . $domain . $path ) |
865 esc_url( 'http://' . $domain . $path ) |
746 ); |
866 ); |
747 wp_mail($user_email, $subject, $message, $message_headers); |
867 wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); |
748 return true; |
868 return true; |
749 } |
869 } |
750 |
870 |
751 /** |
871 /** |
752 * Notify user of signup success. |
872 * Notify user of signup success. |
768 * @param string $key The activation key created in wpmu_signup_user() |
888 * @param string $key The activation key created in wpmu_signup_user() |
769 * @param array $meta By default, an empty array. |
889 * @param array $meta By default, an empty array. |
770 * @return bool |
890 * @return bool |
771 */ |
891 */ |
772 function wpmu_signup_user_notification( $user, $user_email, $key, $meta = array() ) { |
892 function wpmu_signup_user_notification( $user, $user_email, $key, $meta = array() ) { |
773 if ( !apply_filters('wpmu_signup_user_notification', $user, $user_email, $key, $meta) ) |
893 /** |
|
894 * Filter whether to bypass the email notification for new user sign-up. |
|
895 * |
|
896 * @since MU |
|
897 * |
|
898 * @param string $user User login name. |
|
899 * @param string $user_email User email address. |
|
900 * @param string $key Activation key created in wpmu_signup_user(). |
|
901 * @param array $meta Signup meta data. |
|
902 */ |
|
903 if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) ) |
774 return false; |
904 return false; |
775 |
905 |
776 // Send email with activation link. |
906 // Send email with activation link. |
777 $admin_email = get_site_option( 'admin_email' ); |
907 $admin_email = get_site_option( 'admin_email' ); |
778 if ( $admin_email == '' ) |
908 if ( $admin_email == '' ) |
779 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
909 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
780 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
910 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); |
781 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
911 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; |
782 $message = sprintf( |
912 $message = sprintf( |
|
913 /** |
|
914 * Filter the content of the notification email for new user sign-up. |
|
915 * |
|
916 * Content should be formatted for transmission via wp_mail(). |
|
917 * |
|
918 * @since MU |
|
919 * |
|
920 * @param string $content Content of the notification email. |
|
921 * @param string $user User login name. |
|
922 * @param string $user_email User email address. |
|
923 * @param string $key Activation key created in wpmu_signup_user(). |
|
924 * @param array $meta Signup meta data. |
|
925 */ |
783 apply_filters( 'wpmu_signup_user_notification_email', |
926 apply_filters( 'wpmu_signup_user_notification_email', |
784 __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ), |
927 __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ), |
785 $user, $user_email, $key, $meta |
928 $user, $user_email, $key, $meta |
786 ), |
929 ), |
787 site_url( "wp-activate.php?key=$key" ) |
930 site_url( "wp-activate.php?key=$key" ) |
788 ); |
931 ); |
789 // TODO: Don't hard code activation link. |
932 // TODO: Don't hard code activation link. |
790 $subject = sprintf( |
933 $subject = sprintf( |
|
934 /** |
|
935 * Filter the subject of the notification email of new user signup. |
|
936 * |
|
937 * @since MU |
|
938 * |
|
939 * @param string $subject Subject of the notification email. |
|
940 * @param string $user User login name. |
|
941 * @param string $user_email User email address. |
|
942 * @param string $key Activation key created in wpmu_signup_user(). |
|
943 * @param array $meta Signup meta data. |
|
944 */ |
791 apply_filters( 'wpmu_signup_user_notification_subject', |
945 apply_filters( 'wpmu_signup_user_notification_subject', |
792 __( '[%1$s] Activate %2$s' ), |
946 __( '[%1$s] Activate %2$s' ), |
793 $user, $user_email, $key, $meta |
947 $user, $user_email, $key, $meta |
794 ), |
948 ), |
795 $from_name, |
949 $from_name, |
796 $user |
950 $user |
797 ); |
951 ); |
798 wp_mail($user_email, $subject, $message, $message_headers); |
952 wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); |
799 return true; |
953 return true; |
800 } |
954 } |
801 |
955 |
802 /** |
956 /** |
803 * Activate a signup. |
957 * Activate a signup. |
806 * that should happen only when users or sites are self-created (since |
960 * that should happen only when users or sites are self-created (since |
807 * those actions are not called when users and sites are created |
961 * those actions are not called when users and sites are created |
808 * by a Super Admin). |
962 * by a Super Admin). |
809 * |
963 * |
810 * @since MU |
964 * @since MU |
811 * @uses wp_generate_password() |
|
812 * @uses wpmu_welcome_user_notification() |
|
813 * @uses add_user_to_blog() |
|
814 * @uses wpmu_create_user() |
|
815 * @uses wpmu_create_blog() |
|
816 * @uses wpmu_welcome_notification() |
|
817 * |
965 * |
818 * @param string $key The activation key provided to the user. |
966 * @param string $key The activation key provided to the user. |
819 * @return array An array containing information about the activated user and/or blog |
967 * @return array An array containing information about the activated user and/or blog |
820 */ |
968 */ |
821 function wpmu_activate_signup($key) { |
969 function wpmu_activate_signup($key) { |
853 |
1001 |
854 if ( isset( $user_already_exists ) ) |
1002 if ( isset( $user_already_exists ) ) |
855 return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup); |
1003 return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup); |
856 |
1004 |
857 wpmu_welcome_user_notification( $user_id, $password, $meta ); |
1005 wpmu_welcome_user_notification( $user_id, $password, $meta ); |
|
1006 /** |
|
1007 * Fires immediately after a new user is activated. |
|
1008 * |
|
1009 * @since MU |
|
1010 * |
|
1011 * @param int $user_id User ID. |
|
1012 * @param int $password User password. |
|
1013 * @param array $meta Signup meta data. |
|
1014 */ |
858 do_action( 'wpmu_activate_user', $user_id, $password, $meta ); |
1015 do_action( 'wpmu_activate_user', $user_id, $password, $meta ); |
859 return array( 'user_id' => $user_id, 'password' => $password, 'meta' => $meta ); |
1016 return array( 'user_id' => $user_id, 'password' => $password, 'meta' => $meta ); |
860 } |
1017 } |
861 |
1018 |
862 $blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid ); |
1019 $blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid ); |
872 return $blog_id; |
1029 return $blog_id; |
873 } |
1030 } |
874 |
1031 |
875 $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) ); |
1032 $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) ); |
876 wpmu_welcome_notification($blog_id, $user_id, $password, $signup->title, $meta); |
1033 wpmu_welcome_notification($blog_id, $user_id, $password, $signup->title, $meta); |
877 do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta); |
1034 /** |
|
1035 * Fires immediately after a site is activated. |
|
1036 * |
|
1037 * @since MU |
|
1038 * |
|
1039 * @param int $blog_id Blog ID. |
|
1040 * @param int $user_id User ID. |
|
1041 * @param int $password User password. |
|
1042 * @param string $signup_title Site title. |
|
1043 * @param array $meta Signup meta data. |
|
1044 */ |
|
1045 do_action( 'wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta ); |
878 |
1046 |
879 return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta); |
1047 return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta); |
880 } |
1048 } |
881 |
1049 |
882 /** |
1050 /** |
886 * a Super Admin creates a new user. Hook to 'wpmu_new_user' for events |
1054 * a Super Admin creates a new user. Hook to 'wpmu_new_user' for events |
887 * that should affect all new users, but only on Multisite (otherwise |
1055 * that should affect all new users, but only on Multisite (otherwise |
888 * use 'user_register'). |
1056 * use 'user_register'). |
889 * |
1057 * |
890 * @since MU |
1058 * @since MU |
891 * @uses wp_create_user() |
|
892 * |
1059 * |
893 * @param string $user_name The new user's login name. |
1060 * @param string $user_name The new user's login name. |
894 * @param string $password The new user's password. |
1061 * @param string $password The new user's password. |
895 * @param string $email The new user's email address. |
1062 * @param string $email The new user's email address. |
896 * @return mixed Returns false on failure, or int $user_id on success |
1063 * @return int|bool Returns false on failure, or int $user_id on success |
897 */ |
1064 */ |
898 function wpmu_create_user( $user_name, $password, $email ) { |
1065 function wpmu_create_user( $user_name, $password, $email ) { |
899 $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); |
1066 $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); |
900 |
1067 |
901 $user_id = wp_create_user( $user_name, $password, $email ); |
1068 $user_id = wp_create_user( $user_name, $password, $email ); |
922 * domain, and the path is the subdirectory name (eg 'example.com' |
1096 * domain, and the path is the subdirectory name (eg 'example.com' |
923 * and '/blog1/'). On subdomain installs, $domain is the new subdomain + |
1097 * and '/blog1/'). On subdomain installs, $domain is the new subdomain + |
924 * root domain (eg 'blog1.example.com'), and $path is '/'. |
1098 * root domain (eg 'blog1.example.com'), and $path is '/'. |
925 * |
1099 * |
926 * @since MU |
1100 * @since MU |
927 * @uses domain_exists() |
|
928 * @uses insert_blog() |
|
929 * @uses wp_install_defaults() |
|
930 * @uses add_user_to_blog() |
|
931 * |
1101 * |
932 * @param string $domain The new site's domain. |
1102 * @param string $domain The new site's domain. |
933 * @param string $path The new site's path. |
1103 * @param string $path The new site's path. |
934 * @param string $title The new site's title. |
1104 * @param string $title The new site's title. |
935 * @param int $user_id The user ID of the new site's admin. |
1105 * @param int $user_id The user ID of the new site's admin. |
980 |
1150 |
981 if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) |
1151 if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) |
982 update_user_meta( $user_id, 'primary_blog', $blog_id ); |
1152 update_user_meta( $user_id, 'primary_blog', $blog_id ); |
983 |
1153 |
984 restore_current_blog(); |
1154 restore_current_blog(); |
|
1155 /** |
|
1156 * Fires immediately after a new site is created. |
|
1157 * |
|
1158 * @since MU |
|
1159 * |
|
1160 * @param int $blog_id Blog ID. |
|
1161 * @param int $user_id User ID. |
|
1162 * @param string $domain Site domain. |
|
1163 * @param string $path Site path. |
|
1164 * @param int $site_id Site ID. Only relevant on multi-network installs. |
|
1165 * @param array $meta Meta data. Used to set initial site options. |
|
1166 */ |
985 do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta ); |
1167 do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta ); |
986 |
1168 |
987 return $blog_id; |
1169 return $blog_id; |
988 } |
1170 } |
989 |
1171 |
1016 $msg = sprintf( __( 'New Site: %1$s |
1198 $msg = sprintf( __( 'New Site: %1$s |
1017 URL: %2$s |
1199 URL: %2$s |
1018 Remote IP: %3$s |
1200 Remote IP: %3$s |
1019 |
1201 |
1020 Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url); |
1202 Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url); |
|
1203 /** |
|
1204 * Filter the message body of the new site activation email sent |
|
1205 * to the network administrator. |
|
1206 * |
|
1207 * @since MU |
|
1208 * |
|
1209 * @param string $msg Email body. |
|
1210 */ |
1021 $msg = apply_filters( 'newblog_notify_siteadmin', $msg ); |
1211 $msg = apply_filters( 'newblog_notify_siteadmin', $msg ); |
1022 |
1212 |
1023 wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg ); |
1213 wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg ); |
1024 return true; |
1214 return true; |
1025 } |
1215 } |
1051 $msg = sprintf(__('New User: %1$s |
1240 $msg = sprintf(__('New User: %1$s |
1052 Remote IP: %2$s |
1241 Remote IP: %2$s |
1053 |
1242 |
1054 Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url); |
1243 Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url); |
1055 |
1244 |
|
1245 /** |
|
1246 * Filter the message body of the new user activation email sent |
|
1247 * to the network administrator. |
|
1248 * |
|
1249 * @since MU |
|
1250 * |
|
1251 * @param string $msg Email body. |
|
1252 * @param WP_User $user WP_User instance of the new user. |
|
1253 */ |
1056 $msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user ); |
1254 $msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user ); |
1057 wp_mail( $email, sprintf(__('New User Registration: %s'), $user->user_login), $msg ); |
1255 wp_mail( $email, sprintf(__('New User Registration: %s'), $user->user_login), $msg ); |
1058 return true; |
1256 return true; |
1059 } |
1257 } |
1060 |
1258 |
1071 * @param int $site_id Optional. Relevant only on multi-network installs. |
1269 * @param int $site_id Optional. Relevant only on multi-network installs. |
1072 * @return int |
1270 * @return int |
1073 */ |
1271 */ |
1074 function domain_exists($domain, $path, $site_id = 1) { |
1272 function domain_exists($domain, $path, $site_id = 1) { |
1075 global $wpdb; |
1273 global $wpdb; |
|
1274 $path = trailingslashit( $path ); |
1076 $result = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s AND site_id = %d", $domain, $path, $site_id) ); |
1275 $result = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s AND site_id = %d", $domain, $path, $site_id) ); |
|
1276 |
|
1277 /** |
|
1278 * Filter whether a blogname is taken. |
|
1279 * |
|
1280 * @since 3.5.0 |
|
1281 * |
|
1282 * @param int|null $result The blog_id if the blogname exists, null otherwise. |
|
1283 * @param string $domain Domain to be checked. |
|
1284 * @param string $path Path to be checked. |
|
1285 * @param int $site_id Site ID. Relevant only on multi-network installs. |
|
1286 */ |
1077 return apply_filters( 'domain_exists', $result, $domain, $path, $site_id ); |
1287 return apply_filters( 'domain_exists', $result, $domain, $path, $site_id ); |
1078 } |
1288 } |
1079 |
1289 |
1080 /** |
1290 /** |
1081 * Store basic site info in the blogs table. |
1291 * Store basic site info in the blogs table. |
1114 * Creates the new blog tables and options. If calling this function |
1324 * Creates the new blog tables and options. If calling this function |
1115 * directly, be sure to use switch_to_blog() first, so that $wpdb |
1325 * directly, be sure to use switch_to_blog() first, so that $wpdb |
1116 * points to the new blog. |
1326 * points to the new blog. |
1117 * |
1327 * |
1118 * @since MU |
1328 * @since MU |
1119 * @uses make_db_current_silent() |
|
1120 * @uses populate_roles() |
|
1121 * |
1329 * |
1122 * @param int $blog_id The value returned by insert_blog(). |
1330 * @param int $blog_id The value returned by insert_blog(). |
1123 * @param string $blog_title The title of the new site. |
1331 * @param string $blog_title The title of the new site. |
1124 */ |
1332 */ |
1125 function install_blog($blog_id, $blog_title = '') { |
1333 function install_blog( $blog_id, $blog_title = '' ) { |
1126 global $wpdb, $wp_roles, $current_site; |
1334 global $wpdb, $wp_roles; |
1127 |
1335 |
1128 // Cast for security |
1336 // Cast for security |
1129 $blog_id = (int) $blog_id; |
1337 $blog_id = (int) $blog_id; |
1130 |
1338 |
1131 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
1339 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
1132 |
1340 |
1133 $wpdb->suppress_errors(); |
1341 $suppress = $wpdb->suppress_errors(); |
1134 if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) |
1342 if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) |
1135 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>' ); |
1343 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>' ); |
1136 $wpdb->suppress_errors( false ); |
1344 $wpdb->suppress_errors( $suppress ); |
1137 |
1345 |
1138 $url = get_blogaddress_by_id( $blog_id ); |
1346 $url = get_blogaddress_by_id( $blog_id ); |
1139 |
1347 |
1140 // Set everything up |
1348 // Set everything up |
1141 make_db_current_silent( 'blog' ); |
1349 make_db_current_silent( 'blog' ); |
1142 populate_options(); |
1350 populate_options(); |
1143 populate_roles(); |
1351 populate_roles(); |
1144 $wp_roles->_init(); |
1352 |
|
1353 // populate_roles() clears previous role definitions so we start over. |
|
1354 $wp_roles = new WP_Roles(); |
1145 |
1355 |
1146 $url = untrailingslashit( $url ); |
1356 $url = untrailingslashit( $url ); |
1147 |
1357 |
1148 update_option( 'siteurl', $url ); |
1358 update_option( 'siteurl', $url ); |
1149 update_option( 'home', $url ); |
1359 update_option( 'home', $url ); |
1150 |
1360 |
1151 if ( get_site_option( 'ms_files_rewriting' ) ) |
1361 if ( get_site_option( 'ms_files_rewriting' ) ) |
1152 update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" ); |
1362 update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" ); |
1153 else |
1363 else |
1154 update_option( 'upload_path', get_blog_option( $current_site->blog_id, 'upload_path' ) ); |
1364 update_option( 'upload_path', get_blog_option( get_current_site()->blog_id, 'upload_path' ) ); |
1155 |
1365 |
1156 update_option( 'blogname', wp_unslash( $blog_title ) ); |
1366 update_option( 'blogname', wp_unslash( $blog_title ) ); |
1157 update_option( 'admin_email', '' ); |
1367 update_option( 'admin_email', '' ); |
1158 |
1368 |
1159 // remove all perms |
1369 // remove all perms |
1168 * This function creates a row in the wp_blogs table. |
1378 * This function creates a row in the wp_blogs table. |
1169 * |
1379 * |
1170 * @since MU |
1380 * @since MU |
1171 * @deprecated MU |
1381 * @deprecated MU |
1172 * @deprecated Use wp_install_defaults() |
1382 * @deprecated Use wp_install_defaults() |
1173 * @uses wp_install_defaults() |
|
1174 * |
1383 * |
1175 * @param int $blog_id Ignored in this function. |
1384 * @param int $blog_id Ignored in this function. |
1176 * @param int $user_id |
1385 * @param int $user_id |
1177 */ |
1386 */ |
1178 function install_blog_defaults($blog_id, $user_id) { |
1387 function install_blog_defaults($blog_id, $user_id) { |
1179 global $wpdb; |
1388 global $wpdb; |
1180 |
1389 |
1181 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
1390 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
1182 |
1391 |
1183 $wpdb->suppress_errors(); |
1392 $suppress = $wpdb->suppress_errors(); |
1184 |
1393 |
1185 wp_install_defaults($user_id); |
1394 wp_install_defaults($user_id); |
1186 |
1395 |
1187 $wpdb->suppress_errors( false ); |
1396 $wpdb->suppress_errors( $suppress ); |
1188 } |
1397 } |
1189 |
1398 |
1190 /** |
1399 /** |
1191 * Notify a user that her blog activation has been successful. |
1400 * Notify a user that their blog activation has been successful. |
1192 * |
1401 * |
1193 * Filter 'wpmu_welcome_notification' to disable or bypass. |
1402 * Filter 'wpmu_welcome_notification' to disable or bypass. |
1194 * |
1403 * |
1195 * Filter 'update_welcome_email' and 'update_welcome_subject' to |
1404 * Filter 'update_welcome_email' and 'update_welcome_subject' to |
1196 * modify the content and subject line of the notification email. |
1405 * modify the content and subject line of the notification email. |
1203 * @param string $title The new blog's title |
1412 * @param string $title The new blog's title |
1204 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. |
1413 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. |
1205 * @return bool |
1414 * @return bool |
1206 */ |
1415 */ |
1207 function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) { |
1416 function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) { |
1208 global $current_site; |
1417 $current_site = get_current_site(); |
1209 |
1418 |
1210 if ( !apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta) ) |
1419 /** |
|
1420 * Filter whether to bypass the welcome email after site activation. |
|
1421 * |
|
1422 * Returning false disables the welcome email. |
|
1423 * |
|
1424 * @since MU |
|
1425 * |
|
1426 * @param int|bool $blog_id Blog ID. |
|
1427 * @param int $user_id User ID. |
|
1428 * @param string $password User password. |
|
1429 * @param string $title Site title. |
|
1430 * @param array $meta Signup meta data. |
|
1431 */ |
|
1432 if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) |
1211 return false; |
1433 return false; |
1212 |
1434 |
1213 $welcome_email = get_site_option( 'welcome_email' ); |
1435 $welcome_email = get_site_option( 'welcome_email' ); |
1214 if ( $welcome_email == false ) |
1436 if ( $welcome_email == false ) |
1215 $welcome_email = __( 'Dear User, |
1437 $welcome_email = __( 'Howdy USERNAME, |
1216 |
1438 |
1217 Your new SITE_NAME site has been successfully set up at: |
1439 Your new SITE_NAME site has been successfully set up at: |
1218 BLOG_URL |
1440 BLOG_URL |
1219 |
1441 |
1220 You can log in to the administrator account with the following information: |
1442 You can log in to the administrator account with the following information: |
|
1443 |
1221 Username: USERNAME |
1444 Username: USERNAME |
1222 Password: PASSWORD |
1445 Password: PASSWORD |
1223 Log in here: BLOG_URLwp-login.php |
1446 Log in here: BLOG_URLwp-login.php |
1224 |
1447 |
1225 We hope you enjoy your new site. Thanks! |
1448 We hope you enjoy your new site. Thanks! |
1233 $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email ); |
1456 $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email ); |
1234 $welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email ); |
1457 $welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email ); |
1235 $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); |
1458 $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); |
1236 $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); |
1459 $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); |
1237 |
1460 |
1238 $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta); |
1461 /** |
|
1462 * Filter the content of the welcome email after site activation. |
|
1463 * |
|
1464 * Content should be formatted for transmission via wp_mail(). |
|
1465 * |
|
1466 * @since MU |
|
1467 * |
|
1468 * @param string $welcome_email Message body of the email. |
|
1469 * @param int $blog_id Blog ID. |
|
1470 * @param int $user_id User ID. |
|
1471 * @param string $password User password. |
|
1472 * @param string $title Site title. |
|
1473 * @param array $meta Signup meta data. |
|
1474 */ |
|
1475 $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta ); |
1239 $admin_email = get_site_option( 'admin_email' ); |
1476 $admin_email = get_site_option( 'admin_email' ); |
1240 |
1477 |
1241 if ( $admin_email == '' ) |
1478 if ( $admin_email == '' ) |
1242 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
1479 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; |
1243 |
1480 |
1246 $message = $welcome_email; |
1483 $message = $welcome_email; |
1247 |
1484 |
1248 if ( empty( $current_site->site_name ) ) |
1485 if ( empty( $current_site->site_name ) ) |
1249 $current_site->site_name = 'WordPress'; |
1486 $current_site->site_name = 'WordPress'; |
1250 |
1487 |
1251 $subject = apply_filters( 'update_welcome_subject', sprintf(__('New %1$s Site: %2$s'), $current_site->site_name, wp_unslash( $title ) ) ); |
1488 /** |
1252 wp_mail($user->user_email, $subject, $message, $message_headers); |
1489 * Filter the subject of the welcome email after site activation. |
|
1490 * |
|
1491 * @since MU |
|
1492 * |
|
1493 * @param string $subject Subject of the email. |
|
1494 */ |
|
1495 $subject = apply_filters( 'update_welcome_subject', sprintf( __( 'New %1$s Site: %2$s' ), $current_site->site_name, wp_unslash( $title ) ) ); |
|
1496 wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); |
1253 return true; |
1497 return true; |
1254 } |
1498 } |
1255 |
1499 |
1256 /** |
1500 /** |
1257 * Notify a user that her account activation has been successful. |
1501 * Notify a user that their account activation has been successful. |
1258 * |
1502 * |
1259 * Filter 'wpmu_welcome_user_notification' to disable or bypass. |
1503 * Filter 'wpmu_welcome_user_notification' to disable or bypass. |
1260 * |
1504 * |
1261 * Filter 'update_welcome_user_email' and 'update_welcome_user_subject' to |
1505 * Filter 'update_welcome_user_email' and 'update_welcome_user_subject' to |
1262 * modify the content and subject line of the notification email. |
1506 * modify the content and subject line of the notification email. |
1267 * @param string $password |
1511 * @param string $password |
1268 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. |
1512 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. |
1269 * @return bool |
1513 * @return bool |
1270 */ |
1514 */ |
1271 function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) { |
1515 function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) { |
1272 global $current_site; |
1516 $current_site = get_current_site(); |
1273 |
1517 |
1274 if ( !apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta) ) |
1518 /** |
|
1519 * Filter whether to bypass the welcome email after user activation. |
|
1520 * |
|
1521 * Returning false disables the welcome email. |
|
1522 * |
|
1523 * @since MU |
|
1524 * |
|
1525 * @param int $user_id User ID. |
|
1526 * @param string $password User password. |
|
1527 * @param array $meta Signup meta data. |
|
1528 */ |
|
1529 if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) |
1275 return false; |
1530 return false; |
1276 |
1531 |
1277 $welcome_email = get_site_option( 'welcome_user_email' ); |
1532 $welcome_email = get_site_option( 'welcome_user_email' ); |
1278 |
1533 |
1279 $user = get_userdata( $user_id ); |
1534 $user = get_userdata( $user_id ); |
1280 |
1535 |
1281 $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta); |
1536 /** |
|
1537 * Filter the content of the welcome email after user activation. |
|
1538 * |
|
1539 * Content should be formatted for transmission via wp_mail(). |
|
1540 * |
|
1541 * @since MU |
|
1542 * |
|
1543 * @param type $welcome_email The message body of the account activation success email. |
|
1544 * @param int $user_id User ID. |
|
1545 * @param string $password User password. |
|
1546 * @param array $meta Signup meta data. |
|
1547 */ |
|
1548 $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta ); |
1282 $welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email ); |
1549 $welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email ); |
1283 $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); |
1550 $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); |
1284 $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); |
1551 $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); |
1285 $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email ); |
1552 $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email ); |
1286 |
1553 |
1294 $message = $welcome_email; |
1561 $message = $welcome_email; |
1295 |
1562 |
1296 if ( empty( $current_site->site_name ) ) |
1563 if ( empty( $current_site->site_name ) ) |
1297 $current_site->site_name = 'WordPress'; |
1564 $current_site->site_name = 'WordPress'; |
1298 |
1565 |
1299 $subject = apply_filters( 'update_welcome_user_subject', sprintf(__('New %1$s User: %2$s'), $current_site->site_name, $user->user_login) ); |
1566 /** |
1300 wp_mail($user->user_email, $subject, $message, $message_headers); |
1567 * Filter the subject of the welcome email after user activation. |
|
1568 * |
|
1569 * @since MU |
|
1570 * |
|
1571 * @param string $subject Subject of the email. |
|
1572 */ |
|
1573 $subject = apply_filters( 'update_welcome_user_subject', sprintf( __( 'New %1$s User: %2$s' ), $current_site->site_name, $user->user_login) ); |
|
1574 wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); |
1301 return true; |
1575 return true; |
1302 } |
1576 } |
1303 |
1577 |
1304 /** |
1578 /** |
1305 * Get the current site info. |
1579 * Get the current site info. |
1441 * |
1713 * |
1442 * @param array $mimes |
1714 * @param array $mimes |
1443 * @return array |
1715 * @return array |
1444 */ |
1716 */ |
1445 function check_upload_mimes( $mimes ) { |
1717 function check_upload_mimes( $mimes ) { |
1446 $site_exts = explode( ' ', get_site_option( 'upload_filetypes' ) ); |
1718 $site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) ); |
|
1719 $site_mimes = array(); |
1447 foreach ( $site_exts as $ext ) { |
1720 foreach ( $site_exts as $ext ) { |
1448 foreach ( $mimes as $ext_pattern => $mime ) { |
1721 foreach ( $mimes as $ext_pattern => $mime ) { |
1449 if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) |
1722 if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) |
1450 $site_mimes[$ext_pattern] = $mime; |
1723 $site_mimes[$ext_pattern] = $mime; |
1451 } |
1724 } |
1526 $new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 ); |
1799 $new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 ); |
1527 $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); |
1800 $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); |
1528 $global_id = $wpdb->insert_id; |
1801 $global_id = $wpdb->insert_id; |
1529 } |
1802 } |
1530 } elseif ( $global_id != $term_id ) { |
1803 } elseif ( $global_id != $term_id ) { |
1531 $local_id = $wpdb->get_row( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) ); |
1804 $local_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) ); |
1532 if ( null != $local_id ) |
1805 if ( null != $local_id ) { |
1533 $local_id = global_terms( $local_id ); |
1806 global_terms( $local_id ); |
1534 if ( 10 < $global_terms_recurse ) |
1807 if ( 10 < $global_terms_recurse ) { |
1535 $global_id = $term_id; |
1808 $global_id = $term_id; |
|
1809 } |
|
1810 } |
1536 } |
1811 } |
1537 |
1812 |
1538 if ( $global_id != $term_id ) { |
1813 if ( $global_id != $term_id ) { |
1539 if ( get_option( 'default_category' ) == $term_id ) |
1814 if ( get_option( 'default_category' ) == $term_id ) |
1540 update_option( 'default_category', $global_id ); |
1815 update_option( 'default_category', $global_id ); |
1617 * Correct 404 redirects when NOBLOGREDIRECT is defined. |
1889 * Correct 404 redirects when NOBLOGREDIRECT is defined. |
1618 * |
1890 * |
1619 * @since MU |
1891 * @since MU |
1620 */ |
1892 */ |
1621 function maybe_redirect_404() { |
1893 function maybe_redirect_404() { |
|
1894 /** |
|
1895 * Filter the redirect URL for 404s on the main site. |
|
1896 * |
|
1897 * The filter is only evaluated if the NOBLOGREDIRECT constant is defined. |
|
1898 * |
|
1899 * @since 3.0.0 |
|
1900 * |
|
1901 * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT. |
|
1902 */ |
1622 if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) { |
1903 if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) { |
1623 if ( $destination == '%siteurl%' ) |
1904 if ( $destination == '%siteurl%' ) |
1624 $destination = network_home_url(); |
1905 $destination = network_home_url(); |
1625 wp_redirect( $destination ); |
1906 wp_redirect( $destination ); |
1626 exit(); |
1907 exit(); |
1652 delete_option( 'new_user_' . $key ); |
1932 delete_option( 'new_user_' . $key ); |
1653 |
1933 |
1654 if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) |
1934 if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) |
1655 wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) ); |
1935 wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) ); |
1656 |
1936 |
1657 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' ) ); |
1937 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 ) ); |
1658 } |
1938 } |
1659 |
1939 |
1660 /** |
1940 /** |
1661 * Add a user to a blog based on details from maybe_add_existing_user_to_blog(). |
1941 * Add a user to a blog based on details from maybe_add_existing_user_to_blog(). |
1662 * |
1942 * |
1663 * @since MU |
1943 * @since MU |
1664 * @uses add_user_to_blog() |
|
1665 * |
1944 * |
1666 * @param array $details |
1945 * @param array $details |
1667 */ |
1946 */ |
1668 function add_existing_user_to_blog( $details = false ) { |
1947 function add_existing_user_to_blog( $details = false ) { |
1669 global $blog_id; |
1948 global $blog_id; |
1670 |
1949 |
1671 if ( is_array( $details ) ) { |
1950 if ( is_array( $details ) ) { |
1672 $result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] ); |
1951 $result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] ); |
1673 do_action( 'added_existing_user', $details[ 'user_id' ], $result ); |
1952 /** |
|
1953 * Fires immediately after an existing user is added to a site. |
|
1954 * |
|
1955 * @since MU |
|
1956 * |
|
1957 * @param int $user_id User ID. |
|
1958 * @param mixed $result True on success or a WP_Error object if the user doesn't exist. |
|
1959 */ |
|
1960 do_action( 'added_existing_user', $details['user_id'], $result ); |
1674 } |
1961 } |
1675 return $result; |
1962 return $result; |
1676 } |
1963 } |
1677 |
1964 |
1678 /** |
1965 /** |
1687 * @param int $user_id |
1974 * @param int $user_id |
1688 * @param mixed $password Ignored. |
1975 * @param mixed $password Ignored. |
1689 * @param array $meta |
1976 * @param array $meta |
1690 */ |
1977 */ |
1691 function add_new_user_to_blog( $user_id, $password, $meta ) { |
1978 function add_new_user_to_blog( $user_id, $password, $meta ) { |
1692 global $current_site; |
|
1693 if ( !empty( $meta[ 'add_to_blog' ] ) ) { |
1979 if ( !empty( $meta[ 'add_to_blog' ] ) ) { |
1694 $blog_id = $meta[ 'add_to_blog' ]; |
1980 $blog_id = $meta[ 'add_to_blog' ]; |
1695 $role = $meta[ 'new_role' ]; |
1981 $role = $meta[ 'new_role' ]; |
1696 remove_user_from_blog($user_id, $current_site->blog_id); // remove user from main blog. |
1982 remove_user_from_blog($user_id, get_current_site()->blog_id); // remove user from main blog. |
1697 add_user_to_blog( $blog_id, $user_id, $role ); |
1983 add_user_to_blog( $blog_id, $user_id, $role ); |
1698 update_user_meta( $user_id, 'primary_blog', $blog_id ); |
1984 update_user_meta( $user_id, 'primary_blog', $blog_id ); |
1699 } |
1985 } |
1700 } |
1986 } |
1701 |
1987 |
1703 * Correct From host on outgoing mail to match the site domain |
1989 * Correct From host on outgoing mail to match the site domain |
1704 * |
1990 * |
1705 * @since MU |
1991 * @since MU |
1706 */ |
1992 */ |
1707 function fix_phpmailer_messageid( $phpmailer ) { |
1993 function fix_phpmailer_messageid( $phpmailer ) { |
1708 global $current_site; |
1994 $phpmailer->Hostname = get_current_site()->domain; |
1709 $phpmailer->Hostname = $current_site->domain; |
|
1710 } |
1995 } |
1711 |
1996 |
1712 /** |
1997 /** |
1713 * Check to see whether a user is marked as a spammer, based on user login. |
1998 * Check to see whether a user is marked as a spammer, based on user login. |
1714 * |
1999 * |
1715 * @since MU |
2000 * @since MU |
1716 * @uses get_user_by() |
|
1717 * |
2001 * |
1718 * @param string|WP_User $user Optional. Defaults to current user. WP_User object, |
2002 * @param string|WP_User $user Optional. Defaults to current user. WP_User object, |
1719 * or user login name as a string. |
2003 * or user login name as a string. |
1720 * @return bool |
2004 * @return bool |
1721 */ |
2005 */ |
1722 function is_user_spammy( $user = null ) { |
2006 function is_user_spammy( $user = null ) { |
1723 if ( ! is_a( $user, 'WP_User' ) ) { |
2007 if ( ! ( $user instanceof WP_User ) ) { |
1724 if ( $user ) |
2008 if ( $user ) { |
1725 $user = get_user_by( 'login', $user ); |
2009 $user = get_user_by( 'login', $user ); |
1726 else |
2010 } else { |
1727 $user = wp_get_current_user(); |
2011 $user = wp_get_current_user(); |
|
2012 } |
1728 } |
2013 } |
1729 |
2014 |
1730 return $user && isset( $user->spam ) && 1 == $user->spam; |
2015 return $user && isset( $user->spam ) && 1 == $user->spam; |
1731 } |
2016 } |
1732 |
2017 |
1734 * Update this blog's 'public' setting in the global blogs table. |
2019 * Update this blog's 'public' setting in the global blogs table. |
1735 * |
2020 * |
1736 * Public blogs have a setting of 1, private blogs are 0. |
2021 * Public blogs have a setting of 1, private blogs are 0. |
1737 * |
2022 * |
1738 * @since MU |
2023 * @since MU |
1739 * @uses update_blog_status() |
|
1740 * |
2024 * |
1741 * @param int $old_value |
2025 * @param int $old_value |
1742 * @param int $value The new public value |
2026 * @param int $value The new public value |
1743 * @return bool |
|
1744 */ |
2027 */ |
1745 function update_blog_public( $old_value, $value ) { |
2028 function update_blog_public( $old_value, $value ) { |
1746 update_blog_status( get_current_blog_id(), 'public', (int) $value ); |
2029 update_blog_status( get_current_blog_id(), 'public', (int) $value ); |
1747 } |
2030 } |
1748 add_action('update_option_blog_public', 'update_blog_public', 10, 2); |
|
1749 |
2031 |
1750 /** |
2032 /** |
1751 * Check whether a usermeta key has to do with the current blog. |
2033 * Check whether a usermeta key has to do with the current blog. |
1752 * |
2034 * |
1753 * @since MU |
2035 * @since MU |
1754 * @uses wp_get_current_user() |
|
1755 * |
2036 * |
1756 * @param string $key |
2037 * @param string $key |
1757 * @param int $user_id Optional. Defaults to current user. |
2038 * @param int $user_id Optional. Defaults to current user. |
1758 * @param int $blog_id Optional. Defaults to current blog. |
2039 * @param int $blog_id Optional. Defaults to current blog. |
1759 * @return bool |
2040 * @return bool |
1760 */ |
2041 */ |
1761 function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) { |
2042 function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) { |
1762 global $wpdb; |
2043 global $wpdb; |
1763 |
2044 |
1764 $current_user = wp_get_current_user(); |
2045 $current_user = wp_get_current_user(); |
1765 if ( $user_id == 0 ) |
2046 if ( $blog_id == 0 ) { |
1766 $user_id = $current_user->ID; |
|
1767 if ( $blog_id == 0 ) |
|
1768 $blog_id = $wpdb->blogid; |
2047 $blog_id = $wpdb->blogid; |
1769 |
2048 } |
1770 $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key; |
2049 $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key; |
1771 |
2050 |
1772 if ( isset( $current_user->$local_key ) ) |
2051 if ( isset( $current_user->$local_key ) ) |
1773 return true; |
2052 return true; |
1774 |
2053 |
1888 * |
2165 * |
1889 * If enabled through the 'enable_live_network_counts' filter, update the sites count |
2166 * If enabled through the 'enable_live_network_counts' filter, update the sites count |
1890 * on a network when a site is created or its status is updated. |
2167 * on a network when a site is created or its status is updated. |
1891 * |
2168 * |
1892 * @since 3.7.0 |
2169 * @since 3.7.0 |
1893 * |
|
1894 * @uses wp_update_network_site_counts() |
|
1895 */ |
2170 */ |
1896 function wp_maybe_update_network_site_counts() { |
2171 function wp_maybe_update_network_site_counts() { |
1897 $is_small_network = ! wp_is_large_network( 'sites' ); |
2172 $is_small_network = ! wp_is_large_network( 'sites' ); |
1898 |
2173 |
1899 /** |
2174 /** |
1900 * Filter the decision to update network user and site counts in real time. |
2175 * Filter whether to update network site or user counts when a new site is created. |
1901 * |
2176 * |
1902 * @since 3.7.0 |
2177 * @since 3.7.0 |
1903 * |
2178 * |
1904 * @param bool $small_network Based on wp_is_large_network( $context ). |
2179 * @see wp_is_large_network() |
|
2180 * |
|
2181 * @param bool $small_network Whether the network is considered small. |
1905 * @param string $context Context. Either 'users' or 'sites'. |
2182 * @param string $context Context. Either 'users' or 'sites'. |
1906 */ |
2183 */ |
1907 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) |
2184 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) |
1908 return; |
2185 return; |
1909 |
2186 |
1915 * |
2192 * |
1916 * If enabled through the 'enable_live_network_counts' filter, update the users count |
2193 * If enabled through the 'enable_live_network_counts' filter, update the users count |
1917 * on a network when a user is created or its status is updated. |
2194 * on a network when a user is created or its status is updated. |
1918 * |
2195 * |
1919 * @since 3.7.0 |
2196 * @since 3.7.0 |
1920 * |
|
1921 * @uses wp_update_network_user_counts() |
|
1922 */ |
2197 */ |
1923 function wp_maybe_update_network_user_counts() { |
2198 function wp_maybe_update_network_user_counts() { |
1924 $is_small_network = ! wp_is_large_network( 'users' ); |
2199 $is_small_network = ! wp_is_large_network( 'users' ); |
1925 |
2200 |
1926 /** |
2201 /** This filter is documented in wp-includes/ms-functions.php */ |
1927 * Filter the decision to update network user and site counts in real time. |
|
1928 * |
|
1929 * @since 3.7.0 |
|
1930 * |
|
1931 * @param bool $small_network Based on wp_is_large_network( $context ). |
|
1932 * @param string $context Context. Either 'users' or 'sites'. |
|
1933 */ |
|
1934 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) |
2202 if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) |
1935 return; |
2203 return; |
1936 |
2204 |
1937 wp_update_network_user_counts(); |
2205 wp_update_network_user_counts(); |
1938 } |
2206 } |
1967 * @since 3.5.0 |
2235 * @since 3.5.0 |
1968 * |
2236 * |
1969 * @return int Used space in megabytes |
2237 * @return int Used space in megabytes |
1970 */ |
2238 */ |
1971 function get_space_used() { |
2239 function get_space_used() { |
1972 // Allow for an alternative way of tracking storage space used |
2240 /** |
|
2241 * Filter the amount of storage space used by the current site. |
|
2242 * |
|
2243 * @since 3.5.0 |
|
2244 * |
|
2245 * @param int|bool $space_used The amount of used space, in megabytes. Default false. |
|
2246 */ |
1973 $space_used = apply_filters( 'pre_get_space_used', false ); |
2247 $space_used = apply_filters( 'pre_get_space_used', false ); |
1974 if ( false === $space_used ) { |
2248 if ( false === $space_used ) { |
1975 $upload_dir = wp_upload_dir(); |
2249 $upload_dir = wp_upload_dir(); |
1976 $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024; |
2250 $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024; |
1977 } |
2251 } |
2055 * @return bool True if the network meets the criteria for large. False otherwise. |
2336 * @return bool True if the network meets the criteria for large. False otherwise. |
2056 */ |
2337 */ |
2057 function wp_is_large_network( $using = 'sites' ) { |
2338 function wp_is_large_network( $using = 'sites' ) { |
2058 if ( 'users' == $using ) { |
2339 if ( 'users' == $using ) { |
2059 $count = get_user_count(); |
2340 $count = get_user_count(); |
|
2341 /** |
|
2342 * Filter whether the network is considered large. |
|
2343 * |
|
2344 * @since 3.3.0 |
|
2345 * |
|
2346 * @param bool $is_large_network Whether the network has more than 10000 users or sites. |
|
2347 * @param string $component The component to count. Accepts 'users', or 'sites'. |
|
2348 * @param int $count The count of items for the component. |
|
2349 */ |
2060 return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count ); |
2350 return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count ); |
2061 } |
2351 } |
2062 |
2352 |
2063 $count = get_blog_count(); |
2353 $count = get_blog_count(); |
|
2354 /** This filter is documented in wp-includes/ms-functions.php */ |
2064 return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count ); |
2355 return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count ); |
2065 } |
2356 } |
2066 |
2357 |
2067 |
2358 |
2068 /** |
2359 /** |