Ticket #7744: xmlrpc.php.diff

File xmlrpc.php.diff, 1.7 KB (added by josephscott, 5 years ago)
Line 
1Index: xmlrpc.php
2===================================================================
3--- xmlrpc.php  (revision 9088)
4+++ xmlrpc.php  (working copy)
5@@ -137,6 +137,7 @@
6                        'wp.getPageList'                => 'this:wp_getPageList',
7                        'wp.getAuthors'                 => 'this:wp_getAuthors',
8                        'wp.getCategories'              => 'this:mw_getCategories',             // Alias
9+                       'wp.getTags'                    => 'this:wp_getTags',           
10                        'wp.newCategory'                => 'this:wp_newCategory',
11                        'wp.deleteCategory'             => 'this:wp_deleteCategory',
12                        'wp.suggestCategories'  => 'this:wp_suggestCategories',
13@@ -824,6 +825,50 @@
14        }
15 
16        /**
17+        * Get list of all tags
18+        *
19+        * @since 2.7
20+        *
21+        * @param array $args Method parameters.
22+        * @return array
23+        */
24+       function wp_getTags( $args ) {
25+               $this->escape( $args );
26+
27+               $blog_id                = (int) $args[0];
28+               $username               = $args[1];
29+               $password               = $args[2];
30+
31+               if( !$this->login_pass_ok( $username, $password ) ) {
32+                       return $this->error;
33+               }
34+
35+               set_current_user( 0, $username );
36+               if( !current_user_can( 'edit_posts' ) ) {
37+                       return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) );
38+               }
39+
40+               do_action( 'xmlrpc_call', 'wp.getKeywords' );
41+
42+               $tags = array( );
43+
44+               if( $all_tags = get_tags( ) ) {
45+                       foreach( (array) $all_tags as $tag ) {
46+                               $struct['tag_id']                       = $tag->term_id;
47+                               $struct['name']                         = $tag->name;
48+                               $struct['count']                        = $tag->count;
49+                               $struct['slug']                         = $tag->slug;
50+                               $struct['html_url']                     = wp_specialchars( get_tag_link( $tag->term_id ) );
51+                               $struct['rss_url']                      = wp_specialchars( get_tag_feed_link( $tag->term_id ) );
52+
53+                               $tags[] = $struct;
54+                       }
55+               }
56+
57+               return $tags;
58+       }
59+
60+       /**
61         * Create new category.
62         *
63         * @since 2.2.0