Make WordPress Core

Changeset 9340


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

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

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-tags.php

    r9339 r9340  
    274274<div class="tagcloud">
    275275<h3><?php _e('Popular Tags'); ?></h3>
    276 <?php wp_tag_cloud(); ?>
     276<?php wp_tag_cloud(array('link' => 'edit')); ?>
    277277</div>
    278278
  • trunk/wp-includes/category-template.php

    r9289 r9340  
    552552        'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
    553553        'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
    554         'exclude' => '', 'include' => ''
     554        'exclude' => '', 'include' => '', 'link' => 'view'
    555555    );
    556556    $args = wp_parse_args( $args, $defaults );
     
    562562
    563563    foreach ( $tags as $key => $tag ) {
    564         $link = get_tag_link( $tag->term_id );
     564        if ( 'edit' == $args['link'] )
     565            $link = get_edit_tag_link( $tag->term_id );
     566        else
     567            $link = get_tag_link( $tag->term_id );
    565568        if ( is_wp_error( $link ) )
    566569            return false;
  • 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&amp;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.