mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
wp.getUsersBlogs from josephscott. fixes #7130
git-svn-id: http://svn.automattic.com/wordpress/trunk@8075 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6142025639
commit
94eea943d6
53
xmlrpc.php
53
xmlrpc.php
@ -110,6 +110,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
function wp_xmlrpc_server() {
|
||||
$this->methods = array(
|
||||
// WordPress API
|
||||
'wp.getUsersBlogs' => 'this:wp_getUsersBlogs',
|
||||
'wp.getPage' => 'this:wp_getPage',
|
||||
'wp.getPages' => 'this:wp_getPages',
|
||||
'wp.newPage' => 'this:wp_newPage',
|
||||
@ -254,6 +255,53 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WordPress XML-RPC API
|
||||
* wp_getUsersBlogs
|
||||
*/
|
||||
function wp_getUsersBlogs( $args ) {
|
||||
// If this isn't on WPMU then just use blogger_getUsersBlogs
|
||||
if( !function_exists( 'is_site_admin' ) ) {
|
||||
array_unshift( $args, 1 );
|
||||
return $this->blogger_getUsersBlogs( $args );
|
||||
}
|
||||
|
||||
$this->escape( $args );
|
||||
|
||||
$username = $args[0];
|
||||
$password = $args[1];
|
||||
|
||||
if( !$this->login_pass_ok( $username, $password ) )
|
||||
return $this->error;
|
||||
|
||||
do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
|
||||
|
||||
$user = set_current_user( 0, $username );
|
||||
|
||||
$blogs = (array) get_blogs_of_user( $user->ID );
|
||||
$struct = array( );
|
||||
|
||||
foreach( $blogs as $blog ) {
|
||||
// Don't include blogs that aren't hosted at this site
|
||||
if( $blog->site_id != 1 )
|
||||
continue;
|
||||
|
||||
$blog_id = $blog->userblog_id;
|
||||
switch_to_blog($blog_id);
|
||||
$is_admin = current_user_can('level_8');
|
||||
|
||||
$struct[] = array(
|
||||
'isAdmin' => $is_admin,
|
||||
'url' => get_option( 'home' ) . '/',
|
||||
'blogid' => $blog_id,
|
||||
'blogName' => get_option( 'blogname' ),
|
||||
'xmlrpc' => get_option( 'home' ) . '/xmlrpc.php'
|
||||
);
|
||||
}
|
||||
|
||||
return $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* WordPress XML-RPC API
|
||||
* wp_getPage
|
||||
@ -841,7 +889,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
'isAdmin' => $is_admin,
|
||||
'url' => get_option('home') . '/',
|
||||
'blogid' => '1',
|
||||
'blogName' => get_option('blogname')
|
||||
'blogName' => get_option('blogname'),
|
||||
'xmlrpc' => get_option('home') . '/xmlrpc.php',
|
||||
);
|
||||
|
||||
return array($struct);
|
||||
@ -2459,4 +2508,4 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$wp_xmlrpc_server = new wp_xmlrpc_server();
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user