diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index e726adb0c7..8cb9c19fa3 100644 --- a/wp-includes/author-template.php +++ b/wp-includes/author-template.php @@ -269,7 +269,21 @@ function wp_list_authors($args = '') { $return = ''; /** @todo Move select to get_authors(). */ - $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"); + if( is_multisite() ) { + $users = get_users_of_blog(); + $author_ids = array(); + foreach ( (array) $users as $user ) { + $author_ids[] = $user->user_id; + } + if ( count($author_ids) > 0 ) { + $author_ids=implode(',', $author_ids ); + $authors = $wpdb->get_results( "SELECT ID, user_nicename from $wpdb->users WHERE ID IN($author_ids) " . ($exclude_admin ? "AND user_login <> 'admin' " : '') . "ORDER BY display_name" ); + } else { + $authors = array(); + } + } else { + $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"); + } $author_count = array(); foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row) { diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 2828c8a13a..463ff86625 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -987,6 +987,9 @@ function map_meta_cap( $cap, $user_id ) { function current_user_can( $capability ) { $current_user = wp_get_current_user(); + if( is_multisite() && is_super_admin() ) + return true; + if ( empty( $current_user ) ) return false; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 0d4ee8cc74..285906ccb6 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -327,9 +327,13 @@ function get_option( $setting, $default = false ) { return $pre; // prevent non-existent options from triggering multiple queries - $notoptions = wp_cache_get( 'notoptions', 'options' ); - if ( isset( $notoptions[$setting] ) ) - return $default; + if ( defined( 'WP_INSTALLING' ) && is_multisite() ) { + $notoptions = array(); + } else { + $notoptions = wp_cache_get( 'notoptions', 'options' ); + if ( isset( $notoptions[$setting] ) ) + return $default; + } $alloptions = wp_load_alloptions(); @@ -411,7 +415,8 @@ function form_option( $option ) { function wp_load_alloptions() { global $wpdb; - $alloptions = wp_cache_get( 'alloptions', 'options' ); + if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( !$alloptions ) { $suppress = $wpdb->suppress_errors(); @@ -421,7 +426,8 @@ function wp_load_alloptions() { $alloptions = array(); foreach ( (array) $alloptions_db as $o ) $alloptions[$o->option_name] = $o->option_value; - wp_cache_add( 'alloptions', $alloptions, 'options' ); + if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + wp_cache_add( 'alloptions', $alloptions, 'options' ); } return $alloptions; } @@ -623,6 +629,9 @@ function delete_option( $name ) { function delete_transient($transient) { global $_wp_using_ext_object_cache, $wpdb; + if( is_multisite() ) + do_action( 'delete_transient_' . $transient ); + if ( $_wp_using_ext_object_cache ) { return wp_cache_delete($transient, 'transient'); } else { @@ -690,6 +699,9 @@ function get_transient($transient) { function set_transient($transient, $value, $expiration = 0) { global $_wp_using_ext_object_cache, $wpdb; + if( is_multisite() ) + $value = apply_filters( 'pre_set_transient_' . $transient, $value ); + if ( $_wp_using_ext_object_cache ) { return wp_cache_set($transient, $value, 'transient', $expiration); } else { @@ -2174,6 +2186,15 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { if ( $upload['error'] !== false ) return $upload; + if( is_multisite() ) { + /* WPMU check file before writing it */ + $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) ); + if( is_array( $upload_bits_error ) == false ) { + $upload[ 'error' ] = $upload_bits_error; + return $upload; + } + } + $filename = wp_unique_filename( $upload['path'], $name ); $new_file = $upload['path'] . "/$filename"; diff --git a/wp-includes/post.php b/wp-includes/post.php index 7c917bf476..3690a1ef04 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3076,10 +3076,12 @@ function wp_get_attachment_url( $post_id = 0 ) { if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location $url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location - elseif ( false !== strpos($file, 'wp-content/uploads') ) - $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 ); - else - $url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir. + elseif ( !is_multisite() ) { + if ( false !== strpos($file, 'wp-content/uploads') ) + $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 ); + else + $url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir. + } } } diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 9c808139e5..12f4fc2324 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -1724,32 +1724,77 @@ class WP_Rewrite { if ( ! $this->using_permalinks()) { return ''; } - - $rules = ''; - $extra_indent = ''; - if ( $add_parent_tags ) { - $rules .= "".$end_of_line; - $rules .= $indent."".$end_of_line; - $rules .= $indent.$indent."".$end_of_line; - $rules .= $indent.$indent.$indent."".$end_of_line; - $extra_indent = $indent.$indent.$indent.$indent; - } - - $rules .= $extra_indent."".$end_of_line; - $rules .= $extra_indent.$indent."".$end_of_line; - $rules .= $extra_indent.$indent.$indent."".$end_of_line; - $rules .= $extra_indent.$indent.$indent.$indent."".$end_of_line; - $rules .= $extra_indent.$indent.$indent.$indent."".$end_of_line; - $rules .= $extra_indent.$indent.$indent."".$end_of_line; - $rules .= $extra_indent.$indent."".$end_of_line; - $rules .= $extra_indent.""; - - if ( $add_parent_tags ) { - $rules .= $end_of_line.$indent.$indent.$indent."".$end_of_line; - $rules .= $indent.$indent."".$end_of_line; - $rules .= $indent."".$end_of_line; - $rules .= ""; - } + + if( !is_multisite() ) { + $rules = ''; + $extra_indent = ''; + if ( $add_parent_tags ) { + $rules .= "".$end_of_line; + $rules .= $indent."".$end_of_line; + $rules .= $indent.$indent."".$end_of_line; + $rules .= $indent.$indent.$indent."".$end_of_line; + $extra_indent = $indent.$indent.$indent.$indent; + } + + $rules .= $extra_indent."".$end_of_line; + $rules .= $extra_indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent.$indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent.$indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent."".$end_of_line; + $rules .= $extra_indent.""; + + if ( $add_parent_tags ) { + $rules .= $end_of_line.$indent.$indent.$indent."".$end_of_line; + $rules .= $indent.$indent."".$end_of_line; + $rules .= $indent."".$end_of_line; + $rules .= ""; + } + } else { + $rules = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + } $rules = apply_filters('iis7_url_rewrite_rules', $rules); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 6e3c485e53..68157a6f03 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1417,16 +1417,30 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { } if ( ! $term_id = is_term($slug) ) { - if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) - return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); - $term_id = (int) $wpdb->insert_id; + if ( !is_multisite() ) { + if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) + return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); + $term_id = (int) $wpdb->insert_id; + } else { + $maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" ); + $term_id = mt_rand( $maxterm+100, $maxterm+4000 ); + if ( false === $wpdb->insert( $wpdb->terms, compact( 'term_id', 'name', 'slug', 'term_group' ) ) ) + return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); + } } else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) { // If the taxonomy supports hierarchy and the term has a parent, make the slug unique // by incorporating parent slugs. - $slug = wp_unique_term_slug($slug, (object) $args); - if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) - return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); - $term_id = (int) $wpdb->insert_id; + $slug = wp_unique_term_slug($slug, (object) $args); + if( !is_multisite() ) { + if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) + return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); + $term_id = (int) $wpdb->insert_id; + } else { + $maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" ); + $term_id = mt_rand( $maxterm+100, $maxterm+4000 ); + if ( false === $wpdb->insert( $wpdb->terms, compact( 'term_id','name', 'slug', 'term_group' ) ) ) + return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); + } } if ( empty($slug) ) { diff --git a/wp-includes/user.php b/wp-includes/user.php index 06d7159e2e..771ea26f99 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -279,7 +279,8 @@ function get_users_of_blog( $id = '' ) { global $wpdb, $blog_id; if ( empty($id) ) $id = (int) $blog_id; - $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$wpdb->prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); + $blog_prefix = $wpdb->get_blog_prefix($id); + $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); return $users; } diff --git a/wp-login.php b/wp-login.php index 19f49d4693..a28dc0e1d3 100644 --- a/wp-login.php +++ b/wp-login.php @@ -39,7 +39,7 @@ if ( force_ssl_admin() && !is_ssl() ) { * @param WP_Error $wp_error Optional. WordPress Error Object */ function login_header($title = 'Log In', $message = '', $wp_error = '') { - global $error, $is_iphone, $interim_login; + global $error, $is_iphone, $interim_login, $current_site; // Don't index any of these forms add_filter( 'pre_option_blog_public', create_function( '$a', 'return 0;' ) ); @@ -74,9 +74,12 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') { do_action('login_head'); ?> - +

- +

+update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); } $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; - $message .= get_option('siteurl') . "\r\n\r\n"; + if( !is_multisite() ) { + $message .= get_option('siteurl') . "\r\n\r\n"; + } else { + $message .= 'http://' . trailingslashit( $current_site->domain . $current_site->path ) . "\r\n\r\n"; + } $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; - $message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n"; + if( !is_multisite() ) { + $message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n"; + } else { + $message .= 'http://' . trailingslashit( $current_site->domain . $current_site->path ) . "wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login) . "\r\n"; + } // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. @@ -398,6 +409,11 @@ case 'rp' : break; case 'register' : + if( is_multisite() ) { + // WPMU doesn't use this + wp_redirect( apply_filters( 'wp_signup_location', get_bloginfo('wpurl') . '/wp-signup.php' ) ); + exit; + } if ( !get_option('users_can_register') ) { wp_redirect('wp-login.php?registration=disabled'); exit();