From fe28a9d18b979f6c98bc3b7a9959c6be27a60830 Mon Sep 17 00:00:00 2001 From: westi Date: Tue, 9 Nov 2010 10:16:23 +0000 Subject: [PATCH] Switch the following XMLRPC api calls to support an optional number of posts. blogger.getRecentPosts metaWeblog.getRecentPosts mt.getRecentPostTitles git-svn-id: http://svn.automattic.com/wordpress/trunk@16256 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-xmlrpc-server.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index decec331a6..fce1131dc5 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -1762,17 +1762,21 @@ class wp_xmlrpc_server extends IXR_Server { $this->escape($args); + // $args[0] = appkey - ignored $blog_ID = (int) $args[1]; /* though we don't use it yet */ $username = $args[2]; $password = $args[3]; - $num_posts = $args[4]; + if ( isset( $args[4] ) ) + $query = array( 'numberposts' => absint( $args[4] ) ); + else + $query = array(); if ( !$user = $this->login($username, $password) ) return $this->error; do_action('xmlrpc_call', 'blogger.getRecentPosts'); - $posts_list = wp_get_recent_posts($num_posts); + $posts_list = wp_get_recent_posts( $query ); if ( !$posts_list ) { $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); @@ -2682,14 +2686,17 @@ class wp_xmlrpc_server extends IXR_Server { $blog_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; - $num_posts = (int) $args[3]; + if ( isset( $args[3] ) ) + $query = array( 'numberposts' => absint( $args[3] ) ); + else + $query = array(); if ( !$user = $this->login($username, $password) ) return $this->error; do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); - $posts_list = wp_get_recent_posts($num_posts); + $posts_list = wp_get_recent_posts( $query ); if ( !$posts_list ) return array( ); @@ -2914,14 +2921,17 @@ class wp_xmlrpc_server extends IXR_Server { $blog_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; - $num_posts = (int) $args[3]; + if ( isset( $args[3] ) ) + $query = array( 'numberposts' => absint( $args[3] ) ); + else + $query = array(); if ( !$user = $this->login($username, $password) ) return $this->error; do_action('xmlrpc_call', 'mt.getRecentPostTitles'); - $posts_list = wp_get_recent_posts($num_posts); + $posts_list = wp_get_recent_posts( $query ); if ( !$posts_list ) { $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));