| 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 types |
| 1722 | * |
| 1723 | * @uses get_post_types() |
| 1724 | * @param array $args Method parameters. Contains: |
| 1725 | * - int $blog_id |
| 1726 | * - string $username |
| 1727 | * - string $password |
| 1728 | * @return array |
| 1729 | */ |
| 1730 | function wp_getPostTypes( $args ) { |
| 1731 | $this->escape( $args ); |
| 1732 | |
| 1733 | $blog_id = (int) $args[0]; |
| 1734 | $username = $args[1]; |
| 1735 | $password = $args[2]; |
| 1736 | |
| 1737 | if ( ! $user = $this->login( $username, $password ) ) |
| 1738 | return $this->error; |
| 1739 | |
| 1740 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 1741 | |
| 1742 | $post_types = get_post_types( '', 'objects' ); |
| 1743 | |
| 1744 | $struct = array(); |
| 1745 | |
| 1746 | foreach( $post_types as $post_type ) { |
| 1747 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 1748 | continue; |
| 1749 | |
| 1750 | $struct[$post_type->name] = $this->prepare_post_type( $post_type ); |
| 1751 | } |
| 1752 | |
| 1753 | return $struct; |
| 1754 | } |
| 1755 | |