Revert tag cloud changes in 8540 and 8569. They broke tag sorting. see #6015

git-svn-id: http://svn.automattic.com/wordpress/trunk@8666 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-08-18 23:40:41 +00:00
parent 68ae36f22f
commit facedb8d81
1 changed files with 18 additions and 22 deletions

View File

@ -350,17 +350,11 @@ function wp_tag_cloud( $args = '' ) {
if ( empty( $tags ) )
return;
foreach ( $tags as $key => $tag ) {
$link = get_tag_link( $tag->term_id );
if ( is_wp_error( $link ) )
return false;
$tags[ $key ]->link = $link;
$tags[ $key ]->id = $tag->term_id;
}
$return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
if ( is_wp_error( $return ) )
return false;
$return = apply_filters( 'wp_tag_cloud', $return, $args );
if ( 'array' == $args['format'] )
@ -383,19 +377,22 @@ function wp_tag_cloud( $args = '' ) {
function wp_generate_tag_cloud( $tags, $args = '' ) {
global $wp_rewrite;
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt',
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
'single_text' => '%d topic', 'multiple_text' => '%d topics'
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
);
$args = wp_parse_args( $args, $defaults );
extract( $args );
if ( empty( $tags ) )
return;
$counts = array();
foreach ( (array) $tags as $key => $tag )
$counts[ $key ] = $tag->count;
$counts = $tag_links = array();
foreach ( (array) $tags as $tag ) {
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_tag_link( $tag->term_id );
if ( is_wp_error( $tag_links[$tag->name] ) )
return $tag_links[$tag->name];
$tag_ids[$tag->name] = $tag->term_id;
}
$min_count = min( $counts );
$spread = max( $counts ) - $min_count;
@ -426,13 +423,12 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
foreach ( $counts as $key => $count ) {
$tag_link = clean_url( $tags[ $key ]->link );
$tag_id = $tags[ $key ]->id;
$tag_name = $tags[ $key ]->name;
$a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . attribute_escape( sprintf( __ngettext( $single_text, $multiple_text, $count ), $count ) ) . "'$rel style='font-size: " .
foreach ( $counts as $tag => $count ) {
$tag_id = $tag_ids[$tag];
$tag_link = clean_url($tag_links[$tag]);
$a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . attribute_escape( sprintf( __ngettext('%d topic','%d topics',$count), $count ) ) . "'$rel style='font-size: " .
( $smallest + ( ( $count - $min_count ) * $font_step ) )
. "$unit;'>$tag_name</a>";
. "$unit;'>$tag</a>";
}
switch ( $format ) :