Ticket #10703: logarithmic_tag_cloud.diff
File logarithmic_tag_cloud.diff, 2.1 KB (added by , 14 years ago) |
---|
-
wp-includes/category-template.php
566 566 } 567 567 568 568 /** 569 * Default topic count scaling for tag links 570 * 571 * @param integer $count number of posts with that tag 572 * @return integer scaled count 573 */ 574 function default_topic_count_scale( $count ) { 575 return round(log10($count + 1) * 100); 576 } 577 578 579 /** 569 580 * Generates a tag cloud (heatmap) from provided data. 570 581 * 571 582 * The text size is set by the 'smallest' and 'largest' arguments, which will … … 602 613 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0, 603 614 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 604 615 'topic_count_text_callback' => 'default_topic_count_text', 605 'filter' => 1, 616 'filter' => 1, 'topic_count_scale_callback' => 'default_topic_count_scale' 606 617 ); 607 618 608 619 if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) { … … 641 652 $tags = array_slice($tags, 0, $number); 642 653 643 654 $counts = array(); 655 $real_counts = array(); // For the alt tag 644 656 foreach ( (array) $tags as $key => $tag ) 645 $counts[ $key ] = $tag->count; 657 { 658 $real_counts[ $key ] = $tag->count; 659 $counts[ $key ] = $topic_count_scale_callback($tag->count); 660 } 646 661 647 662 $min_count = min( $counts ); 648 663 $spread = max( $counts ) - $min_count; … … 659 674 660 675 foreach ( $tags as $key => $tag ) { 661 676 $count = $counts[ $key ]; 677 $real_count = $real_counts[ $key ]; 662 678 $tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#'; 663 679 $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; 664 680 $tag_name = $tags[ $key ]->name; 665 $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $topic_count_text_callback( $ count ) ) . "'$rel style='font-size: " .681 $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $topic_count_text_callback( $real_count ) ) . "'$rel style='font-size: " . 666 682 ( $smallest + ( ( $count - $min_count ) * $font_step ) ) 667 683 . "$unit;'>$tag_name</a>"; 668 684 }