edit_term_link

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

WordPress Version: 6.2

/**
 * Displays or retrieves the edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string           $link    Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
 * @param string           $before  Optional. Display before edit link. Default empty.
 * @param string           $after   Optional. Display after edit link. Default empty.
 * @param int|WP_Term|null $term    Optional. Term ID or object. If null, the queried object will be inspected. Default null.
 * @param bool             $display Optional. Whether or not to echo the return. Default true.
 * @return string|void HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $display = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    } else {
        $term = get_term($term);
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can('edit_term', $term->term_id)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    /**
     * Filters the anchor tag for the edit link of a term.
     *
     * @since 3.1.0
     *
     * @param string $link    The anchor tag for the edit link.
     * @param int    $term_id Term ID.
     */
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($display) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 5.9

/**
 * Displays or retrieves the edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string           $link   Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
 * @param string           $before Optional. Display before edit link. Default empty.
 * @param string           $after  Optional. Display after edit link. Default empty.
 * @param int|WP_Term|null $term   Optional. Term ID or object. If null, the queried object will be inspected. Default null.
 * @param bool             $echo   Optional. Whether or not to echo the return. Default true.
 * @return string|void HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    } else {
        $term = get_term($term);
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can('edit_term', $term->term_id)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    /**
     * Filters the anchor tag for the edit link of a term.
     *
     * @since 3.1.0
     *
     * @param string $link    The anchor tag for the edit link.
     * @param int    $term_id Term ID.
     */
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($echo) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 5.4

/**
 * Displays or retrieves the edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string  $link   Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
 * @param string  $before Optional. Display before edit link. Default empty.
 * @param string  $after  Optional. Display after edit link. Default empty.
 * @param WP_Term $term   Optional. Term object. If null, the queried object will be inspected. Default null.
 * @param bool    $echo   Optional. Whether or not to echo the return. Default true.
 * @return string|void HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can('edit_term', $term->term_id)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    /**
     * Filters the anchor tag for the edit link of a term.
     *
     * @since 3.1.0
     *
     * @param string $link    The anchor tag for the edit link.
     * @param int    $term_id Term ID.
     */
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($echo) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 5.3

/**
 * Displays or retrieves the edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string $link   Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
 * @param string $before Optional. Display before edit link. Default empty.
 * @param string $after  Optional. Display after edit link. Default empty.
 * @param object $term   Optional. Term object. If null, the queried object will be inspected. Default null.
 * @param bool   $echo   Optional. Whether or not to echo the return. Default true.
 * @return string|void HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can('edit_term', $term->term_id)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    /**
     * Filters the anchor tag for the edit link of a term.
     *
     * @since 3.1.0
     *
     * @param string $link    The anchor tag for the edit link.
     * @param int    $term_id Term ID.
     */
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($echo) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 4.7

/**
 * Displays or retrieves the edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string $link   Optional. Anchor text. Default empty.
 * @param string $before Optional. Display before edit link. Default empty.
 * @param string $after  Optional. Display after edit link. Default empty.
 * @param object $term   Optional. Term object. If null, the queried object will be inspected. Default null.
 * @param bool   $echo   Optional. Whether or not to echo the return. Default true.
 * @return string|void HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can('edit_term', $term->term_id)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    /**
     * Filters the anchor tag for the edit link of a term.
     *
     * @since 3.1.0
     *
     * @param string $link    The anchor tag for the edit link.
     * @param int    $term_id Term ID.
     */
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($echo) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 4.6

/**
 * Displays or retrieves the edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string $link   Optional. Anchor text. Default empty.
 * @param string $before Optional. Display before edit link. Default empty.
 * @param string $after  Optional. Display after edit link. Default empty.
 * @param object $term   Optional. Term object. If null, the queried object will be inspected. Default null.
 * @param bool   $echo   Optional. Whether or not to echo the return. Default true.
 * @return string|void HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can($tax->cap->edit_terms)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    /**
     * Filters the anchor tag for the edit link of a term.
     *
     * @since 3.1.0
     *
     * @param string $link    The anchor tag for the edit link.
     * @param int    $term_id Term ID.
     */
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($echo) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 4.3

/**
 * Display or retrieve edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string $link   Optional. Anchor text. Default empty.
 * @param string $before Optional. Display before edit link. Default empty.
 * @param string $after  Optional. Display after edit link. Default empty.
 * @param object $term   Optional. Term object. If null, the queried object will be inspected. Default null.
 * @param bool   $echo   Optional. Whether or not to echo the return. Default true.
 * @return string|void HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can($tax->cap->edit_terms)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    /**
     * Filter the anchor tag for the edit link of a term.
     *
     * @since 3.1.0
     *
     * @param string $link    The anchor tag for the edit link.
     * @param int    $term_id Term ID.
     */
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($echo) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 3.9

/**
 * Display or retrieve edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string $link Optional. Anchor text.
 * @param string $before Optional. Display before edit link.
 * @param string $after Optional. Display after edit link.
 * @param object $term Term object.
 * @return string HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can($tax->cap->edit_terms)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    /**
     * Filter the anchor tag for the edit link of a term.
     *
     * @since 3.1.0
     *
     * @param string $link    The anchor tag for the edit link.
     * @param int    $term_id Term ID.
     */
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($echo) {
        echo $link;
    } else {
        return $link;
    }
}

WordPress Version: 3.7

/**
 * Display or retrieve edit term link with formatting.
 *
 * @since 3.1.0
 *
 * @param string $link Optional. Anchor text.
 * @param string $before Optional. Display before edit link.
 * @param string $after Optional. Display after edit link.
 * @param object $term Term object.
 * @return string HTML content.
 */
function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true)
{
    if (is_null($term)) {
        $term = get_queried_object();
    }
    if (!$term) {
        return;
    }
    $tax = get_taxonomy($term->taxonomy);
    if (!current_user_can($tax->cap->edit_terms)) {
        return;
    }
    if (empty($link)) {
        $link = __('Edit This');
    }
    $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>';
    $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after;
    if ($echo) {
        echo $link;
    } else {
        return $link;
    }
}