Mainstream things that don't need to be multisite only. Formatting cleanups. see #11644

git-svn-id: http://svn.automattic.com/wordpress/trunk@12699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-01-11 22:23:58 +00:00
parent d24ac0a095
commit b4447f9f9c
4 changed files with 35 additions and 41 deletions

View File

@ -269,26 +269,20 @@ function wp_list_authors($args = '') {
$return = ''; $return = '';
/** @todo Move select to get_authors(). */ /** @todo Move select to get_authors(). */
if( is_multisite() ) { $users = get_users_of_blog();
$users = get_users_of_blog(); $author_ids = array();
$author_ids = array(); foreach ( (array) $users as $user )
foreach ( (array) $users as $user ) { $author_ids[] = $user->user_id;
$author_ids[] = $user->user_id; if ( count($author_ids) > 0 ) {
} $author_ids = implode(',', $author_ids );
if ( count($author_ids) > 0 ) { $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" );
$author_ids=implode(',', $author_ids ); } else {
$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" ); $authors = array();
} 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(); $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) { 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 )
$author_count[$row->post_author] = $row->count; $author_count[$row->post_author] = $row->count;
}
foreach ( (array) $authors as $author ) { foreach ( (array) $authors as $author ) {

View File

@ -987,8 +987,8 @@ function map_meta_cap( $cap, $user_id ) {
function current_user_can( $capability ) { function current_user_can( $capability ) {
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
if( is_multisite() && is_super_admin() ) if ( is_multisite() && is_super_admin() )
return true; return true;
if ( empty( $current_user ) ) if ( empty( $current_user ) )
return false; return false;

View File

@ -1417,30 +1417,30 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
} }
if ( ! $term_id = is_term($slug) ) { if ( ! $term_id = is_term($slug) ) {
if ( !is_multisite() ) { if ( !is_multisite() ) {
if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 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); return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
$term_id = (int) $wpdb->insert_id; $term_id = (int) $wpdb->insert_id;
} else { } else {
$maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" ); $maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" );
$term_id = mt_rand( $maxterm+100, $maxterm+4000 ); $term_id = mt_rand( $maxterm+100, $maxterm+4000 );
if ( false === $wpdb->insert( $wpdb->terms, compact( 'term_id', 'name', 'slug', 'term_group' ) ) ) 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); 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) ) { } else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) {
// If the taxonomy supports hierarchy and the term has a parent, make the slug unique // If the taxonomy supports hierarchy and the term has a parent, make the slug unique
// by incorporating parent slugs. // by incorporating parent slugs.
$slug = wp_unique_term_slug($slug, (object) $args); $slug = wp_unique_term_slug($slug, (object) $args);
if( !is_multisite() ) { if ( !is_multisite() ) {
if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) 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); return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
$term_id = (int) $wpdb->insert_id; $term_id = (int) $wpdb->insert_id;
} else { } else {
$maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" ); $maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" );
$term_id = mt_rand( $maxterm+100, $maxterm+4000 ); $term_id = mt_rand( $maxterm+100, $maxterm+4000 );
if ( false === $wpdb->insert( $wpdb->terms, compact( 'term_id','name', 'slug', 'term_group' ) ) ) 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); return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
} }
} }
if ( empty($slug) ) { if ( empty($slug) ) {

View File

@ -279,7 +279,7 @@ function get_users_of_blog( $id = '' ) {
global $wpdb, $blog_id; global $wpdb, $blog_id;
if ( empty($id) ) if ( empty($id) )
$id = (int) $blog_id; $id = (int) $blog_id;
$blog_prefix = $wpdb->get_blog_prefix($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" ); $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; return $users;
} }