Make WordPress Core

Ticket #9702: edit_term_link.patch

File edit_term_link.patch, 1.1 KB (added by joostdevalk, 14 years ago)

Patch with new edit_term_link function

  • wp-includes/link-template.php

     
    689689}
    690690
    691691/**
     692 * Display or retrieve edit term link with formatting.
     693 *
     694 * @since 3.1
     695 *
     696 * @param string $link Optional. Anchor text.
     697 * @param string $before Optional. Display before edit link.
     698 * @param string $after Optional. Display after edit link.
     699 * @param object $term Term object
     700 * @return string HTML content.
     701 */
     702function edit_term_link( $link = '', $before = '', $after = '', $term = null ) {
     703       
     704        if ( $term == null ) {
     705                global $wp_query;
     706                $term = $wp_query->get_queried_object();
     707        }
     708       
     709        $tax = get_taxonomy( $term->taxonomy );
     710        if ( !current_user_can($tax->cap->edit_terms) )
     711                return;
     712
     713        if ( empty($link) )
     714                $link = __('Edit This');
     715
     716        $link = '<a href="' . get_edit_tag_link( $term->term_id, $term->taxonomy ) . '" title="' . $link . '">' . $link . '</a>';
     717        echo $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
     718}
     719
     720/**
    692721* Retrieve permalink for search.
    693722*
    694723* @since  3.0.0