diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index fde22f4abf..5ab23960b2 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -565,6 +565,17 @@ function default_topic_count_text( $count ) { return sprintf( _n('%s topic', '%s topics', $count), number_format_i18n( $count ) ); } +/** + * Default topic count scaling for tag links + * + * @param integer $count number of posts with that tag + * @return integer scaled count + */ +function default_topic_count_scale( $count ) { + return round(log10($count + 1) * 100); +} + + /** * Generates a tag cloud (heatmap) from provided data. * @@ -602,7 +613,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 'topic_count_text_callback' => 'default_topic_count_text', - 'filter' => 1, + 'filter' => 1, 'topic_count_scale_callback' => 'default_topic_count_scale' ); if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) { @@ -641,8 +652,11 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { $tags = array_slice($tags, 0, $number); $counts = array(); - foreach ( (array) $tags as $key => $tag ) - $counts[ $key ] = $tag->count; + $real_counts = array(); // For the alt tag + foreach ( (array) $tags as $key => $tag ) { + $real_counts[ $key ] = $tag->count; + $counts[ $key ] = $topic_count_scale_callback($tag->count); + } $min_count = min( $counts ); $spread = max( $counts ) - $min_count; @@ -659,10 +673,11 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { foreach ( $tags as $key => $tag ) { $count = $counts[ $key ]; + $real_count = $real_counts[ $key ]; $tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#'; $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; $tag_name = $tags[ $key ]->name; - $a[] = "$tag_name"; }