From 9b210df2b987413bc839fafa40800e59f8c15434 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 15 May 2014 17:48:15 +0000 Subject: [PATCH] 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 --- wp-includes/category-template.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 621761efb3..25d6da9c2e 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -685,9 +685,8 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { ); $args = wp_parse_args( $args, $defaults ); - extract( $args, EXTR_SKIP ); - $return = ( 'array' === $format ) ? array() : ''; + $return = ( 'array' === $args['format'] ) ? array() : ''; if ( empty( $tags ) ) { return $return; @@ -729,37 +728,37 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { $tags = $tags_sorted; unset( $tags_sorted ); } else { - if ( 'RAND' === $order ) { + if ( 'RAND' === $args['order'] ) { shuffle( $tags ); } else { // 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' ); } else { uasort( $tags, '_wp_object_count_sort_cb' ); } - if ( 'DESC' === $order ) { + if ( 'DESC' === $args['order'] ) { $tags = array_reverse( $tags, true ); } } } - if ( $number > 0 ) - $tags = array_slice($tags, 0, $number); + if ( $args['number'] > 0 ) + $tags = array_slice( $tags, 0, $args['number'] ); $counts = array(); $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); + $counts[ $key ] = call_user_func( $args['topic_count_scale_callback'], $tag->count ); } $min_count = min( $counts ); $spread = max( $counts ) - $min_count; if ( $spread <= 0 ) $spread = 1; - $font_spread = $largest - $smallest; + $font_spread = $args['largest'] - $args['smallest']; if ( $font_spread < 0 ) $font_spread = 1; $font_step = $font_spread / $spread; @@ -776,15 +775,15 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { if ( $translate_nooped_plural ) { $title_attribute = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) ); } 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[] = "$tag_name"; + str_replace( ',', '.', ( $args['smallest'] + ( ( $count - $min_count ) * $font_step ) ) ) + . $args['unit'] . ";'>$tag_name"; } - switch ( $format ) : + switch ( $args['format'] ) : case 'array' : $return =& $a; break; @@ -794,11 +793,11 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { $return .= "\n\n"; break; default : - $return = join( $separator, $a ); + $return = join( $args['separator'], $a ); break; endswitch; - if ( $filter ) { + if ( $args['filter'] ) { /** * Filter the generated output of a tag cloud. *