Formatting cleanup. Props Simek. fixes #11876
git-svn-id: https://develop.svn.wordpress.org/trunk@12709 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9b510ecec4
commit
1a7bd827e8
|
@ -78,15 +78,14 @@ function get_sitestats() {
|
|||
function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
|
||||
global $wpdb;
|
||||
|
||||
if( $sitedomain == '' ) {
|
||||
if ( $sitedomain == '' )
|
||||
$site_id = $wpdb->siteid;
|
||||
} else {
|
||||
else
|
||||
$site_id = $wpdb->get_var( $wpdb->prepare("SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) );
|
||||
}
|
||||
|
||||
if( $site_id != false ) {
|
||||
if ( $site_id != false )
|
||||
return $wpdb->get_results( $wpdb->prepare("SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $site_id), ARRAY_A );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -123,9 +122,9 @@ function get_id_from_blogname( $name ) {
|
|||
function get_blog_details( $id, $getall = true ) {
|
||||
global $wpdb;
|
||||
|
||||
if( !is_numeric( $id ) ) {
|
||||
if ( !is_numeric( $id ) )
|
||||
$id = get_id_from_blogname( $id );
|
||||
}
|
||||
|
||||
$all = $getall == true ? '' : 'short';
|
||||
$details = wp_cache_get( $id . $all, 'blog-details' );
|
||||
|
||||
|
@ -216,11 +215,10 @@ function get_blog_option( $blog_id, $setting, $default = false ) {
|
|||
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$blog_prefix}options WHERE option_name = %s", $setting ) );
|
||||
if ( is_object( $row ) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
|
||||
$value = $row->option_value;
|
||||
if ( $value == false ) {
|
||||
if ( $value == false )
|
||||
wp_cache_set( $key, 'falsevalue', 'site-options' );
|
||||
} else {
|
||||
else
|
||||
wp_cache_set( $key, $value, 'site-options' );
|
||||
}
|
||||
} else { // option does not exist, so we must cache its non-existence
|
||||
wp_cache_set( $key, 'noop', 'site-options' );
|
||||
$value = $default;
|
||||
|
@ -300,29 +298,27 @@ function switch_to_blog( $new_blog ) {
|
|||
|
||||
if ( is_object( $wp_roles ) ) {
|
||||
$wpdb->suppress_errors();
|
||||
if ( method_exists( $wp_roles ,'_init' ) ) {
|
||||
if ( method_exists( $wp_roles ,'_init' ) )
|
||||
$wp_roles->_init();
|
||||
} elseif( method_exists( $wp_roles, '__construct' ) ) {
|
||||
elseif ( method_exists( $wp_roles, '__construct' ) )
|
||||
$wp_roles->__construct();
|
||||
}
|
||||
$wpdb->suppress_errors( false );
|
||||
}
|
||||
|
||||
if ( is_object( $current_user ) )
|
||||
$current_user->_init_caps();
|
||||
|
||||
if ( is_object( $wp_object_cache ) ) {
|
||||
if ( is_object( $wp_object_cache ) )
|
||||
$global_groups = $wp_object_cache->global_groups;
|
||||
} else {
|
||||
else
|
||||
$global_groups = false;
|
||||
}
|
||||
|
||||
wp_cache_init();
|
||||
if ( function_exists('wp_cache_add_global_groups') ) {
|
||||
if ( is_array( $global_groups ) ) {
|
||||
if ( is_array( $global_groups ) )
|
||||
wp_cache_add_global_groups( $global_groups );
|
||||
} else {
|
||||
else
|
||||
wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient', 'global-posts' ) );
|
||||
}
|
||||
wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
|
||||
}
|
||||
|
||||
|
@ -355,29 +351,27 @@ function restore_current_blog() {
|
|||
|
||||
if ( is_object( $wp_roles ) ) {
|
||||
$wpdb->suppress_errors();
|
||||
if ( method_exists( $wp_roles ,'_init' ) ) {
|
||||
if ( method_exists( $wp_roles ,'_init' ) )
|
||||
$wp_roles->_init();
|
||||
} elseif( method_exists( $wp_roles, '__construct' ) ) {
|
||||
elseif ( method_exists( $wp_roles, '__construct' ) )
|
||||
$wp_roles->__construct();
|
||||
}
|
||||
$wpdb->suppress_errors( false );
|
||||
}
|
||||
|
||||
if ( is_object( $current_user ) )
|
||||
$current_user->_init_caps();
|
||||
|
||||
if ( is_object( $wp_object_cache ) ) {
|
||||
if ( is_object( $wp_object_cache ) )
|
||||
$global_groups = $wp_object_cache->global_groups;
|
||||
} else {
|
||||
else
|
||||
$global_groups = false;
|
||||
}
|
||||
|
||||
wp_cache_init();
|
||||
if ( function_exists('wp_cache_add_global_groups') ) {
|
||||
if ( is_array( $global_groups ) ) {
|
||||
if ( is_array( $global_groups ) )
|
||||
wp_cache_add_global_groups( $global_groups );
|
||||
} else {
|
||||
else
|
||||
wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient' ) );
|
||||
}
|
||||
wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
|
||||
}
|
||||
|
||||
|
@ -393,9 +387,8 @@ function get_blogs_of_user( $id, $all = false ) {
|
|||
|
||||
$cache_suffix = $all ? '_all' : '_short';
|
||||
$return = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' );
|
||||
if ( $return ) {
|
||||
if ( $return )
|
||||
return apply_filters( 'get_blogs_of_user', $return, $id, $all );
|
||||
}
|
||||
|
||||
$user = get_userdata( (int) $id );
|
||||
if ( !$user )
|
||||
|
@ -494,12 +487,11 @@ function is_user_member_of_blog( $user_id, $blog_id = 0 ) {
|
|||
}
|
||||
|
||||
$blogs = get_blogs_of_user( $user_id );
|
||||
if( is_array( $blogs ) ) {
|
||||
if ( is_array( $blogs ) )
|
||||
return array_key_exists( $blog_id, $blogs );
|
||||
} else {
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function is_archived( $id ) {
|
||||
return get_blog_status($id, 'archived');
|
||||
|
@ -521,12 +513,11 @@ function update_blog_status( $id, $pref, $value, $refresh = 1 ) {
|
|||
refresh_blog_details($id);
|
||||
|
||||
if ( $pref == 'spam' ) {
|
||||
if( $value == 1 ) {
|
||||
if ( $value == 1 )
|
||||
do_action( "make_spam_blog", $id );
|
||||
} else {
|
||||
else
|
||||
do_action( "make_ham_blog", $id );
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
@ -535,9 +526,9 @@ function get_blog_status( $id, $pref ) {
|
|||
global $wpdb;
|
||||
|
||||
$details = get_blog_details( $id, false );
|
||||
if( $details ) {
|
||||
if ( $details )
|
||||
return $details->$pref;
|
||||
}
|
||||
|
||||
return $wpdb->get_var( $wpdb->prepare("SELECT $pref FROM {$wpdb->blogs} WHERE blog_id = %d", $id) );
|
||||
}
|
||||
|
||||
|
@ -568,9 +559,9 @@ function get_most_active_blogs( $num = 10, $display = true ) {
|
|||
}
|
||||
arsort( $most_active );
|
||||
reset( $most_active );
|
||||
foreach ( (array) $most_active as $key => $details ) {
|
||||
foreach ( (array) $most_active as $key => $details )
|
||||
$t[ $key ] = $blog_list[ $key ];
|
||||
}
|
||||
|
||||
unset( $most_active );
|
||||
$most_active = $t;
|
||||
}
|
||||
|
@ -618,12 +609,11 @@ function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
|
|||
if ( false == is_array( $blogs ) )
|
||||
return array();
|
||||
|
||||
if( $num == 'all' ) {
|
||||
if ( $num == 'all' )
|
||||
return array_slice( $blogs, $start, count( $blogs ) );
|
||||
} else {
|
||||
else
|
||||
return array_slice( $blogs, $start, $num );
|
||||
}
|
||||
}
|
||||
|
||||
function get_user_count() {
|
||||
global $wpdb;
|
||||
|
@ -827,9 +817,8 @@ function wpmu_admin_do_redirect( $url = '' ) {
|
|||
|
||||
$url = wpmu_admin_redirect_add_updated_param( $url );
|
||||
if ( isset( $_GET['redirect'] ) ) {
|
||||
if( substr( $_GET['redirect'], 0, 2 ) == 's_' ) {
|
||||
if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
|
||||
$url .= "&action=blogs&s=". wp_specialchars( substr( $_GET['redirect'], 2 ) );
|
||||
}
|
||||
} elseif ( isset( $_POST['redirect'] ) ) {
|
||||
$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
|
||||
}
|
||||
|
@ -839,12 +828,11 @@ function wpmu_admin_do_redirect( $url = '' ) {
|
|||
|
||||
function wpmu_admin_redirect_add_updated_param( $url = '' ) {
|
||||
if ( strpos( $url, 'updated=true' ) === false ) {
|
||||
if( strpos( $url, '?' ) === false ) {
|
||||
if ( strpos( $url, '?' ) === false )
|
||||
return $url . '?updated=true';
|
||||
} else {
|
||||
else
|
||||
return $url . '&updated=true';
|
||||
}
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
@ -870,9 +858,8 @@ function validate_email( $email, $check_domain = true) {
|
|||
if ($check_domain && function_exists('checkdnsrr')) {
|
||||
list (, $domain) = explode('@', $email);
|
||||
|
||||
if (checkdnsrr($domain.'.', 'MX') || checkdnsrr($domain.'.', 'A')) {
|
||||
if (checkdnsrr($domain.'.', 'MX') || checkdnsrr($domain.'.', 'A'))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -882,9 +869,9 @@ function validate_email( $email, $check_domain = true) {
|
|||
|
||||
function is_email_address_unsafe( $user_email ) {
|
||||
$banned_names = get_site_option( "banned_email_domains" );
|
||||
if ($banned_names && !is_array( $banned_names )) {
|
||||
if ($banned_names && !is_array( $banned_names ))
|
||||
$banned_names = explode( "\n", $banned_names);
|
||||
}
|
||||
|
||||
if ( is_array( $banned_names ) && empty( $banned_names ) == false ) {
|
||||
$email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
|
||||
foreach( (array) $banned_names as $banned_domain ) {
|
||||
|
@ -917,25 +904,22 @@ function wpmu_validate_user_signup($user_name, $user_email) {
|
|||
$maybe = array();
|
||||
preg_match( "/[a-z0-9]+/", $user_name, $maybe );
|
||||
|
||||
if( $user_name != $maybe[0] ) {
|
||||
if ( $user_name != $maybe[0] )
|
||||
$errors->add('user_name', __("Only lowercase letters and numbers allowed"));
|
||||
}
|
||||
|
||||
$illegal_names = get_site_option( "illegal_names" );
|
||||
if ( is_array( $illegal_names ) == false ) {
|
||||
$illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
|
||||
add_site_option( "illegal_names", $illegal_names );
|
||||
}
|
||||
if( in_array( $user_name, $illegal_names ) == true ) {
|
||||
if ( in_array( $user_name, $illegal_names ) == true )
|
||||
$errors->add('user_name', __("That username is not allowed"));
|
||||
}
|
||||
|
||||
if ( is_email_address_unsafe( $user_email ) )
|
||||
$errors->add('user_email', __("You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider."));
|
||||
|
||||
if( strlen( $user_name ) < 4 ) {
|
||||
if ( strlen( $user_name ) < 4 )
|
||||
$errors->add('user_name', __("Username must be at least 4 characters"));
|
||||
}
|
||||
|
||||
if ( strpos( " " . $user_name, "_" ) != false )
|
||||
$errors->add('user_name', __("Sorry, usernames may not contain the character '_'!"));
|
||||
|
@ -955,10 +939,9 @@ function wpmu_validate_user_signup($user_name, $user_email) {
|
|||
$limited_email_domains = get_site_option( 'limited_email_domains' );
|
||||
if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
|
||||
$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
|
||||
if( in_array( $emaildomain, $limited_email_domains ) == false ) {
|
||||
if ( in_array( $emaildomain, $limited_email_domains ) == false )
|
||||
$errors->add('user_email', __("Sorry, that email address is not allowed!"));
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the username has been used already.
|
||||
if ( username_exists($user_name) )
|
||||
|
@ -975,11 +958,11 @@ function wpmu_validate_user_signup($user_name, $user_email) {
|
|||
$now = current_time( 'timestamp', true );
|
||||
$diff = $now - $registered_at;
|
||||
// If registered more than two days ago, cancel registration and let this signup go through.
|
||||
if ( $diff > 172800 ) {
|
||||
if ( $diff > 172800 )
|
||||
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_login = %s", $user_name) );
|
||||
} else {
|
||||
else
|
||||
$errors->add('user_name', __("That username is currently reserved but may be available in a couple of days."));
|
||||
}
|
||||
|
||||
if ( $signup->active == 0 && $signup->user_email == $user_email )
|
||||
$errors->add('user_email_used', __("username and email used"));
|
||||
}
|
||||
|
@ -988,12 +971,11 @@ function wpmu_validate_user_signup($user_name, $user_email) {
|
|||
if ( $signup != null ) {
|
||||
$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
|
||||
// If registered more than two days ago, cancel registration and let this signup go through.
|
||||
if ( $diff > 172800 ) {
|
||||
if ( $diff > 172800 )
|
||||
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_email = %s", $user_email) );
|
||||
} else {
|
||||
else
|
||||
$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."));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors);
|
||||
|
||||
|
@ -1019,23 +1001,21 @@ function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
|
|||
|
||||
$maybe = array();
|
||||
preg_match( "/[a-z0-9]+/", $blogname, $maybe );
|
||||
if( $blogname != $maybe[0] ) {
|
||||
if ( $blogname != $maybe[0] )
|
||||
$errors->add('blogname', __("Only lowercase letters and numbers allowed"));
|
||||
}
|
||||
if( in_array( $blogname, $illegal_names ) == true ) {
|
||||
|
||||
if ( in_array( $blogname, $illegal_names ) == true )
|
||||
$errors->add('blogname', __("That name is not allowed"));
|
||||
}
|
||||
if( strlen( $blogname ) < 4 && !is_super_admin() ) {
|
||||
|
||||
if ( strlen( $blogname ) < 4 && !is_super_admin() )
|
||||
$errors->add('blogname', __("Blog name must be at least 4 characters"));
|
||||
}
|
||||
|
||||
if ( strpos( " " . $blogname, "_" ) != false )
|
||||
$errors->add('blogname', __("Sorry, blog names may not contain the character '_'!"));
|
||||
|
||||
// do not allow users to create a blog that conflicts with a page on the main blog.
|
||||
if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) {
|
||||
if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
|
||||
$errors->add( 'blogname', __( "Sorry, you may not use that blog name" ) );
|
||||
}
|
||||
|
||||
// all numeric?
|
||||
$match = array();
|
||||
|
@ -1071,12 +1051,11 @@ function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
|
|||
if ( ! empty($signup) ) {
|
||||
$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
|
||||
// If registered more than two days ago, cancel registration and let this signup go through.
|
||||
if ( $diff > 172800 ) {
|
||||
if ( $diff > 172800 )
|
||||
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) );
|
||||
} else {
|
||||
else
|
||||
$errors->add('blogname', __("That blog is currently reserved but may be available in a couple days."));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors);
|
||||
return apply_filters('wpmu_validate_blog_signup', $result);
|
||||
|
@ -1138,11 +1117,11 @@ function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_emai
|
|||
return false;
|
||||
|
||||
// Send email with activation link.
|
||||
if( !is_subdomain_install() || $current_site->id != 1 ) {
|
||||
if ( !is_subdomain_install() || $current_site->id != 1 )
|
||||
$activate_url = "http://" . $current_site->domain . $current_site->path . "wp-activate.php?key=$key";
|
||||
} else {
|
||||
else
|
||||
$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key";
|
||||
}
|
||||
|
||||
$activate_url = clean_url($activate_url);
|
||||
$admin_email = get_site_option( "admin_email" );
|
||||
if ( $admin_email == '' )
|
||||
|
@ -1206,15 +1185,18 @@ function wpmu_activate_signup($key) {
|
|||
|
||||
if ( empty($signup->domain) ) {
|
||||
$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
|
||||
|
||||
if ( isset( $user_already_exists ) )
|
||||
return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
|
||||
|
||||
wpmu_welcome_user_notification($user_id, $password, $meta);
|
||||
$user_site = get_site_option( 'dashboard_blog', $current_site->blog_id );
|
||||
if ( $user_site == false ) {
|
||||
|
||||
if ( $user_site == false )
|
||||
add_user_to_blog( '1', $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
|
||||
} else {
|
||||
else
|
||||
add_user_to_blog( $user_site, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
|
||||
}
|
||||
|
||||
add_new_user_to_blog( $user_id, $user_email, $meta );
|
||||
do_action('wpmu_activate_user', $user_id, $password, $meta);
|
||||
return array('user_id' => $user_id, 'password' => $password, 'meta' => $meta);
|
||||
|
@ -1231,14 +1213,11 @@ function wpmu_activate_signup($key) {
|
|||
$blog_id->add_data( $signup );
|
||||
$wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) );
|
||||
}
|
||||
|
||||
return $blog_id;
|
||||
}
|
||||
|
||||
$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
|
||||
|
||||
wpmu_welcome_notification($blog_id, $user_id, $password, $signup->title, $meta);
|
||||
|
||||
do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta);
|
||||
|
||||
return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
|
||||
|
@ -1267,8 +1246,10 @@ function wpmu_create_user( $user_name, $password, $email) {
|
|||
|
||||
function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
|
||||
$domain = preg_replace( "/\s+/", '', sanitize_user( $domain, true ) );
|
||||
|
||||
if ( is_subdomain_install() )
|
||||
$domain = str_replace( '@', '', $domain );
|
||||
|
||||
$title = strip_tags( $title );
|
||||
$user_id = (int) $user_id;
|
||||
|
||||
|
@ -1286,30 +1267,25 @@ function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id
|
|||
return new WP_Error('insert_blog', __('Could not create blog.'));
|
||||
|
||||
switch_to_blog($blog_id);
|
||||
|
||||
install_blog($blog_id, $title);
|
||||
|
||||
install_blog_defaults($blog_id, $user_id);
|
||||
|
||||
add_user_to_blog($blog_id, $user_id, 'administrator');
|
||||
|
||||
if ( is_array($meta) ) foreach ($meta as $key => $value) {
|
||||
if( $key == 'public' || $key == 'archived' || $key == 'mature' || $key == 'spam' || $key == 'deleted' || $key == 'lang_id' ) {
|
||||
if ( $key == 'public' || $key == 'archived' || $key == 'mature' || $key == 'spam' || $key == 'deleted' || $key == 'lang_id' )
|
||||
update_blog_status( $blog_id, $key, $value );
|
||||
} else {
|
||||
else
|
||||
update_option( $key, $value );
|
||||
}
|
||||
}
|
||||
|
||||
add_option( 'WPLANG', get_site_option( 'WPLANG' ) );
|
||||
|
||||
update_option( 'blog_public', $meta['public'] );
|
||||
|
||||
if ( !is_super_admin() && get_usermeta( $user_id, 'primary_blog' ) == get_site_option( 'dashboard_blog', 1 ) )
|
||||
update_usermeta( $user_id, 'primary_blog', $blog_id );
|
||||
|
||||
restore_current_blog();
|
||||
|
||||
do_action( 'wpmu_new_blog', $blog_id, $user_id );
|
||||
|
||||
return $blog_id;
|
||||
|
@ -1344,12 +1320,15 @@ Disable these notifications: %4s"), $blogname, $siteurl, $_SERVER['REMOTE_ADDR']
|
|||
|
||||
function newuser_notify_siteadmin( $user_id ) {
|
||||
global $current_site;
|
||||
|
||||
if ( get_site_option( 'registrationnotification' ) != 'yes' )
|
||||
return false;
|
||||
|
||||
$email = get_site_option( 'admin_email' );
|
||||
|
||||
if ( is_email($email) == false )
|
||||
return false;
|
||||
|
||||
$user = new WP_User($user_id);
|
||||
|
||||
$options_site_url = clean_url("http://{$current_site->domain}{$current_site->path}wp-admin/ms-options.php");
|
||||
|
@ -1394,6 +1373,7 @@ function install_blog($blog_id, $blog_title = '') {
|
|||
|
||||
if ( $wpdb->get_results("SELECT ID FROM $wpdb->posts") )
|
||||
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>');
|
||||
|
||||
$wpdb->suppress_errors(false);
|
||||
|
||||
$url = get_blogaddress_by_id($blog_id);
|
||||
|
@ -1422,6 +1402,7 @@ function install_blog($blog_id, $blog_title = '') {
|
|||
$cat_slug = sanitize_title($cat_name);
|
||||
|
||||
$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
|
||||
|
||||
if ( $blogroll_id == null ) {
|
||||
$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
|
||||
$blogroll_id = $wpdb->insert_id;
|
||||
|
@ -1457,9 +1438,10 @@ function install_blog_defaults($blog_id, $user_id) {
|
|||
$now = date('Y-m-d H:i:s');
|
||||
$now_gmt = gmdate('Y-m-d H:i:s');
|
||||
$first_post = get_site_option( 'first_post' );
|
||||
if( $first_post == false ) {
|
||||
|
||||
if ( $first_post == false )
|
||||
$first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
|
||||
}
|
||||
|
||||
$first_post = str_replace( "SITE_URL", clean_url("http://" . $current_site->domain . $current_site->path), $first_post );
|
||||
$first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
|
||||
$wpdb->insert( $wpdb->posts, array(
|
||||
|
@ -1563,13 +1545,17 @@ SITE_NAME" ) );
|
|||
|
||||
$welcome_email = apply_filters( "update_welcome_email", $welcome_email, $blog_id, $user_id, $password, $title, $meta);
|
||||
$admin_email = get_site_option( "admin_email" );
|
||||
|
||||
if ( $admin_email == '' )
|
||||
$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
|
||||
|
||||
$from_name = get_site_option( "site_name" ) == '' ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
|
||||
$message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
|
||||
$message = $welcome_email;
|
||||
|
||||
if ( empty( $current_site->site_name ) )
|
||||
$current_site->site_name = "WordPress MU";
|
||||
|
||||
$subject = apply_filters( 'update_welcome_subject', sprintf(__('New %1$s Blog: %2$s'), $current_site->site_name, stripslashes( $title ) ) );
|
||||
wp_mail($user->user_email, $subject, $message, $message_headers);
|
||||
return true;
|
||||
|
@ -1592,13 +1578,17 @@ function wpmu_welcome_user_notification($user_id, $password, $meta = '') {
|
|||
$welcome_email = str_replace( "LOGINLINK", wp_login_url(), $welcome_email );
|
||||
|
||||
$admin_email = get_site_option( "admin_email" );
|
||||
|
||||
if ( $admin_email == '' )
|
||||
$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
|
||||
|
||||
$from_name = get_site_option( "site_name" ) == '' ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
|
||||
$message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
|
||||
$message = $welcome_email;
|
||||
|
||||
if ( empty( $current_site->site_name ) )
|
||||
$current_site->site_name = "WordPress MU";
|
||||
|
||||
$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);
|
||||
return true;
|
||||
|
@ -1646,10 +1636,7 @@ function get_most_recent_post_of_user( $user_id ) {
|
|||
// If this is the first post checked or if this post is
|
||||
// newer than the current recent post, make it the new
|
||||
// most recent post.
|
||||
if (
|
||||
!isset($most_recent_post['post_gmt_ts'])
|
||||
|| ($post_gmt_ts > $most_recent_post['post_gmt_ts'])
|
||||
) {
|
||||
if ( !isset($most_recent_post['post_gmt_ts']) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {
|
||||
$most_recent_post = array(
|
||||
'blog_id' => $blog->userblog_id,
|
||||
'post_id' => $recent_post['ID'],
|
||||
|
@ -1672,12 +1659,12 @@ function fix_upload_details( $uploads ) {
|
|||
|
||||
function get_dirsize( $directory ) {
|
||||
$dirsize = get_transient( 'dirsize_cache' );
|
||||
if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) {
|
||||
if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
|
||||
return $dirsize[ $directory ][ 'size' ];
|
||||
}
|
||||
if ( false == is_array( $dirsize ) ) {
|
||||
|
||||
if ( false == is_array( $dirsize ) )
|
||||
$dirsize = array();
|
||||
}
|
||||
|
||||
$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
|
||||
|
||||
set_transient( 'dirsize_cache', $dirsize, 3600 );
|
||||
|
@ -1693,8 +1680,13 @@ add_action( 'delete_attachment', 'clear_dirsize_cache' );
|
|||
|
||||
function recurse_dirsize( $directory ) {
|
||||
$size = 0;
|
||||
if(substr($directory,-1) == '/') $directory = substr($directory,0,-1);
|
||||
if(!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) return false;
|
||||
|
||||
if ( substr( $directory, -1 ) == '/' )
|
||||
$directory = substr($directory,0,-1);
|
||||
|
||||
if ( !file_exists($directory) || !is_dir( $directory ) || !is_readable( $directory ) )
|
||||
return false;
|
||||
|
||||
if ($handle = opendir($directory)) {
|
||||
while(($file = readdir($handle)) !== false) {
|
||||
$path = $directory.'/'.$file;
|
||||
|
@ -1703,23 +1695,22 @@ function recurse_dirsize( $directory ) {
|
|||
$size += filesize($path);
|
||||
} elseif (is_dir($path)) {
|
||||
$handlesize = recurse_dirsize($path);
|
||||
if($handlesize >= 0) {
|
||||
if ($handlesize >= 0)
|
||||
$size += $handlesize;
|
||||
} else {
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
function upload_is_user_over_quota( $echo = true ) {
|
||||
if ( get_site_option( 'upload_space_check_disabled' ) ) {
|
||||
if ( get_site_option( 'upload_space_check_disabled' ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
$spaceAllowed = get_space_allowed();
|
||||
if ( empty( $spaceAllowed ) || !is_numeric( $spaceAllowed ) )
|
||||
$spaceAllowed = 10; // Default space allowed is 10 MB
|
||||
|
@ -1739,12 +1730,11 @@ function upload_is_user_over_quota( $echo = true ) {
|
|||
function check_upload_mimes( $mimes ) {
|
||||
$site_exts = explode( " ", get_site_option( "upload_filetypes" ) );
|
||||
foreach ( $site_exts as $ext ) {
|
||||
foreach ( $mimes as $ext_pattern => $mime ) {
|
||||
foreach ( $mimes as $ext_pattern => $mime )
|
||||
if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) {
|
||||
$site_mimes[$ext_pattern] = $mime;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $site_mimes;
|
||||
}
|
||||
|
||||
|
@ -1760,19 +1750,17 @@ function wpmu_log_new_registrations( $blog_id, $user_id ) {
|
|||
}
|
||||
|
||||
function fix_import_form_size( $size ) {
|
||||
if( upload_is_user_over_quota( false ) == true ) {
|
||||
if ( upload_is_user_over_quota( false ) == true )
|
||||
return 0;
|
||||
}
|
||||
|
||||
$spaceAllowed = 1024 * 1024 * get_space_allowed();
|
||||
$dirName = BLOGUPLOADDIR;
|
||||
$dirsize = get_dirsize($dirName) ;
|
||||
if( $size > $spaceAllowed - $dirsize ) {
|
||||
if ( $size > $spaceAllowed - $dirsize )
|
||||
return $spaceAllowed - $dirsize; // remaining space
|
||||
} else {
|
||||
else
|
||||
return $size; // default
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists('graceful_fail') ) :
|
||||
function graceful_fail( $message ) {
|
||||
|
@ -1818,10 +1806,9 @@ class delete_blog {
|
|||
if ( $current_blog->domain . $current_blog->path == $current_site->domain . $current_site->path )
|
||||
return false;
|
||||
|
||||
if( $this->reallydeleteblog == true ) {
|
||||
if ( $this->reallydeleteblog == true )
|
||||
wpmu_delete_blog( $wpdb->blogid );
|
||||
}
|
||||
}
|
||||
|
||||
function admin_menu() {
|
||||
global $current_blog, $current_site;
|
||||
|
@ -1919,9 +1906,9 @@ function redirect_this_site( $deprecated = '' ) {
|
|||
function upload_is_file_too_big( $upload ) {
|
||||
if ( is_array( $upload ) == false || defined( 'WP_IMPORTING' ) )
|
||||
return $upload;
|
||||
if( strlen( $upload[ 'bits' ] ) > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
|
||||
|
||||
if ( strlen( $upload[ 'bits' ] ) > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
|
||||
return sprintf(__( "This file is too big. Files must be less than %dKb in size.<br />" ), get_site_option( 'fileupload_maxk', 1500 ));
|
||||
}
|
||||
|
||||
return $upload;
|
||||
}
|
||||
|
@ -1929,10 +1916,9 @@ function upload_is_file_too_big( $upload ) {
|
|||
function wordpressmu_authenticate_siteadmin( $user, $password = '' ) {
|
||||
if ( is_super_admin( $user->user_login ) == false && ( $primary_blog = get_usermeta( $user->user_id, "primary_blog" ) ) ) {
|
||||
$details = get_blog_details( $primary_blog );
|
||||
if( is_object( $details ) && $details->spam == 1 ) {
|
||||
if ( is_object( $details ) && $details->spam == 1 )
|
||||
return new WP_Error('blog_suspended', __('Blog Suspended.'));
|
||||
}
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
@ -1955,9 +1941,8 @@ function wpmu_blogger_getUsersBlogs($args) {
|
|||
$rpc->query('wp.getUsersBlogs', $args[1], $args[2]);
|
||||
$blogs = $rpc->getResponse();
|
||||
|
||||
if ( isset($blogs['faultCode']) ) {
|
||||
if ( isset($blogs['faultCode']) )
|
||||
return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
|
||||
}
|
||||
|
||||
if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) {
|
||||
return $blogs;
|
||||
|
@ -2020,14 +2005,15 @@ function remove_tinymce_media_button( $buttons ) {
|
|||
}
|
||||
|
||||
function maybe_add_existing_user_to_blog() {
|
||||
if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) {
|
||||
if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
$parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
|
||||
$key = array_pop( $parts );
|
||||
|
||||
if ( $key == '' )
|
||||
$key = array_pop( $parts );
|
||||
|
||||
$details = get_option( "new_user_" . $key );
|
||||
add_existing_user_to_blog( $details );
|
||||
delete_option( 'new_user_' . $key );
|
||||
|
@ -2065,8 +2051,10 @@ function is_user_spammy( $username = 0 ) {
|
|||
$user_id = get_user_id_from_string( $username );
|
||||
}
|
||||
$u = new WP_User( $user_id );
|
||||
|
||||
if ( $u->spam == 1 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2104,12 +2092,11 @@ add_action( 'template_redirect', 'redirect_mu_dashboard' );
|
|||
function get_dashboard_blog() {
|
||||
global $current_site;
|
||||
|
||||
if ( get_site_option( 'dashboard_blog' ) == false ) {
|
||||
if ( get_site_option( 'dashboard_blog' ) == false )
|
||||
return get_blog_details( $current_site->blog_id );
|
||||
} else {
|
||||
else
|
||||
return get_blog_details( get_site_option( 'dashboard_blog' ) );
|
||||
}
|
||||
}
|
||||
|
||||
function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
|
||||
global $current_user, $wpdb;
|
||||
|
@ -2120,8 +2107,10 @@ function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
|
|||
$blog_id = $wpdb->blogid;
|
||||
|
||||
$local_key = $wpdb->base_prefix . $blog_id . "_" . $key;
|
||||
|
||||
if ( isset( $current_user->$local_key ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2177,12 +2166,11 @@ add_filter( 'upload_dir', 'mu_upload_dir' );
|
|||
|
||||
function users_can_register_signup_filter() {
|
||||
$registration = get_site_option('registration');
|
||||
if ( $registration == 'all' || $registration == 'user' ) {
|
||||
if ( $registration == 'all' || $registration == 'user' )
|
||||
return true;
|
||||
} else {
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
add_filter('option_users_can_register', 'users_can_register_signup_filter');
|
||||
|
||||
function welcome_user_msg_filter( $text ) {
|
||||
|
@ -2205,34 +2193,34 @@ Thanks!
|
|||
add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
|
||||
|
||||
function first_page_filter( $text ) {
|
||||
if ( !$text ) {
|
||||
if ( !$text )
|
||||
return __( "This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress." );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
add_filter( 'site_option_first_page', 'first_page_filter' );
|
||||
|
||||
function first_comment_filter( $text ) {
|
||||
if ( !$text ) {
|
||||
if ( !$text )
|
||||
return __( "This is an example of a WordPress comment, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many comments like this one or sub-comments as you like and manage all of your content inside of WordPress." );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
add_filter( 'site_option_first_comment', 'first_comment_filter' );
|
||||
|
||||
function first_comment_author_filter( $text ) {
|
||||
if ( !$text ) {
|
||||
if ( !$text )
|
||||
return __( "Mr WordPress" );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
add_filter( 'site_option_first_comment_author', 'first_comment_author_filter' );
|
||||
|
||||
function first_comment_url_filter( $text ) {
|
||||
global $current_site;
|
||||
if ( !$text ) {
|
||||
if ( !$text )
|
||||
return 'http://' . $current_site->domain . $current_site->path;
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
add_filter( 'site_option_first_comment_url', 'first_comment_url_filter' );
|
||||
|
@ -2265,6 +2253,7 @@ function force_ssl_content( $force = '' ) {
|
|||
$forced_content = $force;
|
||||
return $old_forced;
|
||||
}
|
||||
|
||||
return $forced_content;
|
||||
}
|
||||
|
||||
|
@ -2275,26 +2264,23 @@ function force_ssl_content( $force = '' ) {
|
|||
* @since 2.8.5
|
||||
**/
|
||||
function filter_SSL( $url) {
|
||||
if ( !is_string( $url ) ) {
|
||||
if ( !is_string( $url ) )
|
||||
return get_bloginfo( 'url' ); //return home blog url with proper scheme
|
||||
}
|
||||
|
||||
$arrURL = parse_url( $url );
|
||||
|
||||
if ( force_ssl_content() && is_ssl() ) {
|
||||
if ( 'http' === $arrURL['scheme'] && 'https' !== $arrURL['scheme'] ) {
|
||||
if ( 'http' === $arrURL['scheme'] && 'https' !== $arrURL['scheme'] )
|
||||
$url = str_replace( $arrURL['scheme'], 'https', $url );
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
function maybe_cancel_post_by_email() {
|
||||
if ( !defined( 'POST_BY_EMAIL' ) || !POST_BY_EMAIL ) {
|
||||
if ( !defined( 'POST_BY_EMAIL' ) || !POST_BY_EMAIL )
|
||||
die( __( 'This action has been disabled by the administrator' ) );
|
||||
}
|
||||
}
|
||||
add_action( 'wp-mail.php', 'maybe_cancel_post_by_email' );
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue