[wp-trac] [WordPress Trac] #21198: Add tag id to callback to allow customizing of the tooltip text in tag clouds

WordPress Trac noreply at wordpress.org
Sun Jan 13 07:43:55 UTC 2013


#21198: Add tag id to callback to allow customizing of the tooltip text in tag
clouds
-------------------------+------------------
 Reporter:  najamelan    |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  3.6
Component:  Taxonomy     |     Version:
 Severity:  minor        |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------
Changes (by toscho):

 * cc: info@… (added)


Comment:

 The term ID alone is not enough, we need at least the taxonomy too. The
 following patch does exactly this. It passes the complete list of
 arguments to the callback.

 {{{
 call_user_func( $topic_count_text_callback, $real_count, $tag_id, $args )
 }}}

 For a practical use case see
 [http://wordpress.stackexchange.com/q/78426/73 this thread] and the
 hilarious workaround I needed to achieve that.

 With the patch we can use just:


 {{{
 wp_tag_cloud(
         array (
                 'topic_count_text_callback' => 't5_desc_as_title'
         )
 );

 function t5_desc_as_title( $real_count, $term_id, $args )
 {
         $desc = term_description( $term_id, $args['taxonomy'] );
         $desc = wp_strip_all_tags( $desc, TRUE );
         return esc_attr( $desc );
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21198#comment:7>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list