get_term_to_edit

The timeline below displays how wordpress function get_term_to_edit has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Sanitizes term for editing.
 *
 * Return value is sanitize_term() and usage is for sanitizing the term for
 * editing. Function is for contextual and simplicity.
 *
 * @since 2.3.0
 *
 * @param int|object $id       Term ID or object.
 * @param string     $taxonomy Taxonomy name.
 * @return string|int|null|WP_Error Will return empty string if $term is not an object.
 */
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');
}

WordPress Version: 4.3

/**
 * Sanitizes Term for editing.
 *
 * Return value is sanitize_term() and usage is for sanitizing the term for
 * editing. Function is for contextual and simplicity.
 *
 * @since 2.3.0
 *
 * @param int|object $id       Term ID or object.
 * @param string     $taxonomy Taxonomy name.
 * @return string|int|null|WP_Error Will return empty string if $term is not an object.
 */
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');
}

WordPress Version: 4.1

/**
 * Sanitizes Term for editing.
 *
 * Return value is sanitize_term() and usage is for sanitizing the term for
 * editing. Function is for contextual and simplicity.
 *
 * @since 2.3.0
 *
 * @param int|object $id Term ID or Object
 * @param string $taxonomy Taxonomy Name
 * @return mixed|null|WP_Error Will return empty string if $term is not an object.
 */
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');
}

WordPress Version: 3.9

/**
 * Sanitizes Term for editing.
 *
 * Return value is sanitize_term() and usage is for sanitizing the term for
 * editing. Function is for contextual and simplicity.
 *
 * @since 2.3.0
 *
 * @uses sanitize_term() Passes the return value on success
 *
 * @param int|object $id Term ID or Object
 * @param string $taxonomy Taxonomy Name
 * @return mixed|null|WP_Error Will return empty string if $term is not an object.
 */
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');
}

WordPress Version: 3.7

/**
 * Sanitizes Term for editing.
 *
 * Return value is sanitize_term() and usage is for sanitizing the term for
 * editing. Function is for contextual and simplicity.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses sanitize_term() Passes the return value on success
 *
 * @param int|object $id Term ID or Object
 * @param string $taxonomy Taxonomy Name
 * @return mixed|null|WP_Error Will return empty string if $term is not an object.
 */
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');
}