Lose get_ordered_blogs_of_user() and set_visibility(). Not using them yet. see #14772
git-svn-id: http://svn.automattic.com/wordpress/trunk@15851 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fe9c746809
commit
c4599ec729
|
@ -12,7 +12,7 @@ class WP_Admin_Bar {
|
|||
$this->menu = new stdClass;
|
||||
|
||||
/* Populate settings we need for the menu based on the current user. */
|
||||
$this->user->blogs = get_ordered_blogs_of_user( $current_user->id );
|
||||
$this->user->blogs = get_blogs_of_user( $current_user->id );
|
||||
if ( is_multisite() ) {
|
||||
$this->user->active_blog = get_active_blog_for_user( $current_user->id );
|
||||
$this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
|
||||
|
|
|
@ -637,83 +637,6 @@ function get_blogs_of_user( $id, $all = false ) {
|
|||
return apply_filters( 'get_blogs_of_user', $blog_deets, $id, $all );
|
||||
}
|
||||
|
||||
function get_ordered_blogs_of_user( $user_id, $visibility = true ) {
|
||||
$newblogs = $ordered = array();
|
||||
$blogs = get_blogs_of_user( $user_id );
|
||||
$order_meta = get_user_meta( $user_id, 'blog_order' );
|
||||
$visible_meta = get_user_meta( $user_id, 'blog_visibility' );
|
||||
|
||||
$order = $order_meta;
|
||||
if ( !is_array( $order ) )
|
||||
$order = array();
|
||||
|
||||
$visible = $visible_meta;
|
||||
if ( !is_array( $visible ) )
|
||||
$visible = array();
|
||||
|
||||
// Index the blogs by userblog_id and set the visibility flag
|
||||
// Visibility is on by default, unless a linked site then off
|
||||
foreach ( $blogs as $blog ) {
|
||||
$blog->visible = true;
|
||||
|
||||
if ( isset( $visible[$blog->userblog_id] ) )
|
||||
$blog->visible = $visible[$blog->userblog_id];
|
||||
|
||||
$newblogs[$blog->userblog_id] = $blog;
|
||||
}
|
||||
|
||||
// Add the blogs to our list by order
|
||||
foreach ( (array)$order as $id ) {
|
||||
// A previous change was saving the entire blog details into ordered, not just the blog ID - this detects it
|
||||
if ( is_object( $id ) && isset( $id->userblog_id ) )
|
||||
$id = $id->userblog_id;
|
||||
|
||||
if ( is_numeric( $id ) && isset( $newblogs[intval( $id )] ) ) {
|
||||
$ordered[$id] = $newblogs[$id];
|
||||
unset( $newblogs[$id] );
|
||||
}
|
||||
}
|
||||
|
||||
// Add any blog not yet ordered to the end
|
||||
foreach ( $newblogs as $blog ) {
|
||||
$ordered[$blog->userblog_id] = $blog;
|
||||
}
|
||||
|
||||
// If we're only interested in visible blogs then remove the rest
|
||||
if ( $visibility ) {
|
||||
foreach ( (array)$ordered as $pos => $blog ) {
|
||||
if ( $blog->visible == false )
|
||||
unset( $ordered[$pos] );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Set the order and visible options if the user doesn't have any,
|
||||
// but rate limit it so that the global DB doesn't get hammered
|
||||
if ( !is_array( $order_meta ) && ( 1 == mt_rand( 1, 10 ) ) )
|
||||
update_usermeta( $user_id, 'blog_order', array() );
|
||||
|
||||
if ( !is_array( $visible_meta ) && ( 1 == mt_rand( 1, 10 ) ) )
|
||||
update_usermeta( $user_id, 'blog_visibility', array() );
|
||||
*/
|
||||
|
||||
return apply_filters( 'ordered_blogs', $ordered );
|
||||
}
|
||||
|
||||
function set_blog_visibility( $blog_id, $visible ) {
|
||||
global $current_user;
|
||||
|
||||
if ( is_blog_user( $blog_id ) ) {
|
||||
$visibility = get_user_meta( $current_user->ID, 'blog_visibility' );
|
||||
if ( !is_array( $visibility ) )
|
||||
$visibility = array();
|
||||
|
||||
$visibility[$blog_id] = $visible;
|
||||
|
||||
update_user_meta( $current_user->ID, 'blog_visibility', $visibility );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current user belong to a given blog.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue