| | 1706 | /** |
| | 1707 | * Delete a term |
| | 1708 | * |
| | 1709 | * @uses wp_delete_term() |
| | 1710 | * @param array $args Method parameters. Contains: |
| | 1711 | * - int $blog_id |
| | 1712 | * - string $username |
| | 1713 | * - string $password |
| | 1714 | * - int $term_id |
| | 1715 | * - string $taxnomy_name |
| | 1716 | * @return boolean true |
| | 1717 | */ |
| | 1718 | function wp_deleteTerm( $args ) { |
| | 1719 | $this->escape( $args ); |
| | 1720 | |
| | 1721 | $blog_id = (int) $args[0]; |
| | 1722 | $username = $args[1]; |
| | 1723 | $password = $args[2]; |
| | 1724 | $term_id = (int) $args[3]; |
| | 1725 | $taxonomy_name = $args[4]; |
| | 1726 | |
| | 1727 | if ( ! $user = $this->login( $username, $password ) ) |
| | 1728 | return $this->error; |
| | 1729 | |
| | 1730 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| | 1731 | |
| | 1732 | if ( ! taxonomy_exists( $taxonomy_name ) ) |
| | 1733 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| | 1734 | |
| | 1735 | $taxonomy = get_taxonomy( $taxonomy_name ); |
| | 1736 | |
| | 1737 | if( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
| | 1738 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
| | 1739 | |
| | 1740 | $term = get_term ( $term_id, $taxonomy_name ); |
| | 1741 | |
| | 1742 | if ( is_wp_error( $term ) ) |
| | 1743 | return new IXR_Error( 500, $term->get_error_message() ); |
| | 1744 | |
| | 1745 | if ( ! $term ) |
| | 1746 | return new IXR_Error( 404, __('Invalid term ID.') ); |
| | 1747 | |
| | 1748 | $result = wp_delete_term( $term_id, $taxonomy_name ); |
| | 1749 | |
| | 1750 | if ( is_wp_error( $result ) ) |
| | 1751 | return new IXR_Error( 500, $term->get_error_message() ); |
| | 1752 | |
| | 1753 | if ( ! $result ) |
| | 1754 | return new IXR_Error( 500, __('Sorry, deleting the term failed.') ); |
| | 1755 | |
| | 1756 | return $result; |
| | 1757 | } |
| | 1758 | |