Make WordPress Core

Ticket #18434: wp.getPostTerms.patch

File wp.getPostTerms.patch, 2.4 KB (added by nprasath002, 14 years ago)
  • class-wp-xmlrpc-server.php

    # This patch file was generated by NetBeans IDE
    # Following Index: paths are relative to: /var/www/GSoC/wordtrunk/wp-includes
    # This patch can be applied using context Tools: Patch action on respective folder.
    # It uses platform neutral UTF-8 encoding and \n newlines.
    # Above lines and this line are ignored by the patching process.
     
    6464                        'wp.getMediaItem'               => 'this:wp_getMediaItem',
    6565                        'wp.getMediaLibrary'    => 'this:wp_getMediaLibrary',
    6666                        'wp.getPostFormats'     => 'this:wp_getPostFormats',
     67                        'wp.getPostTerms'       => 'this:wp_getPostTerms',
    6768
    6869                        // Blogger API
    6970                        'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
     
    17021703                return $formats;
    17031704        }
    17041705
     1706        /**
     1707         * Retrieve post terms
     1708         *
     1709         * @uses wp_get_object_terms()
     1710         * @param array $args Method parameters. Contains:
     1711         *  - int     $blog_id
     1712         *  - string  $username
     1713         *  - string  $password
     1714         *  - int     $post_id
     1715         * @return array term data
     1716         */
     1717        function wp_getPostTerms( $args ) {
     1718
     1719                $this->escape( $args );
     1720
     1721                $blog_ID            = (int) $args[0];
     1722                $username           = $args[1];
     1723                $password           = $args[2];
     1724                $post_ID            = (int) $args[3];
     1725
     1726                if ( ! $user = $this->login( $username, $password ) )
     1727                        return $this->error;
     1728
     1729                $post = wp_get_single_post( $post_ID, ARRAY_A );
     1730                if ( empty( $post['ID'] ) )
     1731                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
     1732
     1733                $post_type = get_post_type_object( $post['post_type'] );
     1734
     1735                if( ! current_user_can( $post_type->cap->edit_post , $post_ID ) )
     1736                        return new IXR_Error( 401, __( 'Sorry, You are not allowed to edit this post.' ));
     1737
     1738                $taxonomies = get_taxonomies( '' );
     1739
     1740                $terms = wp_get_object_terms( $post_ID , $taxonomies );
     1741
     1742                if ( is_wp_error( $terms ) )
     1743                        return new IXR_Error( 500 , $term->get_error_message());
     1744
     1745                return $terms;
     1746               
     1747        }
     1748
    17051749        /* Blogger API functions.
    17061750         * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
    17071751         */