Introduce get_edit_tag_link() and add option to wp_tag_cloud() for showing edit links.
git-svn-id: https://develop.svn.wordpress.org/trunk@9340 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
09b755baf1
commit
5999f964e7
|
@ -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>
|
||||
|
|
|
@ -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,6 +561,9 @@ function wp_tag_cloud( $args = '' ) {
|
|||
return;
|
||||
|
||||
foreach ( $tags as $key => $tag ) {
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue