get_term_to_edit()
Sanitizes term for editing.
Return value is sanitize_term() and usage is for sanitizing the term for editing. Function is for contextual and simplicity.
No Hooks.
Returns
String|Int|null|WP_Error. Will return empty string if $term is not an object.
Usage
get_term_to_edit( $id, $taxonomy );
- $id(int|object) (required)
- Term ID or object.
- $taxonomy(string) (required)
- Taxonomy name.
Changelog
| Since 2.3.0 | Introduced. |
get_term_to_edit() get term to edit code WP 6.9.1
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' );
}