﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
21198	Add tag id to callback to allow customizing of the tooltip text in tag clouds	najamelan	ryan	"When hovering over tags in tag clouds wp shows the number of posts. To achieve this a callback is called with the number. This callback forms the text to be added to the title attribute.

The callback can be set by the user, but because it only gets the count, and not the tag id, not much can be done.

With the tag id the callback could for example return the tag description for the tooltip.

Not much is needed for this since the tag id is available in the context of the caller. A 2 line patch to wp-includes/category-template.php provides this functionality.

This is a patch generated by Git on the 3.4.1 code.

Subject: [PATCH] wp-includes/category-template: add tagid to call for tooltip
 text in tag clouds

{{{
---
 wp-includes/category-template.php |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
--- a/wp-includes/category-template.php
+++ b/wp-includes/category-template.php
@@ -559,7 +559,7 @@ function wp_tag_cloud( $args = '' ) {
  * @param integer $count number of posts with that tag
  * @return string text for the tooltip of a tag link.
  */
-function default_topic_count_text( $count ) {
+function default_topic_count_text( $count, $tag_id ) {
 	return sprintf( _n('%s topic', '%s topics', $count), number_format_i18n( $count ) );
 }
 
@@ -671,7 +671,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
 		$tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#';
 		$tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
 		$tag_name = $tags[ $key ]->name;
-		$a[] = ""<a href='$tag_link' class='tag-link-$tag_id' title='"" . esc_attr( call_user_func( $topic_count_text_callback, $real_count ) ) . ""' style='font-size: "" .
+		$a[] = ""<a href='$tag_link' class='tag-link-$tag_id' title='"" . esc_attr( call_user_func( $topic_count_text_callback, $real_count, $tag_id ) ) . ""' style='font-size: "" .
 			str_replace( ',', '.', ( $smallest + ( ( $count - $min_count ) * $font_step ) ) )
 			. ""$unit;'>$tag_name</a>"";
 	}
-- 
}}}


Probably it would be desirable some day to replace the callback by a filter for consistency, but this works fine and probably has less overhead.

Thanks alot"	enhancement	closed	normal	3.6	Taxonomy		minor	fixed	has-patch commit	ocean90 info@…
