mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
XML-RPC: In wp_xmlrpc_server::wp_getUsersBlogs()
, return the isPrimary
flag for each blog.
Props SergeyBiryukov, daniloercoli. Fixes #25958. Built from https://develop.svn.wordpress.org/trunk@34574 git-svn-id: http://core.svn.wordpress.org/trunk@34538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9b253bbc7b
commit
c8b308a647
@ -543,6 +543,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* }
|
||||
* @return array|IXR_Error Array contains:
|
||||
* - 'isAdmin'
|
||||
* - 'isPrimary' - whether the blog is the user's primary blog
|
||||
* - 'url'
|
||||
* - 'blogid'
|
||||
* - 'blogName'
|
||||
@ -578,6 +579,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$blogs = (array) get_blogs_of_user( $user->ID );
|
||||
$struct = array();
|
||||
$primary_blog_id = 0;
|
||||
$active_blog = get_active_blog_for_user( $user->ID );
|
||||
if ( $active_blog ) {
|
||||
$primary_blog_id = (int) $active_blog->blog_id;
|
||||
}
|
||||
|
||||
foreach ( $blogs as $blog ) {
|
||||
// Don't include blogs that aren't hosted at this site.
|
||||
@ -589,13 +595,15 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
switch_to_blog( $blog_id );
|
||||
|
||||
$is_admin = current_user_can( 'manage_options' );
|
||||
$is_primary = ( (int) $blog_id === $primary_blog_id );
|
||||
|
||||
$struct[] = array(
|
||||
'isAdmin' => $is_admin,
|
||||
'url' => home_url( '/' ),
|
||||
'blogid' => (string) $blog_id,
|
||||
'blogName' => get_option( 'blogname' ),
|
||||
'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ),
|
||||
'isAdmin' => $is_admin,
|
||||
'isPrimary' => $is_primary,
|
||||
'url' => home_url( '/' ),
|
||||
'blogid' => (string) $blog_id,
|
||||
'blogName' => get_option( 'blogname' ),
|
||||
'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ),
|
||||
);
|
||||
|
||||
restore_current_blog();
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34573';
|
||||
$wp_version = '4.4-alpha-34574';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user