get_term_to_edit

Sanitizes Term for editing.

Description

(string|int|null|WP_Error) get_term_to_edit( (int|object) $id, (string) $taxonomy ); 

Return value is sanitize_term() and usage is for sanitizing the term for editing. Function is for contextual and simplicity.

Returns (string|int|null|WP_Error)

Will return empty string if $term is not an object.

Parameters (2)

0. $id (int|object)
Term ID or object.
1. $taxonomy (string)
Taxonomy name.

Usage

  1. if ( !function_exists( 'get_term_to_edit' ) ) { 
  2. require_once ABSPATH . WPINC . '/taxonomy.php'; 
  3.  
  4. // Term ID or object. 
  5. $id = null; 
  6.  
  7. // Taxonomy name. 
  8. $taxonomy = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_term_to_edit($id, $taxonomy); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/taxonomy.php  
  1. function get_term_to_edit( $id, $taxonomy ) { 
  2. $term = get_term( $id, $taxonomy ); 
  3.  
  4. if ( is_wp_error($term) ) 
  5. return $term; 
  6.  
  7. if ( !is_object($term) ) 
  8. return ''; 
  9.  
  10. return sanitize_term($term, $taxonomy, 'edit');