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

@ -273,7 +273,7 @@ do_action('edit_tag_form', $tag);
<div class="tagcloud">
<h3><?php _e('Popular Tags'); ?></h3>
<?php wp_tag_cloud(); ?>
<?php wp_tag_cloud(array('link' => 'edit')); ?>
</div>
</div>

View File

@ -551,7 +551,7 @@ function wp_tag_cloud( $args = '' ) {
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
'exclude' => '', 'include' => ''
'exclude' => '', 'include' => '', 'link' => 'view'
);
$args = wp_parse_args( $args, $defaults );
@ -561,7 +561,10 @@ function wp_tag_cloud( $args = '' ) {
return;
foreach ( $tags as $key => $tag ) {
$link = get_tag_link( $tag->term_id );
if ( 'edit' == $args['link'] )
$link = get_edit_tag_link( $tag->term_id );
else
$link = get_tag_link( $tag->term_id );
if ( is_wp_error( $link ) )
return false;

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&amp;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;
}
/**