X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f9001779751f83dc8a10e478bfecb4d8dd5f964c..341dfbb66f24f5145174c373267f889c31615cc5:/wp-includes/ms-functions.php
diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php
index 16f5a05a..17e0e670 100644
--- a/wp-includes/ms-functions.php
+++ b/wp-includes/ms-functions.php
@@ -1,6 +1,6 @@
get_blog_count(),
+ 'users' => get_user_count(),
+ );
return $stats;
}
@@ -79,7 +81,7 @@ function get_active_blog_for_user( $user_id ) {
if ( false !== $primary_blog ) {
if ( ! isset( $blogs[ $primary_blog ] ) ) {
update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
- $primary = $first_blog;
+ $primary = get_blog_details( $first_blog->userblog_id );
} else {
$primary = get_blog_details( $primary_blog );
}
@@ -90,7 +92,7 @@ function get_active_blog_for_user( $user_id ) {
$primary = $first_blog;
}
- if ( ( ! is_object( $primary ) ) || ( is_object( $primary ) && $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) {
+ if ( ( ! is_object( $primary ) ) || ( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) {
$blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs.
$ret = false;
if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
@@ -116,32 +118,6 @@ function get_active_blog_for_user( $user_id ) {
}
}
-/**
- * Find out whether a user is a member of a given blog.
- *
- * @since MU 1.1
- * @uses get_blogs_of_user()
- *
- * @param int $user_id The unique ID of the user
- * @param int $blog Optional. If no blog_id is provided, current site is used
- * @return bool
- */
-function is_user_member_of_blog( $user_id, $blog_id = 0 ) {
- $user_id = (int) $user_id;
- $blog_id = (int) $blog_id;
-
- if ( $blog_id == 0 ) {
- global $wpdb;
- $blog_id = $wpdb->blogid;
- }
-
- $blogs = get_blogs_of_user( $user_id );
- if ( is_array( $blogs ) )
- return array_key_exists( $blog_id, $blogs );
- else
- return false;
-}
-
/**
* The number of active users in your installation.
*
@@ -291,6 +267,8 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
}
restore_current_blog();
+
+ return true;
}
/**
@@ -314,14 +292,14 @@ function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
// Check if the domain has been used already. We should return an error message.
if ( domain_exists($domain, $path, $site_id) )
- return __( 'Error: Site URL already taken.' );
+ return __( 'ERROR: Site URL already taken.' );
// Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
// Need to get blog_id from wp_blogs, and create new table names.
// Must restore table names at the end of function.
if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
- return __( 'Error: problem creating site entry.' );
+ return __( 'ERROR: problem creating site entry.' );
switch_to_blog($blog_id);
install_blog($blog_id);
@@ -391,68 +369,6 @@ function get_blog_id_from_url( $domain, $path = '/' ) {
// Admin functions
-/**
- * Redirect a user based on $_GET or $_POST arguments.
- *
- * The function looks for redirect arguments in the following order:
- * 1) $_GET['ref']
- * 2) $_POST['ref']
- * 3) $_SERVER['HTTP_REFERER']
- * 4) $_GET['redirect']
- * 5) $_POST['redirect']
- * 6) $url
- *
- * @since MU
- * @uses wpmu_admin_redirect_add_updated_param()
- *
- * @param string $url
- */
-function wpmu_admin_do_redirect( $url = '' ) {
- $ref = '';
- if ( isset( $_GET['ref'] ) )
- $ref = $_GET['ref'];
- if ( isset( $_POST['ref'] ) )
- $ref = $_POST['ref'];
-
- if ( $ref ) {
- $ref = wpmu_admin_redirect_add_updated_param( $ref );
- wp_redirect( $ref );
- exit();
- }
- if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
- wp_redirect( $_SERVER['HTTP_REFERER'] );
- exit();
- }
-
- $url = wpmu_admin_redirect_add_updated_param( $url );
- if ( isset( $_GET['redirect'] ) ) {
- if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
- $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
- } elseif ( isset( $_POST['redirect'] ) ) {
- $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
- }
- wp_redirect( $url );
- exit();
-}
-
-/**
- * Adds an 'updated=true' argument to a URL.
- *
- * @since MU
- *
- * @param string $url
- * @return string
- */
-function wpmu_admin_redirect_add_updated_param( $url = '' ) {
- if ( strpos( $url, 'updated=true' ) === false ) {
- if ( strpos( $url, '?' ) === false )
- return $url . '?updated=true';
- else
- return $url . '&updated=true';
- }
- return $url;
-}
-
/**
* Checks an email address against a list of banned domains.
*
@@ -644,13 +560,10 @@ function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
if (! is_subdomain_install() )
$illegal_names = array_merge($illegal_names, apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ) );
-
if ( empty( $blogname ) )
$errors->add('blogname', __('Please enter a site name'));
- $maybe = array();
- preg_match( '/[a-z0-9]+/', $blogname, $maybe );
- if ( $blogname != $maybe[0] )
+ if ( preg_match( '/[^a-z0-9]+/', $blogname ) )
$errors->add('blogname', __('Only lowercase letters and numbers allowed'));
if ( in_array( $blogname, $illegal_names ) == true )
@@ -792,7 +705,7 @@ function wpmu_signup_user($user, $user_email, $meta = '') {
* replace it with your own notification behavior.
*
* Filter 'wpmu_signup_blog_notification_email' and
- * 'wpmu_signup_blog_notification_email' to change the content
+ * 'wpmu_signup_blog_notification_subject' to change the content
* and subject line of the email sent to newly registered users.
*
* @since MU
@@ -882,8 +795,7 @@ function wpmu_signup_user_notification($user, $user_email, $key, $meta = '') {
__( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\n" ),
$user, $user_email, $key, $meta
),
- site_url( "wp-activate.php?key=$key" ),
- $key
+ site_url( "wp-activate.php?key=$key" )
);
// TODO: Don't hard code activation link.
$subject = sprintf(
@@ -1079,7 +991,7 @@ function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id
add_option( 'WPLANG', get_site_option( 'WPLANG' ) );
update_option( 'blog_public', (int)$meta['public'] );
- if ( !is_super_admin() && ! get_user_meta( $user_id, 'primary_blog', true ) )
+ if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) )
update_user_meta( $user_id, 'primary_blog', $blog_id );
restore_current_blog();
@@ -1234,7 +1146,7 @@ function install_blog($blog_id, $blog_title = '') {
$url = get_blogaddress_by_id($blog_id);
// Set everything up
- make_db_current_silent();
+ make_db_current_silent( 'blog' );
populate_options();
populate_roles();
$wp_roles->_init();
@@ -1313,10 +1225,9 @@ BLOG_URL
You can log in to the administrator account with the following information:
Username: USERNAME
Password: PASSWORD
-Login Here: BLOG_URLwp-login.php
+Log in here: BLOG_URLwp-login.php
-We hope you enjoy your new site.
-Thanks!
+We hope you enjoy your new site. Thanks!
--The Team @ SITE_NAME' ) );
@@ -1340,7 +1251,7 @@ Thanks!
$message = $welcome_email;
if ( empty( $current_site->site_name ) )
- $current_site->site_name = 'WordPress MU';
+ $current_site->site_name = 'WordPress';
$subject = apply_filters( 'update_welcome_subject', sprintf(__('New %1$s Site: %2$s'), $current_site->site_name, stripslashes( $title ) ) );
wp_mail($user->user_email, $subject, $message, $message_headers);
@@ -1388,7 +1299,7 @@ function wpmu_welcome_user_notification($user_id, $password, $meta = '') {
$message = $welcome_email;
if ( empty( $current_site->site_name ) )
- $current_site->site_name = 'WordPress MU';
+ $current_site->site_name = 'WordPress';
$subject = apply_filters( 'update_welcome_user_subject', sprintf(__('New %1$s User: %2$s'), $current_site->site_name, $user->user_login) );
wp_mail($user->user_email, $subject, $message, $message_headers);
@@ -1522,8 +1433,7 @@ function get_dirsize( $directory ) {
function recurse_dirsize( $directory ) {
$size = 0;
- if ( substr( $directory, -1 ) == '/' )
- $directory = substr($directory,0,-1);
+ $directory = untrailingslashit( $directory );
if ( !file_exists($directory) || !is_dir( $directory ) || !is_readable( $directory ) )
return false;
@@ -1566,8 +1476,7 @@ function upload_is_user_over_quota( $echo = true ) {
if ( empty( $spaceAllowed ) || !is_numeric( $spaceAllowed ) )
$spaceAllowed = 10; // Default space allowed is 10 MB
- $dirName = BLOGUPLOADDIR;
- $size = get_dirsize($dirName) / 1024 / 1024;
+ $size = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
if ( ($spaceAllowed-$size) < 0 ) {
if ( $echo )
@@ -1648,8 +1557,7 @@ function fix_import_form_size( $size ) {
return 0;
$spaceAllowed = 1024 * 1024 * get_space_allowed();
- $dirName = BLOGUPLOADDIR;
- $dirsize = get_dirsize($dirName) ;
+ $dirsize = get_dirsize( BLOGUPLOADDIR );
if ( $size > $spaceAllowed - $dirsize )
return $spaceAllowed - $dirsize; // remaining space
else
@@ -1828,7 +1736,7 @@ function maybe_add_existing_user_to_blog() {
if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
wp_die( sprintf(__('An error occurred adding you to this site. Back to the homepage.'), site_url() ) );
- wp_die( sprintf(__('You have been added to this site. Please visit the homepage or login using your username and password.'), site_url(), admin_url() ), __('Success') );
+ wp_die( sprintf(__('You have been added to this site. Please visit the homepage or log in using your username and password.'), site_url(), admin_url() ), __('Success') );
}
/**
@@ -1860,7 +1768,7 @@ function add_existing_user_to_blog( $details = false ) {
*/
function add_new_user_to_blog( $user_id, $email, $meta ) {
global $current_site;
- if ( $meta[ 'add_to_blog' ] ) {
+ if ( !empty( $meta[ 'add_to_blog' ] ) ) {
$blog_id = $meta[ 'add_to_blog' ];
$role = $meta[ 'new_role' ];
remove_user_from_blog($user_id, $current_site->blog_id); // remove user from main blog.