Add xmlrpc_call actions. Cleanup some whitespace.
git-svn-id: https://develop.svn.wordpress.org/trunk@6473 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6d13a7f175
commit
7abea37f4f
112
xmlrpc.php
112
xmlrpc.php
|
@ -231,6 +231,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.getPage");
|
||||||
|
|
||||||
// Lookup page info.
|
// Lookup page info.
|
||||||
$page = get_page($page_id);
|
$page = get_page($page_id);
|
||||||
|
|
||||||
|
@ -313,6 +315,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.getPages");
|
||||||
|
|
||||||
// Lookup info on pages.
|
// Lookup info on pages.
|
||||||
$pages = get_pages();
|
$pages = get_pages();
|
||||||
$num_pages = count($pages);
|
$num_pages = count($pages);
|
||||||
|
@ -351,6 +355,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.newPage");
|
||||||
|
|
||||||
// Set the user context and check if they are allowed
|
// Set the user context and check if they are allowed
|
||||||
// to add new pages.
|
// to add new pages.
|
||||||
$user = set_current_user(0, $username);
|
$user = set_current_user(0, $username);
|
||||||
|
@ -381,6 +387,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.deletePage");
|
||||||
|
|
||||||
// Get the current page based on the page_id and
|
// Get the current page based on the page_id and
|
||||||
// make sure it is a page and not a post.
|
// make sure it is a page and not a post.
|
||||||
$actual_page = wp_get_single_post($page_id, ARRAY_A);
|
$actual_page = wp_get_single_post($page_id, ARRAY_A);
|
||||||
|
@ -423,6 +431,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.editPage");
|
||||||
|
|
||||||
// Get the page data and make sure it is a page.
|
// Get the page data and make sure it is a page.
|
||||||
$actual_page = wp_get_single_post($page_id, ARRAY_A);
|
$actual_page = wp_get_single_post($page_id, ARRAY_A);
|
||||||
if(
|
if(
|
||||||
|
@ -471,6 +481,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.getPageList");
|
||||||
|
|
||||||
// Get list of pages ids and titles
|
// Get list of pages ids and titles
|
||||||
$page_list = $wpdb->get_results("
|
$page_list = $wpdb->get_results("
|
||||||
SELECT ID page_id,
|
SELECT ID page_id,
|
||||||
|
@ -515,6 +527,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.getAuthors");
|
||||||
|
|
||||||
return(get_users_of_blog());
|
return(get_users_of_blog());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,6 +548,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.newCategory");
|
||||||
|
|
||||||
// Set the user context and make sure they are
|
// Set the user context and make sure they are
|
||||||
// allowed to add a category.
|
// allowed to add a category.
|
||||||
set_current_user(0, $username);
|
set_current_user(0, $username);
|
||||||
|
@ -588,6 +604,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.deleteCategory");
|
||||||
|
|
||||||
set_current_user(0, $username);
|
set_current_user(0, $username);
|
||||||
if( !current_user_can("manage_categories") ) {
|
if( !current_user_can("manage_categories") ) {
|
||||||
return new IXR_Error( 401, __( "Sorry, you do not the right to delete a category." ) );
|
return new IXR_Error( 401, __( "Sorry, you do not the right to delete a category." ) );
|
||||||
|
@ -614,6 +632,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return($this->error);
|
return($this->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "wp.suggestCategories");
|
||||||
|
|
||||||
$category_suggestions = array();
|
$category_suggestions = array();
|
||||||
$args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category);
|
$args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category);
|
||||||
foreach ( (array) get_categories($args) as $cat ) {
|
foreach ( (array) get_categories($args) as $cat ) {
|
||||||
|
@ -644,6 +664,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "blogger.getUsersBlogs");
|
||||||
|
|
||||||
set_current_user(0, $user_login);
|
set_current_user(0, $user_login);
|
||||||
$is_admin = current_user_can('level_8');
|
$is_admin = current_user_can('level_8');
|
||||||
|
|
||||||
|
@ -670,6 +692,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "blogger.getUserInfo");
|
||||||
|
|
||||||
$user_data = get_userdatabylogin($user_login);
|
$user_data = get_userdatabylogin($user_login);
|
||||||
|
|
||||||
$struct = array(
|
$struct = array(
|
||||||
|
@ -698,6 +722,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "blogger.getPost");
|
||||||
|
|
||||||
$post_data = wp_get_single_post($post_ID, ARRAY_A);
|
$post_data = wp_get_single_post($post_ID, ARRAY_A);
|
||||||
|
|
||||||
$categories = implode(',', wp_get_post_categories($post_ID));
|
$categories = implode(',', wp_get_post_categories($post_ID));
|
||||||
|
@ -731,6 +757,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "blogger.getRecentPosts");
|
||||||
|
|
||||||
$posts_list = wp_get_recent_posts($num_posts);
|
$posts_list = wp_get_recent_posts($num_posts);
|
||||||
|
|
||||||
if (!$posts_list) {
|
if (!$posts_list) {
|
||||||
|
@ -779,6 +807,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "blogger.getTemplate");
|
||||||
|
|
||||||
set_current_user(0, $user_login);
|
set_current_user(0, $user_login);
|
||||||
if ( !current_user_can('edit_themes') ) {
|
if ( !current_user_can('edit_themes') ) {
|
||||||
return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
|
return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
|
||||||
|
@ -804,33 +834,35 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
$this->escape($args);
|
$this->escape($args);
|
||||||
|
|
||||||
$blog_ID = (int) $args[1];
|
$blog_ID = (int) $args[1];
|
||||||
$user_login = $args[2];
|
$user_login = $args[2];
|
||||||
$user_pass = $args[3];
|
$user_pass = $args[3];
|
||||||
$content = $args[4];
|
$content = $args[4];
|
||||||
$template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
|
$template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
|
||||||
|
|
||||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_current_user(0, $user_login);
|
do_action("xmlrpc_call", "blogger.setTemplate");
|
||||||
if ( !current_user_can('edit_themes') ) {
|
|
||||||
return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* warning: here we make the assumption that the blog's URL is on the same server */
|
set_current_user(0, $user_login);
|
||||||
$filename = get_option('home') . '/';
|
if ( !current_user_can('edit_themes') ) {
|
||||||
$filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
|
return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
|
||||||
|
}
|
||||||
|
|
||||||
if ($f = fopen($filename, 'w+')) {
|
/* warning: here we make the assumption that the blog's URL is on the same server */
|
||||||
fwrite($f, $content);
|
$filename = get_option('home') . '/';
|
||||||
fclose($f);
|
$filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
|
||||||
} else {
|
|
||||||
return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
if ($f = fopen($filename, 'w+')) {
|
||||||
|
fwrite($f, $content);
|
||||||
|
fclose($f);
|
||||||
|
} else {
|
||||||
|
return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -849,6 +881,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "blogger.newPost");
|
||||||
|
|
||||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||||
$user = set_current_user(0, $user_login);
|
$user = set_current_user(0, $user_login);
|
||||||
if ( !current_user_can($cap) )
|
if ( !current_user_can($cap) )
|
||||||
|
@ -896,6 +930,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "blogger.editPost");
|
||||||
|
|
||||||
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
|
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
|
||||||
|
|
||||||
if (!$actual_post) {
|
if (!$actual_post) {
|
||||||
|
@ -943,6 +979,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "blogger.deletePost");
|
||||||
|
|
||||||
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
|
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
|
||||||
|
|
||||||
if (!$actual_post) {
|
if (!$actual_post) {
|
||||||
|
@ -982,6 +1020,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "metaWeblog.newPost");
|
||||||
|
|
||||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||||
$user = set_current_user(0, $user_login);
|
$user = set_current_user(0, $user_login);
|
||||||
if ( !current_user_can($cap) )
|
if ( !current_user_can($cap) )
|
||||||
|
@ -1194,9 +1234,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$publish = $args[4];
|
$publish = $args[4];
|
||||||
|
|
||||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "metaWeblog.editPost");
|
||||||
|
|
||||||
$user = set_current_user(0, $user_login);
|
$user = set_current_user(0, $user_login);
|
||||||
|
|
||||||
// The post_type defaults to post, but could also be page.
|
// The post_type defaults to post, but could also be page.
|
||||||
|
@ -1406,6 +1448,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "metaWeblog.getPost");
|
||||||
|
|
||||||
$postdata = wp_get_single_post($post_ID, ARRAY_A);
|
$postdata = wp_get_single_post($post_ID, ARRAY_A);
|
||||||
|
|
||||||
if ($postdata['post_date'] != '') {
|
if ($postdata['post_date'] != '') {
|
||||||
|
@ -1482,6 +1526,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "metaWeblog.getRecentPosts");
|
||||||
|
|
||||||
$posts_list = wp_get_recent_posts($num_posts);
|
$posts_list = wp_get_recent_posts($num_posts);
|
||||||
|
|
||||||
if (!$posts_list) {
|
if (!$posts_list) {
|
||||||
|
@ -1569,6 +1615,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "metaWeblog.getCategories");
|
||||||
|
|
||||||
$categories_struct = array();
|
$categories_struct = array();
|
||||||
|
|
||||||
if ( $cats = get_categories('get=all') ) {
|
if ( $cats = get_categories('get=all') ) {
|
||||||
|
@ -1609,6 +1657,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
if ( !$this->login_pass_ok($user_login, $user_pass) )
|
if ( !$this->login_pass_ok($user_login, $user_pass) )
|
||||||
return $this->error;
|
return $this->error;
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "metaWeblog.newMediaObject");
|
||||||
|
|
||||||
set_current_user(0, $user_login);
|
set_current_user(0, $user_login);
|
||||||
if ( !current_user_can('upload_files') ) {
|
if ( !current_user_can('upload_files') ) {
|
||||||
logIO('O', '(MW) User does not have upload_files capability');
|
logIO('O', '(MW) User does not have upload_files capability');
|
||||||
|
@ -1725,6 +1775,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "mt.getCategoryList");
|
||||||
|
|
||||||
$categories_struct = array();
|
$categories_struct = array();
|
||||||
|
|
||||||
// FIXME: can we avoid using direct SQL there?
|
// FIXME: can we avoid using direct SQL there?
|
||||||
|
@ -1754,6 +1806,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "mt.getPostCategories");
|
||||||
|
|
||||||
$categories = array();
|
$categories = array();
|
||||||
$catids = wp_get_post_categories(intval($post_ID));
|
$catids = wp_get_post_categories(intval($post_ID));
|
||||||
// first listed category will be the primary category
|
// first listed category will be the primary category
|
||||||
|
@ -1785,6 +1839,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "mt.setPostCategories");
|
||||||
|
|
||||||
set_current_user(0, $user_login);
|
set_current_user(0, $user_login);
|
||||||
if ( !current_user_can('edit_post', $post_ID) )
|
if ( !current_user_can('edit_post', $post_ID) )
|
||||||
return new IXR_Error(401, __('Sorry, you can not edit this post.'));
|
return new IXR_Error(401, __('Sorry, you can not edit this post.'));
|
||||||
|
@ -1802,6 +1858,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
/* mt.supportedMethods ...returns an array of methods supported by this server */
|
/* mt.supportedMethods ...returns an array of methods supported by this server */
|
||||||
function mt_supportedMethods($args) {
|
function mt_supportedMethods($args) {
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "mt.supportedMethods");
|
||||||
|
|
||||||
$supported_methods = array();
|
$supported_methods = array();
|
||||||
foreach($this->methods as $key=>$value) {
|
foreach($this->methods as $key=>$value) {
|
||||||
$supported_methods[] = $key;
|
$supported_methods[] = $key;
|
||||||
|
@ -1825,6 +1883,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
$post_ID = intval($args);
|
$post_ID = intval($args);
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "mt.getTrackbackPings");
|
||||||
|
|
||||||
$actual_post = wp_get_single_post($post_ID, ARRAY_A);
|
$actual_post = wp_get_single_post($post_ID, ARRAY_A);
|
||||||
|
|
||||||
if (!$actual_post) {
|
if (!$actual_post) {
|
||||||
|
@ -1867,6 +1927,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "mt.publishPost");
|
||||||
|
|
||||||
set_current_user(0, $user_login);
|
set_current_user(0, $user_login);
|
||||||
if ( !current_user_can('edit_post', $post_ID) )
|
if ( !current_user_can('edit_post', $post_ID) )
|
||||||
return new IXR_Error(401, __('Sorry, you can not edit this post.'));
|
return new IXR_Error(401, __('Sorry, you can not edit this post.'));
|
||||||
|
@ -1895,6 +1957,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
function pingback_ping($args) {
|
function pingback_ping($args) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "pingback.ping");
|
||||||
|
|
||||||
$this->escape($args);
|
$this->escape($args);
|
||||||
|
|
||||||
$pagelinkedfrom = $args[0];
|
$pagelinkedfrom = $args[0];
|
||||||
|
@ -2057,6 +2121,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
|
do_action("xmlrpc_call", "pingback.extensions.getPingsbacks");
|
||||||
|
|
||||||
$this->escape($args);
|
$this->escape($args);
|
||||||
|
|
||||||
$url = $args;
|
$url = $args;
|
||||||
|
|
Loading…
Reference in New Issue