Make WordPress Core

Ticket #24656: 24656#category-template.php.patch

File 24656#category-template.php.patch, 3.1 KB (added by ysalame, 13 years ago)
  • category-template.php

     
    498498 * argument can be 'flat' (default), 'list', or 'array'. The flat value for the
    499499 * 'format' argument will separate tags with spaces. The list value for the
    500500 * 'format' argument will format the tags in a UL HTML list. The array value for
    501  * the 'format' argument will return in PHP array type format.
     501 * the 'format' argument will return in PHP array type format. The array value
     502 * for the 'object' argument will return an array of objects with unformated
     503 * data.
    502504 *
    503505 * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
    504506 * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'.
     
    547549
    548550        $return = apply_filters( 'wp_tag_cloud', $return, $args );
    549551
    550         if ( 'array' == $args['format'] || empty($args['echo']) )
     552        if ( 'array' == $args['format'] || 'object' == $args['format'] || empty($args['echo']) )
    551553                return $return;
    552554
    553555        echo $return;
     
    581583 * argument can be 'flat' (default), 'list', or 'array'. The flat value for the
    582584 * 'format' argument will separate tags with spaces. The list value for the
    583585 * 'format' argument will format the tags in a UL HTML list. The array value for
    584  * the 'format' argument will return in PHP array type format.
     586 * the 'format' argument will return in PHP array type format. The array value
     587 * for the 'object' argument will return an array of objects with unformated
     588 * data.
    585589 *
    586590 * The 'tag_cloud_sort' filter allows you to override the sorting.
    587591 * Passed to the filter: $tags array and $args array, has to return the $tags array
     
    671675                $tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#';
    672676                $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
    673677                $tag_name = $tags[ $key ]->name;
    674                 $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( call_user_func( $topic_count_text_callback, $real_count, $tag, $args ) ) . "' style='font-size: " .
    675                         str_replace( ',', '.', ( $smallest + ( ( $count - $min_count ) * $font_step ) ) )
    676                         . "$unit;'>$tag_name</a>";
     678
     679                if ($format == 'object')
     680                {
     681                        $tag_record = new stdClass;
     682                        $tag_record->id = $tag_id;
     683                        $tag_record->url = $tag_link;
     684                        $tag_record->name = $tag_name;
     685                        $tag_record->slug = $tags[$key]->slug;
     686                        $tag_record->real_count = $real_count;
     687                        $tag_record->class = 'tag-link-'.$tag_id;
     688                        $tag_record->size       = $smallest + ($count - $min_count);
     689                        $tag_record->font_size = ($smallest + (($count - $min_count) * $font_step));
     690                        $a[] = $tag_record;
     691                } else {
     692                        $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( call_user_func( $topic_count_text_callback, $real_count, $tag, $args ) ) . "' style='font-size: " .
     693                                str_replace( ',', '.', ( $smallest + ( ( $count - $min_count ) * $font_step ) ) )
     694                                . "$unit;'>$tag_name</a>";
     695                }
    677696        }
    678697
    679698        switch ( $format ) :
    680699        case 'array' :
     700        case 'object' :
    681701                $return =& $a;
    682702                break;
    683703        case 'list' :