Integrate wpmu_blogger_getUsersBlogs() directly into xmlrpc.php. see #11644
git-svn-id: http://svn.automattic.com/wordpress/trunk@12852 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e6b0d64b4e
commit
9b79d3d516
|
@ -2,7 +2,6 @@
|
|||
// Users
|
||||
add_filter ( 'wpmu_validate_user_signup', 'signup_nonce_check' );
|
||||
add_action ( 'init', 'maybe_add_existing_user_to_blog' );
|
||||
add_filter ( 'xmlrpc_methods', 'attach_wpmu_xmlrpc' );
|
||||
add_filter ( 'wp_authenticate_user', 'wordpressmu_authenticate_siteadmin', 10, 2 );
|
||||
add_action ( 'wpmu_new_user', 'newuser_notify_siteadmin' );
|
||||
add_action ( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 );
|
||||
|
|
|
@ -1789,38 +1789,6 @@ function wordpressmu_wp_mail_from( $email ) {
|
|||
return $email;
|
||||
}
|
||||
|
||||
/*
|
||||
XMLRPC getUsersBlogs() for a multiblog environment
|
||||
http://trac.mu.wordpress.org/attachment/ticket/551/xmlrpc-mu.php
|
||||
*/
|
||||
function wpmu_blogger_getUsersBlogs( $args ) {
|
||||
global $current_blog;
|
||||
$domain = $current_blog->domain;
|
||||
$path = $current_blog->path . 'xmlrpc.php';
|
||||
|
||||
$rpc = new IXR_Client("http://{$domain}{$path}");
|
||||
$rpc->query('wp.getUsersBlogs', $args[1], $args[2]);
|
||||
$blogs = $rpc->getResponse();
|
||||
|
||||
if ( isset($blogs['faultCode']) )
|
||||
return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
|
||||
|
||||
if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) {
|
||||
return $blogs;
|
||||
} else {
|
||||
foreach ( (array) $blogs as $blog ) {
|
||||
if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) )
|
||||
return array($blog);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
function attach_wpmu_xmlrpc( $methods ) {
|
||||
$methods['blogger.getUsersBlogs'] = 'wpmu_blogger_getUsersBlogs';
|
||||
return $methods;
|
||||
}
|
||||
|
||||
function mu_locale( $locale ) {
|
||||
if ( defined('WP_INSTALLING') == false ) {
|
||||
$mu_locale = get_option('WPLANG');
|
||||
|
|
35
xmlrpc.php
35
xmlrpc.php
|
@ -452,9 +452,9 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[0];
|
||||
$password = $args[1];
|
||||
|
||||
if ( !$user = $this->login($username, $password) ) {
|
||||
if ( !$user = $this->login($username, $password) )
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
||||
do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
|
||||
|
||||
|
@ -1546,6 +1546,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
* @return array
|
||||
*/
|
||||
function blogger_getUsersBlogs($args) {
|
||||
if ( is_multisite() )
|
||||
return _multisite_getUsersBlogs($args);
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
|
@ -1570,6 +1572,35 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
return array($struct);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private function for retrieving a users blogs for multisite setups
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _multisite_getUsersBlogs($args) {
|
||||
global $current_blog;
|
||||
$domain = $current_blog->domain;
|
||||
$path = $current_blog->path . 'xmlrpc.php';
|
||||
$protocol = is_ssl() ? 'https' : 'http';
|
||||
|
||||
$rpc = new IXR_Client("$protocol://{$domain}{$path}");
|
||||
$rpc->query('wp.getUsersBlogs', $args[1], $args[2]);
|
||||
$blogs = $rpc->getResponse();
|
||||
|
||||
if ( isset($blogs['faultCode']) )
|
||||
return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
|
||||
|
||||
if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) {
|
||||
return $blogs;
|
||||
} else {
|
||||
foreach ( (array) $blogs as $blog ) {
|
||||
if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) )
|
||||
return array($blog);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve user's data.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue