Make WordPress Core


Ignore:
Timestamp:
10/25/2008 06:19:42 PM (15 years ago)
Author:
ryan
Message:

Introduce get_edit_tag_link() and add option to wp_tag_cloud() for showing edit links.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r9318 r9340  
    557557
    558558    return $link;
     559}
     560
     561/**
     562 * Retrieve edit tag link.
     563 *
     564 * @since 2.7.0
     565 *
     566 * @param int $tag_id Tag ID
     567 * @return string
     568 */
     569function get_edit_tag_link( $tag_id = 0 ) {
     570    $tag = get_term($tag_id, 'post_tag');
     571
     572    if ( !current_user_can('manage_categories') )
     573        return;
     574
     575    $location = admin_url('edit-tags.php?action=edit&tag_ID=') . $tag->term_id;
     576    return apply_filters( 'get_edit_tag_link', $location );
     577}
     578
     579/**
     580 * Display or retrieve edit tag link with formatting.
     581 *
     582 * @since 2.7.0
     583 *
     584 * @param string $link Optional. Anchor text.
     585 * @param string $before Optional. Display before edit link.
     586 * @param string $after Optional. Display after edit link.
     587 * @param int|object $tag Tag object or ID
     588 * @return string|null HTML content, if $echo is set to false.
     589 */
     590function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
     591    $tag = get_term($tag, 'post_tag');
     592
     593    if ( !current_user_can('manage_categories') )
     594        return;
     595
     596    if ( empty($link) )
     597        $link = __('Edit This');
     598
     599    $link = '<a href="' . get_edit_tag_link( $tag->term_id ) . '" title="' . __( 'Edit tag' ) . '">' . $link . '</a>';
     600    echo $before . apply_filters( 'edit_tag_link', $link, $tag->term_id ) . $after;
    559601}
    560602
     
    717759 * @param string $before Optional. Display before edit link.
    718760 * @param string $after Optional. Display after edit link.
    719  * @param bool $echo Optional, defaults to true. Whether to echo or return HTML.
    720761 * @return string|null HTML content, if $echo is set to false.
    721762 */
    722 function edit_comment_link( $link = 'Edit This', $before = '', $after = '', $echo = true ) {
     763function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
    723764    global $comment, $post;
    724765
     
    733774
    734775    $link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
    735     $link = $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
    736     if ( $echo )
    737         echo $link;
    738     else
    739         return $link;
     776    echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
    740777}
    741778
Note: See TracChangeset for help on using the changeset viewer.