wp_xmlrpc_server::wp_deleteTerm( array $args ): true|IXR_Error
- Since
- 3.4.0
- Source
wp-includes/class-wp-xmlrpc-server.php:2311
Deletes a term.
Parameters
$argsarray- Method arguments. Note: arguments must be ordered as documented.
$0intBlog ID (unused).$1stringUsername.$2stringPassword.$3stringTaxonomy name.$4intTerm ID.
Return
true|IXR_Error- True on success, IXR_Error instance on failure.
Hooks fired · 1
One hook fires while wp_xmlrpc_server::wp_deleteTerm() runs, in this order:
- do_action( xmlrpc_call )actionline 2329 (+18 into the body)
Fires after the XML-RPC user has been authenticated but before the rest of the method logic begins.
Uses · 12
- do_action()Calls the callback functions that have been added to an action hook.
- taxonomy_exists()Determines whether the taxonomy name exists.
- __()Retrieves the translation of $text.
- get_taxonomy()Retrieves the taxonomy object of $taxonomy.
- get_term()Gets all term data from database by term ID.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- current_user_can()Returns whether the current user has the specified capability.
- wp_delete_term()Removes a term from the database.
- wp_xmlrpc_server::minimum_args()Checks if the method received at least the minimum number of arguments.
- wp_xmlrpc_server::escape()Escapes string or array of strings for database.
- wp_xmlrpc_server::login()Logs user in.
- IXR_Error::__construct()PHP5 constructor.
Source
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, $result->get_error_message() ); } if ( ! $result ) { return new IXR_Error( 500, __( 'Sorry, deleting the term failed.' ) ); } return $result; }History
Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/class-wp-xmlrpc-server.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.