Eliminate use of extract() in wp_generate_tag_cloud().

See #22400.

Built from https://develop.svn.wordpress.org/trunk@28435


git-svn-id: http://core.svn.wordpress.org/trunk@28262 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-05-15 17:48:15 +00:00
parent 9c8becc1f7
commit 9b210df2b9

View File

@ -685,9 +685,8 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
); );
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
extract( $args, EXTR_SKIP );
$return = ( 'array' === $format ) ? array() : ''; $return = ( 'array' === $args['format'] ) ? array() : '';
if ( empty( $tags ) ) { if ( empty( $tags ) ) {
return $return; return $return;
@ -729,37 +728,37 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
$tags = $tags_sorted; $tags = $tags_sorted;
unset( $tags_sorted ); unset( $tags_sorted );
} else { } else {
if ( 'RAND' === $order ) { if ( 'RAND' === $args['order'] ) {
shuffle( $tags ); shuffle( $tags );
} else { } else {
// SQL cannot save you; this is a second (potentially different) sort on a subset of data. // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ( 'name' === $orderby ) { if ( 'name' === $args['orderby'] ) {
uasort( $tags, '_wp_object_name_sort_cb' ); uasort( $tags, '_wp_object_name_sort_cb' );
} else { } else {
uasort( $tags, '_wp_object_count_sort_cb' ); uasort( $tags, '_wp_object_count_sort_cb' );
} }
if ( 'DESC' === $order ) { if ( 'DESC' === $args['order'] ) {
$tags = array_reverse( $tags, true ); $tags = array_reverse( $tags, true );
} }
} }
} }
if ( $number > 0 ) if ( $args['number'] > 0 )
$tags = array_slice($tags, 0, $number); $tags = array_slice( $tags, 0, $args['number'] );
$counts = array(); $counts = array();
$real_counts = array(); // For the alt tag $real_counts = array(); // For the alt tag
foreach ( (array) $tags as $key => $tag ) { foreach ( (array) $tags as $key => $tag ) {
$real_counts[ $key ] = $tag->count; $real_counts[ $key ] = $tag->count;
$counts[ $key ] = $topic_count_scale_callback($tag->count); $counts[ $key ] = call_user_func( $args['topic_count_scale_callback'], $tag->count );
} }
$min_count = min( $counts ); $min_count = min( $counts );
$spread = max( $counts ) - $min_count; $spread = max( $counts ) - $min_count;
if ( $spread <= 0 ) if ( $spread <= 0 )
$spread = 1; $spread = 1;
$font_spread = $largest - $smallest; $font_spread = $args['largest'] - $args['smallest'];
if ( $font_spread < 0 ) if ( $font_spread < 0 )
$font_spread = 1; $font_spread = 1;
$font_step = $font_spread / $spread; $font_step = $font_spread / $spread;
@ -776,15 +775,15 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
if ( $translate_nooped_plural ) { if ( $translate_nooped_plural ) {
$title_attribute = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) ); $title_attribute = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) );
} else { } else {
$title_attribute = call_user_func( $topic_count_text_callback, $real_count, $tag, $args ); $title_attribute = call_user_func( $args['topic_count_text_callback'], $real_count, $tag, $args );
} }
$a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $title_attribute ) . "' style='font-size: " . $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $title_attribute ) . "' style='font-size: " .
str_replace( ',', '.', ( $smallest + ( ( $count - $min_count ) * $font_step ) ) ) str_replace( ',', '.', ( $args['smallest'] + ( ( $count - $min_count ) * $font_step ) ) )
. "$unit;'>$tag_name</a>"; . $args['unit'] . ";'>$tag_name</a>";
} }
switch ( $format ) : switch ( $args['format'] ) :
case 'array' : case 'array' :
$return =& $a; $return =& $a;
break; break;
@ -794,11 +793,11 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
$return .= "</li>\n</ul>\n"; $return .= "</li>\n</ul>\n";
break; break;
default : default :
$return = join( $separator, $a ); $return = join( $args['separator'], $a );
break; break;
endswitch; endswitch;
if ( $filter ) { if ( $args['filter'] ) {
/** /**
* Filter the generated output of a tag cloud. * Filter the generated output of a tag cloud.
* *