| 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 | * - array $content_struct contains: |
| 1716 | * - 'taxonomy' |
| 1717 | * @return boolean true |
| 1718 | */ |
| 1719 | function wp_deleteTerm( $args ) { |
| 1720 | |
| 1721 | $this->escape( $args ); |
| 1722 | |
| 1723 | $blog_ID = (int) $args[0]; |
| 1724 | $username = $args[1]; |
| 1725 | $password = $args[2]; |
| 1726 | $term_ID = (int)$args[3]; |
| 1727 | $content_struct = $args[4]; |
| 1728 | |
| 1729 | if ( ! $user = $this->login( $username, $password ) ) |
| 1730 | return $this->error; |
| 1731 | |
| 1732 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1733 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1734 | |
| 1735 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 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, $content_struct['taxonomy'] ); |
| 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(500, __('The specified term does not exist')); |
| 1747 | |
| 1748 | if( $term_ID == get_option('default_category') ) |
| 1749 | return new IXR_Error( 403, __( 'You cannot delete the default category' ) ); |
| 1750 | |
| 1751 | $result = wp_delete_term( $term_ID, $content_struct['taxonomy'] ); |
| 1752 | |
| 1753 | if ( is_wp_error( $result ) ) |
| 1754 | return new IXR_Error(500, $term->get_error_message()); |
| 1755 | |
| 1756 | if ( ! $result ) |
| 1757 | return new IXR_Error(500, __('For some strange yet very annoying reason, this term could not be deleted.')); |
| 1758 | |
| 1759 | return true; |
| 1760 | } |
| 1761 | |