get_terms_to_edit

The timeline below displays how wordpress function get_terms_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

/**
 * Gets comma-separated list of terms available to edit for the given post ID.
 *
 * @since 2.8.0
 *
 * @param int    $post_id
 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
 * @return string|false|WP_Error
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $terms = get_object_term_cache($post_id, $taxonomy);
    if (false === $terms) {
        $terms = wp_get_object_terms($post_id, $taxonomy);
        wp_cache_add($post_id, wp_list_pluck($terms, 'term_id'), $taxonomy . '_relationships');
    }
    if (!$terms) {
        return false;
    }
    if (is_wp_error($terms)) {
        return $terms;
    }
    $term_names = array();
    foreach ($terms as $term) {
        $term_names[] = $term->name;
    }
    $terms_to_edit = esc_attr(implode(',', $term_names));
    /**
     * Filters the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param string $terms_to_edit A comma-separated list of term names.
     * @param string $taxonomy      The taxonomy name for which to retrieve terms.
     */
    $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy);
    return $terms_to_edit;
}

WordPress Version: 5.7

/**
 * Get comma-separated list of terms available to edit for the given post ID.
 *
 * @since 2.8.0
 *
 * @param int    $post_id
 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
 * @return string|false|WP_Error
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $terms = get_object_term_cache($post_id, $taxonomy);
    if (false === $terms) {
        $terms = wp_get_object_terms($post_id, $taxonomy);
        wp_cache_add($post_id, wp_list_pluck($terms, 'term_id'), $taxonomy . '_relationships');
    }
    if (!$terms) {
        return false;
    }
    if (is_wp_error($terms)) {
        return $terms;
    }
    $term_names = array();
    foreach ($terms as $term) {
        $term_names[] = $term->name;
    }
    $terms_to_edit = esc_attr(implode(',', $term_names));
    /**
     * Filters the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param string $terms_to_edit A comma-separated list of term names.
     * @param string $taxonomy      The taxonomy name for which to retrieve terms.
     */
    $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy);
    return $terms_to_edit;
}

WordPress Version: 5.6

/**
 * Get comma-separated list of terms available to edit for the given post ID.
 *
 * @since 2.8.0
 *
 * @param int    $post_id
 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
 * @return string|bool|WP_Error
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $terms = get_object_term_cache($post_id, $taxonomy);
    if (false === $terms) {
        $terms = wp_get_object_terms($post_id, $taxonomy);
        wp_cache_add($post_id, wp_list_pluck($terms, 'term_id'), $taxonomy . '_relationships');
    }
    if (!$terms) {
        return false;
    }
    if (is_wp_error($terms)) {
        return $terms;
    }
    $term_names = array();
    foreach ($terms as $term) {
        $term_names[] = $term->name;
    }
    $terms_to_edit = esc_attr(implode(',', $term_names));
    /**
     * Filters the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param string $terms_to_edit A comma-separated list of term names.
     * @param string $taxonomy      The taxonomy name for which to retrieve terms.
     */
    $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy);
    return $terms_to_edit;
}

WordPress Version: 5.1

/**
 * Get comma-separated list of terms available to edit for the given post ID.
 *
 * @since 2.8.0
 *
 * @param int    $post_id
 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
 * @return string|bool|WP_Error
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $terms = get_object_term_cache($post_id, $taxonomy);
    if (false === $terms) {
        $terms = wp_get_object_terms($post_id, $taxonomy);
        wp_cache_add($post_id, wp_list_pluck($terms, 'term_id'), $taxonomy . '_relationships');
    }
    if (!$terms) {
        return false;
    }
    if (is_wp_error($terms)) {
        return $terms;
    }
    $term_names = array();
    foreach ($terms as $term) {
        $term_names[] = $term->name;
    }
    $terms_to_edit = esc_attr(join(',', $term_names));
    /**
     * Filters the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param string $terms_to_edit A comma-separated list of term names.
     * @param string $taxonomy      The taxonomy name for which to retrieve terms.
     */
    $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy);
    return $terms_to_edit;
}

WordPress Version: 4.6

/**
 * Get comma-separated list of terms available to edit for the given post ID.
 *
 * @since 2.8.0
 *
 * @param int    $post_id
 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
 * @return string|bool|WP_Error
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $terms = get_object_term_cache($post_id, $taxonomy);
    if (false === $terms) {
        $terms = wp_get_object_terms($post_id, $taxonomy);
        wp_cache_add($post_id, wp_list_pluck($terms, 'term_id'), $taxonomy . '_relationships');
    }
    if (!$terms) {
        return false;
    }
    if (is_wp_error($terms)) {
        return $terms;
    }
    $term_names = array();
    foreach ($terms as $term) {
        $term_names[] = $term->name;
    }
    $terms_to_edit = esc_attr(join(',', $term_names));
    /**
     * Filters the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param array  $terms_to_edit An array of terms.
     * @param string $taxonomy     The taxonomy for which to retrieve terms. Default 'post_tag'.
     */
    $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy);
    return $terms_to_edit;
}

WordPress Version: 4.2

/**
 * Get comma-separated list of terms available to edit for the given post ID.
 *
 * @since 2.8.0
 *
 * @param int    $post_id
 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
 * @return string|bool|WP_Error
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $terms = get_object_term_cache($post_id, $taxonomy);
    if (false === $terms) {
        $terms = wp_get_object_terms($post_id, $taxonomy);
        wp_cache_add($post_id, $terms, $taxonomy . '_relationships');
    }
    if (!$terms) {
        return false;
    }
    if (is_wp_error($terms)) {
        return $terms;
    }
    $term_names = array();
    foreach ($terms as $term) {
        $term_names[] = $term->name;
    }
    $terms_to_edit = esc_attr(join(',', $term_names));
    /**
     * Filter the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param array  $terms_to_edit An array of terms.
     * @param string $taxonomy     The taxonomy for which to retrieve terms. Default 'post_tag'.
     */
    $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy);
    return $terms_to_edit;
}

WordPress Version: 4.1

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.8.0
 *
 * @param int $post_id
 * @return string|bool|WP_Error
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $terms = get_object_term_cache($post_id, $taxonomy);
    if (false === $terms) {
        $terms = wp_get_object_terms($post_id, $taxonomy);
        wp_cache_add($post_id, $terms, $taxonomy . '_relationships');
    }
    if (!$terms) {
        return false;
    }
    if (is_wp_error($terms)) {
        return $terms;
    }
    $term_names = array();
    foreach ($terms as $term) {
        $term_names[] = $term->name;
    }
    $terms_to_edit = esc_attr(join(',', $term_names));
    /**
     * Filter the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param array  $terms_to_edit An array of terms.
     * @param string $taxonomy     The taxonomy for which to retrieve terms. Default 'post_tag'.
     */
    $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy);
    return $terms_to_edit;
}

WordPress Version: 4.0

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.8.0
 *
 * @param unknown_type $post_id
 * @return unknown
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $terms = get_object_term_cache($post_id, $taxonomy);
    if (false === $terms) {
        $terms = wp_get_object_terms($post_id, $taxonomy);
        wp_cache_add($post_id, $terms, $taxonomy . '_relationships');
    }
    if (!$terms) {
        return false;
    }
    if (is_wp_error($terms)) {
        return $terms;
    }
    $term_names = array();
    foreach ($terms as $term) {
        $term_names[] = $term->name;
    }
    $terms_to_edit = esc_attr(join(',', $term_names));
    /**
     * Filter the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param array  $terms_to_edit An array of terms.
     * @param string $taxonomy     The taxonomy for which to retrieve terms. Default 'post_tag'.
     */
    $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy);
    return $terms_to_edit;
}

WordPress Version: 3.9

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.8.0
 *
 * @param unknown_type $post_id
 * @return unknown
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $tags = wp_get_post_terms($post_id, $taxonomy, array());
    if (!$tags) {
        return false;
    }
    if (is_wp_error($tags)) {
        return $tags;
    }
    foreach ($tags as $tag) {
        $tag_names[] = $tag->name;
    }
    $tags_to_edit = join(',', $tag_names);
    $tags_to_edit = esc_attr($tags_to_edit);
    /**
     * Filter the comma-separated list of terms available to edit.
     *
     * @since 2.8.0
     *
     * @see get_terms_to_edit()
     *
     * @param array  $tags_to_edit An array of terms.
     * @param string $taxonomy     The taxonomy for which to retrieve terms. Default 'post_tag'.
     */
    $tags_to_edit = apply_filters('terms_to_edit', $tags_to_edit, $taxonomy);
    return $tags_to_edit;
}

WordPress Version: 3.7

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.8.0
 *
 * @param unknown_type $post_id
 * @return unknown
 */
function get_terms_to_edit($post_id, $taxonomy = 'post_tag')
{
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $tags = wp_get_post_terms($post_id, $taxonomy, array());
    if (!$tags) {
        return false;
    }
    if (is_wp_error($tags)) {
        return $tags;
    }
    foreach ($tags as $tag) {
        $tag_names[] = $tag->name;
    }
    $tags_to_edit = join(',', $tag_names);
    $tags_to_edit = esc_attr($tags_to_edit);
    $tags_to_edit = apply_filters('terms_to_edit', $tags_to_edit, $taxonomy);
    return $tags_to_edit;
}