| | 1706 | /** |
| | 1707 | * Prepares term data for return in an XML-RPC object |
| | 1708 | * |
| | 1709 | * @param array $term The unprepared term data |
| | 1710 | * @return array The prepared term data |
| | 1711 | */ |
| | 1712 | function prepare_term( $term ) { |
| | 1713 | $_term = (array) $term; |
| | 1714 | |
| | 1715 | return apply_filters( 'xmlrpc_prepare_term', $_term, $term ); |
| | 1716 | } |
| | 1717 | |
| | 1718 | /** |
| | 1719 | * Retrieve a term |
| | 1720 | * |
| | 1721 | * @uses get_term() |
| | 1722 | * @param array $args Method parameters. Contains: |
| | 1723 | * - int $blog_id |
| | 1724 | * - string $username |
| | 1725 | * - string $password |
| | 1726 | * - string $taxonomy_name |
| | 1727 | * - int $term_id |
| | 1728 | * @return array contains: |
| | 1729 | * - 'term_id' |
| | 1730 | * - 'name' |
| | 1731 | * - 'slug' |
| | 1732 | * - 'term_group' |
| | 1733 | * - 'term_taxonomy_id' |
| | 1734 | * - 'taxonomy' |
| | 1735 | * - 'description' |
| | 1736 | * - 'parent' |
| | 1737 | * - 'count' |
| | 1738 | */ |
| | 1739 | function wp_getTerm( $args ) { |
| | 1740 | $this->escape( $args ); |
| | 1741 | |
| | 1742 | $blog_id = (int) $args[0]; |
| | 1743 | $username = $args[1]; |
| | 1744 | $password = $args[2]; |
| | 1745 | $taxonomy_name = $args[3]; |
| | 1746 | $term_id = (int)$args[4]; |
| | 1747 | |
| | 1748 | if ( ! $user = $this->login( $username, $password ) ) |
| | 1749 | return $this->error; |
| | 1750 | |
| | 1751 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| | 1752 | |
| | 1753 | if ( ! taxonomy_exists( $taxonomy_name ) ) |
| | 1754 | return new IXR_Error( 403, __( 'Invalid taxonomy name.' ) ); |
| | 1755 | |
| | 1756 | $taxonomy = get_taxonomy( $taxonomy_name ); |
| | 1757 | |
| | 1758 | if( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| | 1759 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| | 1760 | |
| | 1761 | $term = get_term( $term_id , $taxonomy_name ); |
| | 1762 | |
| | 1763 | if ( is_wp_error( $term ) ) |
| | 1764 | return new IXR_Error( 500, $term->get_error_message() ); |
| | 1765 | |
| | 1766 | if ( ! $term ) |
| | 1767 | return new IXR_Error( 404, __( 'Invalid term ID.' ) ); |
| | 1768 | |
| | 1769 | return $this->prepare_term( $term ); |
| | 1770 | } |
| | 1771 | |