merge in multisite login, wp-includes, See #11644
git-svn-id: http://svn.automattic.com/wordpress/trunk@12697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fd5266e0a9
commit
7b64248bc8
|
@ -269,7 +269,21 @@ function wp_list_authors($args = '') {
|
|||
$return = '';
|
||||
|
||||
/** @todo Move select to get_authors(). */
|
||||
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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -327,9 +327,13 @@ function get_option( $setting, $default = false ) {
|
|||
return $pre;
|
||||
|
||||
// prevent non-existent options from triggering multiple queries
|
||||
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,6 +415,7 @@ function form_option( $option ) {
|
|||
function wp_load_alloptions() {
|
||||
global $wpdb;
|
||||
|
||||
if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
|
||||
$alloptions = wp_cache_get( 'alloptions', 'options' );
|
||||
|
||||
if ( !$alloptions ) {
|
||||
|
@ -421,6 +426,7 @@ function wp_load_alloptions() {
|
|||
$alloptions = array();
|
||||
foreach ( (array) $alloptions_db as $o )
|
||||
$alloptions[$o->option_name] = $o->option_value;
|
||||
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";
|
||||
|
|
|
@ -3076,12 +3076,14 @@ 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') )
|
||||
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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty($url) ) //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recomended to rely upon this.
|
||||
$url = get_the_guid( $post->ID );
|
||||
|
|
|
@ -1725,6 +1725,7 @@ class WP_Rewrite {
|
|||
return '';
|
||||
}
|
||||
|
||||
if( !is_multisite() ) {
|
||||
$rules = '';
|
||||
$extra_indent = '';
|
||||
if ( $add_parent_tags ) {
|
||||
|
@ -1750,6 +1751,50 @@ class WP_Rewrite {
|
|||
$rules .= $indent."</system.webServer>".$end_of_line;
|
||||
$rules .= "</configuration>";
|
||||
}
|
||||
} else {
|
||||
$rules = '<rule name="wordpress - strip index.php" stopProcessing="false">
|
||||
<match url="^index.php/(.*)$" />
|
||||
<action type="Rewrite" url="{R:1}" />
|
||||
</rule>
|
||||
<rule name="wordpress - 1" stopProcessing="true">
|
||||
<match url="^(.*/)?files/$" />
|
||||
<action type="Rewrite" url="index.php" />
|
||||
</rule>
|
||||
<rule name="wordpress - 2" stopProcessing="true">
|
||||
<match url="^(.*/)?files/(.*)" />
|
||||
<conditions>
|
||||
<add input="{REQUEST_URI}" negate="true" pattern=".*wp-content/plugins.*"/>
|
||||
</conditions>
|
||||
<action type="Rewrite" url="wp-content/blogs.php?file={R:2}" appendQueryString="false" />
|
||||
</rule>
|
||||
<rule name="wordpress - 3" stopProcessing="true">
|
||||
<match url="^(.+)$" />
|
||||
<conditions>
|
||||
<add input="{REQUEST_URI}" pattern="^.*/wp-admin$" />
|
||||
</conditions>
|
||||
<action type="Redirect" url="{R:1}/" redirectType="Permanent" />
|
||||
</rule>
|
||||
<rule name="wordpress - 4" stopProcessing="true">
|
||||
<match url="."/>
|
||||
<conditions logicalGrouping="MatchAny">
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" />
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" />
|
||||
</conditions>
|
||||
<action type="None" />
|
||||
</rule>
|
||||
<rule name="wordpress - 5" stopProcessing="true">
|
||||
<match url="^([_0-9a-zA-Z-]+/)?(wp-.*)" />
|
||||
<action type="Rewrite" url="{R:2}" />
|
||||
</rule>
|
||||
<rule name="wordpress - 6" stopProcessing="true">
|
||||
<match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" />
|
||||
<action type="Rewrite" url="{R:2}" />
|
||||
</rule>
|
||||
<rule name="wordpress - 7" stopProcessing="true">
|
||||
<match url="." />
|
||||
<action type="Rewrite" url="index.php" />
|
||||
</rule>';
|
||||
}
|
||||
|
||||
$rules = apply_filters('iis7_url_rewrite_rules', $rules);
|
||||
|
||||
|
|
|
@ -1417,16 +1417,30 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||
}
|
||||
|
||||
if ( ! $term_id = is_term($slug) ) {
|
||||
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( !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) ) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
24
wp-login.php
24
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'); ?>
|
||||
</head>
|
||||
<body class="login">
|
||||
|
||||
<?php if( !is_multisite() ) { ?>
|
||||
<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>
|
||||
<?php
|
||||
<?php } else { ?>
|
||||
<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://' . $current_site->domain . $current_site->path ); ?>" title="<?php echo apply_filters('login_headertitle', $current_site->site_name ); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1>
|
||||
<?php }
|
||||
|
||||
$message = apply_filters('login_message', $message);
|
||||
if ( !empty( $message ) ) echo $message . "\n";
|
||||
|
||||
|
@ -113,7 +116,7 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
|
|||
* @return bool|WP_Error True: when finish. WP_Error on error
|
||||
*/
|
||||
function retrieve_password() {
|
||||
global $wpdb;
|
||||
global $wpdb, $current_site;
|
||||
|
||||
$errors = new WP_Error();
|
||||
|
||||
|
@ -162,10 +165,18 @@ function retrieve_password() {
|
|||
$wpdb->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";
|
||||
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";
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue