Make WordPress Core

Changeset 9143 for trunk/xmlrpc.php


Ignore:
Timestamp:
10/13/2008 11:54:21 PM (17 years ago)
Author:
ryan
Message:

List post tags via XMLRPC. Props josephscott. fixes #7744

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r9133 r9143  
    138138            'wp.getAuthors'         => 'this:wp_getAuthors',
    139139            'wp.getCategories'      => 'this:mw_getCategories',     // Alias
     140            'wp.getTags'            => 'this:wp_getTags',       
    140141            'wp.newCategory'        => 'this:wp_newCategory',
    141142            'wp.deleteCategory'     => 'this:wp_deleteCategory',
     
    822823
    823824        return($authors);
     825    }
     826
     827    /**
     828     * Get list of all tags
     829     *
     830     * @since 2.7
     831     *
     832     * @param array $args Method parameters.
     833     * @return array
     834     */
     835    function wp_getTags( $args ) {
     836        $this->escape( $args );
     837
     838        $blog_id        = (int) $args[0];
     839        $username       = $args[1];
     840        $password       = $args[2];
     841
     842        if( !$this->login_pass_ok( $username, $password ) ) {
     843            return $this->error;
     844        }
     845
     846        set_current_user( 0, $username );
     847        if( !current_user_can( 'edit_posts' ) ) {
     848            return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) );
     849        }
     850
     851        do_action( 'xmlrpc_call', 'wp.getKeywords' );
     852
     853        $tags = array( );
     854
     855        if( $all_tags = get_tags( ) ) {
     856            foreach( (array) $all_tags as $tag ) {
     857                $struct['tag_id']           = $tag->term_id;
     858                $struct['name']             = $tag->name;
     859                $struct['count']            = $tag->count;
     860                $struct['slug']             = $tag->slug;
     861                $struct['html_url']         = wp_specialchars( get_tag_link( $tag->term_id ) );
     862                $struct['rss_url']          = wp_specialchars( get_tag_feed_link( $tag->term_id ) );
     863
     864                $tags[] = $struct;
     865            }
     866        }
     867
     868        return $tags;
    824869    }
    825870
Note: See TracChangeset for help on using the changeset viewer.