From f72a4ce64f0ae4b210ec5cc3c3b80b74162d5c7a Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 13 Oct 2008 23:54:21 +0000 Subject: [PATCH] List post tags via XMLRPC. Props josephscott. fixes #7744 git-svn-id: http://svn.automattic.com/wordpress/trunk@9143 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- xmlrpc.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/xmlrpc.php b/xmlrpc.php index 8085ba36d..bbfc564cd 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -137,6 +137,7 @@ class wp_xmlrpc_server extends IXR_Server { 'wp.getPageList' => 'this:wp_getPageList', 'wp.getAuthors' => 'this:wp_getAuthors', 'wp.getCategories' => 'this:mw_getCategories', // Alias + 'wp.getTags' => 'this:wp_getTags', 'wp.newCategory' => 'this:wp_newCategory', 'wp.deleteCategory' => 'this:wp_deleteCategory', 'wp.suggestCategories' => 'this:wp_suggestCategories', @@ -823,6 +824,50 @@ class wp_xmlrpc_server extends IXR_Server { return($authors); } + /** + * Get list of all tags + * + * @since 2.7 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getTags( $args ) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if( !$this->login_pass_ok( $username, $password ) ) { + return $this->error; + } + + set_current_user( 0, $username ); + if( !current_user_can( 'edit_posts' ) ) { + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) ); + } + + do_action( 'xmlrpc_call', 'wp.getKeywords' ); + + $tags = array( ); + + if( $all_tags = get_tags( ) ) { + foreach( (array) $all_tags as $tag ) { + $struct['tag_id'] = $tag->term_id; + $struct['name'] = $tag->name; + $struct['count'] = $tag->count; + $struct['slug'] = $tag->slug; + $struct['html_url'] = wp_specialchars( get_tag_link( $tag->term_id ) ); + $struct['rss_url'] = wp_specialchars( get_tag_feed_link( $tag->term_id ) ); + + $tags[] = $struct; + } + } + + return $tags; + } + /** * Create new category. *