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

git-svn-id: http://svn.automattic.com/wordpress/trunk@9340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-10-25 18:19:42 +00:00
parent b3e5e7a718
commit ce62669cc4
3 changed files with 50 additions and 10 deletions

View File

@@ -558,6 +558,48 @@ function get_tag_feed_link($tag_id, $feed = '') {
return $link;
}
/**
* Retrieve edit tag link.
*
* @since 2.7.0
*
* @param int $tag_id Tag ID
* @return string
*/
function get_edit_tag_link( $tag_id = 0 ) {
$tag = get_term($tag_id, 'post_tag');
if ( !current_user_can('manage_categories') )
return;
$location = admin_url('edit-tags.php?action=edit&tag_ID=') . $tag->term_id;
return apply_filters( 'get_edit_tag_link', $location );
}
/**
* Display or retrieve edit tag link with formatting.
*
* @since 2.7.0
*
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param int|object $tag Tag object or ID
* @return string|null HTML content, if $echo is set to false.
*/
function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
$tag = get_term($tag, 'post_tag');
if ( !current_user_can('manage_categories') )
return;
if ( empty($link) )
$link = __('Edit This');
$link = '<a href="' . get_edit_tag_link( $tag->term_id ) . '" title="' . __( 'Edit tag' ) . '">' . $link . '</a>';
echo $before . apply_filters( 'edit_tag_link', $link, $tag->term_id ) . $after;
}
/**
* Retrieve the permalink for the feed of the search results.
*
@@ -716,10 +758,9 @@ function get_edit_comment_link( $comment_id = 0 ) {
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param bool $echo Optional, defaults to true. Whether to echo or return HTML.
* @return string|null HTML content, if $echo is set to false.
*/
function edit_comment_link( $link = 'Edit This', $before = '', $after = '', $echo = true ) {
function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
global $comment, $post;
if ( $post->post_type == 'attachment' ) {
@@ -732,11 +773,7 @@ function edit_comment_link( $link = 'Edit This', $before = '', $after = '', $ech
}
$link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
$link = $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
if ( $echo )
echo $link;
else
return $link;
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
}
/**