mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-17 03:56:07 +00:00
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:
parent
68ae36f22f
commit
facedb8d81
@ -350,17 +350,11 @@ function wp_tag_cloud( $args = '' ) {
|
|||||||
if ( empty( $tags ) )
|
if ( empty( $tags ) )
|
||||||
return;
|
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
|
$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 );
|
$return = apply_filters( 'wp_tag_cloud', $return, $args );
|
||||||
|
|
||||||
if ( 'array' == $args['format'] )
|
if ( 'array' == $args['format'] )
|
||||||
@ -383,19 +377,22 @@ function wp_tag_cloud( $args = '' ) {
|
|||||||
function wp_generate_tag_cloud( $tags, $args = '' ) {
|
function wp_generate_tag_cloud( $tags, $args = '' ) {
|
||||||
global $wp_rewrite;
|
global $wp_rewrite;
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'smallest' => 8, 'largest' => 22, 'unit' => 'pt',
|
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
|
||||||
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
|
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
|
||||||
'single_text' => '%d topic', 'multiple_text' => '%d topics'
|
|
||||||
);
|
);
|
||||||
$args = wp_parse_args( $args, $defaults );
|
$args = wp_parse_args( $args, $defaults );
|
||||||
extract( $args );
|
extract( $args );
|
||||||
|
|
||||||
if ( empty( $tags ) )
|
if ( empty( $tags ) )
|
||||||
return;
|
return;
|
||||||
|
$counts = $tag_links = array();
|
||||||
$counts = array();
|
foreach ( (array) $tags as $tag ) {
|
||||||
foreach ( (array) $tags as $key => $tag )
|
$counts[$tag->name] = $tag->count;
|
||||||
$counts[ $key ] = $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 );
|
$min_count = min( $counts );
|
||||||
$spread = max( $counts ) - $min_count;
|
$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"' : '';
|
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
|
||||||
|
|
||||||
foreach ( $counts as $key => $count ) {
|
foreach ( $counts as $tag => $count ) {
|
||||||
$tag_link = clean_url( $tags[ $key ]->link );
|
$tag_id = $tag_ids[$tag];
|
||||||
$tag_id = $tags[ $key ]->id;
|
$tag_link = clean_url($tag_links[$tag]);
|
||||||
$tag_name = $tags[ $key ]->name;
|
$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: " .
|
||||||
$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: " .
|
|
||||||
( $smallest + ( ( $count - $min_count ) * $font_step ) )
|
( $smallest + ( ( $count - $min_count ) * $font_step ) )
|
||||||
. "$unit;'>$tag_name</a>";
|
. "$unit;'>$tag</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( $format ) :
|
switch ( $format ) :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user