On this page
get_term_to_edit( int|object $id, string $taxonomy ): string|int|null|WP_Error
Sanitizes term for editing.
Description
Return value is sanitize_term() and usage is for sanitizing the term for editing. Function is for contextual and simplicity.
Parameters
$idint|object Required-
Term ID or object.
$taxonomystring Required-
Taxonomy name.
Return
string|int|null|WP_Error Will return empty string if $term is not an object.
Source
File: wp-includes/taxonomy.php. View all references
function get_term_to_edit( $id, $taxonomy ) {
$term = get_term( $id, $taxonomy );
if ( is_wp_error( $term ) ) {
return $term;
}
if ( ! is_object( $term ) ) {
return '';
}
return sanitize_term( $term, $taxonomy, 'edit' );
}
Related
Uses
| Uses | Description |
|---|---|
| sanitize_term() wp-includes/taxonomy.php | Sanitizes all term fields. |
| get_term() wp-includes/taxonomy.php | Gets all term data from database by term ID. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_term_to_edit