Make WordPress Core

Ticket #18436: wp.getPostType.patch

File wp.getPostType.patch, 3.2 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.getPostType'        => 'this:wp_getPostType',
    6768
    6869                        // Blogger API
    6970                        'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
     
    17021703                return $formats;
    17031704        }
    17041705
     1706        /**
     1707         * Retrieves a post type
     1708         *
     1709         * @uses get_post_type_object()
     1710         * @param array $args Method parameters. Contains:
     1711         *  - int     $blog_id
     1712         *  - string  $username
     1713         *  - string  $password
     1714         *  - string  $post_type_name
     1715         * @return array contains:
     1716         *  - 'labels'
     1717         *  - 'description'
     1718         *  - 'capability_type'
     1719         *  - 'cap'
     1720         *  - 'map_meta_cap'
     1721         *  - 'hierarchical'
     1722         *  - 'menu_position'
     1723         *  - 'taxonomies'
     1724         */
     1725        function wp_getPostType( $args ) {
     1726
     1727                $this->escape( $args );
     1728
     1729                $blog_ID        = (int) $args[0];
     1730                $username       = $args[1];
     1731                $password       = $args[2];
     1732                $post_type_name = $args[3];
     1733
     1734                if ( ! $user = $this->login( $username, $password ) )
     1735                        return $this->error;
     1736
     1737                $post_type_names = get_post_types('', 'names');
     1738
     1739                if( ! in_array( $post_type_name, $post_type_names ) )
     1740                        return new IXR_Error( 403, __( 'The post type specified is not valid' ) );
     1741
     1742                $post_type = get_post_type_object( $post_type_name );
     1743
     1744                //capability check
     1745                if( ! current_user_can( $post_type->cap->edit_posts ) )
     1746                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type' ) );
     1747
     1748                $post_type = (array)$post_type;
     1749
     1750                $post_type_data = array(
     1751                                'labels'            => $post_type['labels'],
     1752                                'description'       => $post_type['description'],
     1753                                'capability_type'   => $post_type['capability_type'],
     1754                                'cap'               => $post_type['cap'],
     1755                                'map_meta_cap'      => $post_type['map_meta_cap'],
     1756                                'hierarchical'      => $post_type['hierarchical'],
     1757                                'menu_position'     => $post_type['menu_position'],
     1758                                'taxonomies'        => get_object_taxonomies( $post_type['name'] ),
     1759                        );
     1760
     1761                return $post_type_data;
     1762       
     1763        }
     1764
    17051765        /* Blogger API functions.
    17061766         * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
    17071767         */