WordPress.org

Make WordPress Core

Changeset 34574


Ignore:
Timestamp:
09/26/2015 04:34:50 AM (6 years ago)
Author:
wonderboymusic
Message:

XML-RPC: In wp_xmlrpc_server::wp_getUsersBlogs(), return the isPrimary flag for each blog.

Props SergeyBiryukov, daniloercoli.
Fixes #25958.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r34573 r34574  
    544544     * @return array|IXR_Error Array contains:
    545545     *  - 'isAdmin'
     546     *  - 'isPrimary' - whether the blog is the user's primary blog
    546547     *  - 'url'
    547548     *  - 'blogid'
     
    579580        $blogs = (array) get_blogs_of_user( $user->ID );
    580581        $struct = array();
     582        $primary_blog_id = 0;
     583        $active_blog = get_active_blog_for_user( $user->ID );
     584        if ( $active_blog ) {
     585            $primary_blog_id = (int) $active_blog->blog_id;
     586        }
    581587
    582588        foreach ( $blogs as $blog ) {
     
    590596
    591597            $is_admin = current_user_can( 'manage_options' );
     598            $is_primary = ( (int) $blog_id === $primary_blog_id );
    592599
    593600            $struct[] = array(
    594                 'isAdmin'       => $is_admin,
    595                 'url'           => home_url( '/' ),
    596                 'blogid'        => (string) $blog_id,
    597                 'blogName'      => get_option( 'blogname' ),
    598                 'xmlrpc'        => site_url( 'xmlrpc.php', 'rpc' ),
     601                'isAdmin'   => $is_admin,
     602                'isPrimary' => $is_primary,
     603                'url'       => home_url( '/' ),
     604                'blogid'    => (string) $blog_id,
     605                'blogName'  => get_option( 'blogname' ),
     606                'xmlrpc'    => site_url( 'xmlrpc.php', 'rpc' ),
    599607            );
    600608
Note: See TracChangeset for help on using the changeset viewer.