Make WordPress Core

Ticket #24656: 24656.diff

File 24656.diff, 2.6 KB (added by flixos90, 10 years ago)

Updated patch according to suggestions by @boonebgorges

  • src/wp-includes/category-template.php

     
    808808                $font_spread = 1;
    809809        $font_step = $font_spread / $spread;
    810810
    811         $a = array();
     811        $tags_data = array();
    812812
     813        // generate the $tags_data array
    813814        foreach ( $tags as $key => $tag ) {
    814815                $count = $counts[ $key ];
    815                 $real_count = $real_counts[ $key ];
    816                 $tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#';
    817                 $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
    818                 $tag_name = $tags[ $key ]->name;
     816                $tag_id = isset( $tag->id ) ? $tag->id : $key;
    819817
     818                $tags_data[] = array(
     819                        'id'                                    => $tag_id,
     820                        'url'                                   => '#' != $tag->link ? esc_url( $tag->link ) : '#',
     821                        'name'                          => $tag->name,
     822                        'slug'                          => $tag->slug,
     823                        'real_count'    => $real_counts[ $key ],
     824                        'class'                         => 'tag-link-' . $tag_id,
     825                        'font_size'             => $args['smallest'] + ( $count - $min_count ) * $font_step,
     826                );
     827        }
     828
     829        /**
     830         * Filter the data used to generate the tag cloud.
     831         *
     832         * @see wp_generate_tag_cloud()
     833         *
     834         * @param array        $tags   An array of term data for each term used in the tag cloud.
     835         */
     836        $tags_data = apply_filters( 'wp_generate_tag_cloud_data', $tags_data );
     837
     838        $a = array();
     839
     840        // generate the output links array
     841        foreach ( $tags_data as $key => $tag_data ) {
     842                $tag_link = $tag_data['url'];
     843                $tag_name = $tag_data['name'];
     844                $tag_class = $tag_data['class'];
     845
    820846                if ( $translate_nooped_plural ) {
    821                         $title_attribute = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) );
     847                        $title_attribute = sprintf( translate_nooped_plural( $translate_nooped_plural, $tag_data['real_count'] ), number_format_i18n( $tag_data['real_count'] ) );
    822848                } else {
    823                         $title_attribute = call_user_func( $args['topic_count_text_callback'], $real_count, $tag, $args );
     849                        $title_attribute = call_user_func( $args['topic_count_text_callback'], $tag_data['real_count'], $tags[ $key ], $args );
    824850                }
    825851
    826                 $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $title_attribute ) . "' style='font-size: " .
    827                         str_replace( ',', '.', ( $args['smallest'] + ( ( $count - $min_count ) * $font_step ) ) )
    828                         . $args['unit'] . ";'>$tag_name</a>";
     852                $a[] = "<a href='" . $tag_data['url'] . "' class='" . $tag_data['class'] . "' title='" . esc_attr( $title_attribute ) . "' style='font-size: " .
     853                        str_replace( ',', '.', $tag_data['font_size'] ) . $args['unit'] . ";'>$tag_name</a>";
    829854        }
    830855
    831856        switch ( $args['format'] ) {