| 380 | | 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, |
|---|
| 381 | | 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC' |
|---|
| | 386 | 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0, |
|---|
| | 387 | 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', |
|---|
| | 388 | 'single_text' => '%d topic', 'multiple_text' => '%d topics' |
|---|
| 388 | | $counts = $tag_links = array(); |
|---|
| 389 | | foreach ( (array) $tags as $tag ) { |
|---|
| 390 | | $counts[$tag->name] = $tag->count; |
|---|
| 391 | | $tag_links[$tag->name] = get_tag_link( $tag->term_id ); |
|---|
| 392 | | if ( is_wp_error( $tag_links[$tag->name] ) ) |
|---|
| 393 | | return $tag_links[$tag->name]; |
|---|
| 394 | | $tag_ids[$tag->name] = $tag->term_id; |
|---|
| 395 | | } |
|---|
| | 395 | |
|---|
| | 396 | // SQL cannot save you; this is a second (potentially different) sort on a subset of data. |
|---|
| | 397 | if ( 'name' == $orderby ) |
|---|
| | 398 | uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') ); |
|---|
| | 399 | else |
|---|
| | 400 | uasort( $tags, create_function('$a, $b', 'return ($a->count < $b->count);') ); |
|---|
| | 401 | |
|---|
| | 402 | if ( 'DESC' == $order ) |
|---|
| | 403 | $tags = array_reverse( $tags, true ); |
|---|
| | 404 | elseif ( 'RAND' == $order ) { |
|---|
| | 405 | $keys = array_rand( $tags, count( $tags ) ); |
|---|
| | 406 | foreach ( $keys as $key ) |
|---|
| | 407 | $temp[$key] = $tags[$key]; |
|---|
| | 408 | $tags = $temp; |
|---|
| | 409 | unset( $temp ); |
|---|
| | 410 | } |
|---|
| | 411 | |
|---|
| | 412 | if ( $number > 0 ) |
|---|
| | 413 | $tags = array_slice($tags, 0, $number); |
|---|
| | 414 | |
|---|
| | 415 | $counts = array(); |
|---|
| | 416 | foreach ( (array) $tags as $key => $tag ) |
|---|
| | 417 | $counts[ $key ] = $tag->count; |
|---|
| 406 | | // SQL cannot save you; this is a second (potentially different) sort on a subset of data. |
|---|
| 407 | | if ( 'name' == $orderby ) |
|---|
| 408 | | uksort( $counts, 'strnatcasecmp' ); |
|---|
| 409 | | else |
|---|
| 410 | | asort( $counts ); |
|---|
| 411 | | |
|---|
| 412 | | if ( 'DESC' == $order ) |
|---|
| 413 | | $counts = array_reverse( $counts, true ); |
|---|
| 414 | | elseif ( 'RAND' == $order ) { |
|---|
| 415 | | $keys = array_rand( $counts, count( $counts ) ); |
|---|
| 416 | | foreach ( $keys as $key ) |
|---|
| 417 | | $temp[$key] = $counts[$key]; |
|---|
| 418 | | $counts = $temp; |
|---|
| 419 | | unset( $temp ); |
|---|
| 420 | | } |
|---|
| 421 | | |
|---|
| 426 | | foreach ( $counts as $tag => $count ) { |
|---|
| 427 | | $tag_id = $tag_ids[$tag]; |
|---|
| 428 | | $tag_link = clean_url($tag_links[$tag]); |
|---|
| 429 | | $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: " . |
|---|
| | 432 | foreach ( $tags as $key => $tag ) { |
|---|
| | 433 | $count = $counts[ $key ]; |
|---|
| | 434 | $tag_link = clean_url( $tag->link ); |
|---|
| | 435 | $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; |
|---|
| | 436 | $tag_name = $tags[ $key ]->name; |
|---|
| | 437 | $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: " . |
|---|