On this page
wp_xmlrpc_server::wp_deleteTerm( array $args ): true|IXR_Error
Delete a term.
Description
See also
Parameters
$argsarray Required-
Method arguments. Note: arguments must be ordered as documented.
- int
Blog ID (unused).
1stringUsername.2stringPassword.3stringTaxonomy name.4intTerm ID.
- int
Return
true|IXR_Error True on success, IXR_Error instance on failure.
Source
File: wp-includes/class-wp-xmlrpc-server.php. View all references
public function wp_deleteTerm( $args ) {
if ( ! $this->minimum_args( $args, 5 ) ) {
return $this->error;
}
$this->escape( $args );
$username = $args[1];
$password = $args[2];
$taxonomy = $args[3];
$term_id = (int) $args[4];
$user = $this->login( $username, $password );
if ( ! $user ) {
return $this->error;
}
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this );
if ( ! taxonomy_exists( $taxonomy ) ) {
return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
}
$taxonomy = get_taxonomy( $taxonomy );
$term = get_term( $term_id, $taxonomy->name );
if ( is_wp_error( $term ) ) {
return new IXR_Error( 500, $term->get_error_message() );
}
if ( ! $term ) {
return new IXR_Error( 404, __( 'Invalid term ID.' ) );
}
if ( ! current_user_can( 'delete_term', $term_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this term.' ) );
}
$result = wp_delete_term( $term_id, $taxonomy->name );
if ( is_wp_error( $result ) ) {
return new IXR_Error( 500, $term->get_error_message() );
}
if ( ! $result ) {
return new IXR_Error( 500, __( 'Sorry, deleting the term failed.' ) );
}
return $result;
}
Hooks
- do_action( 'xmlrpc_call',
string $name ,array|string $args ,wp_xmlrpc_server $server ) -
Fires after the XML-RPC user has been authenticated but before the rest of the method logic begins.
Related
Uses
| Uses | Description |
|---|---|
| wp_delete_term() wp-includes/taxonomy.php | Removes a term from the database. |
| taxonomy_exists() wp-includes/taxonomy.php | Determines whether the taxonomy name exists. |
| wp_xmlrpc_server::minimum_args() wp-includes/class-wp-xmlrpc-server.php | Checks if the method received at least the minimum number of arguments. |
| IXR_Error::__construct() wp-includes/IXR/class-IXR-error.php | PHP5 constructor. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| get_taxonomy() wp-includes/taxonomy.php | Retrieves the taxonomy object of $taxonomy. |
| get_term() wp-includes/taxonomy.php | Gets all term data from database by term ID. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
| wp_xmlrpc_server::escape() wp-includes/class-wp-xmlrpc-server.php | Escape string or array of strings for database. |
| wp_xmlrpc_server::login() wp-includes/class-wp-xmlrpc-server.php | Log user in. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_deleteterm