<?php
/**
- * Multi-site WordPress API
+ * Multisite WordPress API
*
* @package WordPress
* @subpackage Multisite
function get_sitestats() {
global $wpdb;
- $stats['blogs'] = get_blog_count();
- $stats['users'] = get_user_count();
+ $stats = array(
+ 'blogs' => get_blog_count(),
+ 'users' => get_user_count(),
+ );
return $stats;
}
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 );
}
$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 ) {
}
}
-/**
- * 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.
*
}
restore_current_blog();
+
+ return true;
}
/**
// 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 __( '<strong>ERROR</strong>: 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 __( '<strong>ERROR</strong>: problem creating site entry.' );
switch_to_blog($blog_id);
install_blog($blog_id);
// 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.
*
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 )
* 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
__( "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(
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();
$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();
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' ) );
$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);
$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);
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;
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 )
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
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 <a href="%s">homepage</a>.'), site_url() ) );
- wp_die( sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">login</a> using your username and password.'), site_url(), admin_url() ), __('Success') );
+ 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.'), site_url(), admin_url() ), __('Success') );
}
/**
*/
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.
*/
function welcome_user_msg_filter( $text ) {
if ( !$text ) {
- return __( 'Dear User,
+ remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
+ $text = __( 'Dear User,
Your new account is set up.
Thanks!
--The Team @ SITE_NAME' );
+ update_site_option( 'welcome_user_email', $text );
}
return $text;
}