Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#14577 closed defect (bug) (duplicate)

wp_generate_tag_cloud() font-size generated with comma as decimal separator

Reported by: elvarsteinn's profile elvarsteinn Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.1
Component: Taxonomy Keywords: has-patch 3.2-early gsoc
Focuses: Cc:

Description

Hello,
the wp_generate_tag_cloud() function in category-template.php was causing me problems since it returned style="font-size: 1,723828em" for example, and at least on FireFox 3.6 in MacOs the comma caused the browser to ignore the font-size attribute wholly, causing all but the largest tag (since that came down to an even 2em) to be the same size.

I'm guessing that on other php Configurations (im on a server in Germany, where comma is the correct decimal separator) a point is returned by php as the decimal separator, and hence for people running english php configurations, this wouldn't be a problem. Also i assume some browsers / configurations dont mind getting the value with a comma separator, but mine did, and it isnt a very strange browser/OS combination im running.

Bug (line 715-717 in category-template.php):

$a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $topic_count_text_callback( $real_count ) ) . "' style='font-size: " .

( $smallest + ( ( $count - $min_count ) * $font_step ) )
. "$unit;'>$tag_name</a>";

Fix:

$a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $topic_count_text_callback( $real_count ) ) . "' style='font-size: " .

number_format( ( $smallest + ( ( $count - $min_count ) * $font_step ) ), 3, '.', ',')
. "$unit;'>$tag_name</a>";

Of course the rounding value of 3 could be chosen differently, or set to 12 (? not sure) to not round at all (personally i feel you would never need more than 3 decimal places, and it does make the html look nicer). Alternatively, str_replace can replace a comma with a point.

Attachments (1)

14577.diff (676 bytes) - added by wojtek.szkutnik 14 years ago.

Download all attachments as: .zip

Change History (5)

#1 @wojtek.szkutnik
14 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords has-patch needs-testing gsoc added; wp_generate_tag_cloud tag cloud font size comma point category-template.php removed

I think 4 is the maximum number of digits considered by some browsers after the decimal point.

Also, we don't want ',' as a thousands separator, do we?

#2 @nacin
14 years ago

Related #11727

#3 @dd32
14 years ago

  • Keywords 3.2-early added
  • Milestone changed from Awaiting Review to Future Release

As crazy as it may first sound, this is a possibility.
It'll only affect sites in which, the PHP Locale has been set to a certain language, for example, French.

For an example of how to trigger it, have a look at the final code in this PHP Manual comment: http://www.php.net/manual/en/language.types.float.php#92885

#4 @SergeyBiryukov
13 years ago

  • Component changed from General to Taxonomy
  • Keywords needs-testing removed
  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

#19593, #19624

Fixed in [20675].

Note: See TracTickets for help on using tickets.