| 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 | |