| 1706 | /** |
| 1707 | * Prepares post type data for return in an XML-RPC object |
| 1708 | * |
| 1709 | * @param array|object $post_type The unprepared post type data |
| 1710 | * @return array The prepared post type data |
| 1711 | */ |
| 1712 | function prepare_post_type( $post_type ) { |
| 1713 | $_post_type = (array) $post_type; |
| 1714 | |
| 1715 | $_post_type['taxonomies'] = get_object_taxonomies( $_post_type['name'] ); |
| 1716 | |
| 1717 | return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type ); |
| 1718 | } |
| 1719 | |
| 1720 | /** |
| 1721 | * Retrieves a post type |
| 1722 | * |
| 1723 | * @uses get_post_type_object() |
| 1724 | * @param array $args Method parameters. Contains: |
| 1725 | * - int $blog_id |
| 1726 | * - string $username |
| 1727 | * - string $password |
| 1728 | * - string $post_type_name |
| 1729 | * @return array contains: |
| 1730 | * - 'labels' |
| 1731 | * - 'description' |
| 1732 | * - 'capability_type' |
| 1733 | * - 'cap' |
| 1734 | * - 'map_meta_cap' |
| 1735 | * - 'hierarchical' |
| 1736 | * - 'menu_position' |
| 1737 | * - 'taxonomies' |
| 1738 | */ |
| 1739 | function wp_getPostType( $args ) { |
| 1740 | $this->escape( $args ); |
| 1741 | |
| 1742 | $blog_id = (int) $args[0]; |
| 1743 | $username = $args[1]; |
| 1744 | $password = $args[2]; |
| 1745 | $post_type_name = $args[3]; |
| 1746 | |
| 1747 | if ( !$user = $this->login( $username, $password ) ) |
| 1748 | return $this->error; |
| 1749 | |
| 1750 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 1751 | |
| 1752 | if( ! post_type_exists( $post_type_name ) ) |
| 1753 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1754 | |
| 1755 | $post_type = get_post_type_object( $post_type_name ); |
| 1756 | |
| 1757 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 1758 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
| 1759 | |
| 1760 | return $this->prepare_post_type( $post_type ); |
| 1761 | } |
| 1762 | |