Commit cdac6595ed for wordpress.org
commit cdac6595ed82af8bb2a7330e1f4c2510e1fb1889
Author: westonruter <westonruter@git.wordpress.org>
Date: Sun Nov 1 05:59:56 2026 +0000
Taxonomy: Fix tag cloud handling of float font sizes.
The `smallest` and `largest` arguments of `wp_generate_tag_cloud()` were documented as integers, but they are only used in arithmetic, and the Tag Cloud block always passes them as floats so that its font size settings can be fractional. They are now documented as `int|float`.
Accepting floats exposed a bug. The `aria-label` on each tag is meant to be omitted when all tags share one font size, which was checked by comparing the font spread against the integer `0`. With equal float sizes the spread is `0.0`, which is not identical to `0`, so the `aria-label` was output anyway, including for any Tag Cloud block whose smallest and largest sizes matched. The spread is now checked for being greater than zero; a negative spread was already clamped to `1`.
Developed in https://github.com/WordPress/wordpress-develop/pull/15306.
Follow-up to r40816.
Props huzaifaalmesbah, westonruter.
See #65817.
Built from https://develop.svn.wordpress.org/trunk@65161
git-svn-id: http://core.svn.wordpress.org/trunk@64310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
index dbb1ff8ab0..f48ebe6adb 100644
--- a/wp-includes/category-template.php
+++ b/wp-includes/category-template.php
@@ -819,38 +819,38 @@ function default_topic_count_scale( $count ) {
* @param string|array $args {
* Optional. Array or string of arguments for generating a tag cloud.
*
- * @type int $smallest Smallest font size used to display tags. Paired
- * with the value of `$unit`, to determine CSS text
- * size unit. Default 8 (pt).
- * @type int $largest Largest font size used to display tags. Paired
- * with the value of `$unit`, to determine CSS text
- * size unit. Default 22 (pt).
- * @type string $unit CSS text size unit to use with the `$smallest`
- * and `$largest` values. Accepts any valid CSS text
- * size unit. Default 'pt'.
- * @type int $number The number of tags to return. Accepts any
- * positive integer or zero to return all.
- * Default 0.
- * @type string $format Format to display the tag cloud in. Accepts 'flat'
- * (tags separated with spaces), 'list' (tags displayed
- * in an unordered list), or 'array' (returns an array).
- * Default 'flat'.
- * @type string $separator HTML or text to separate the tags. Default "\n" (newline).
- * @type string $orderby Value to order tags by. Accepts 'name' or 'count'.
- * Default 'name'. The {@see 'tag_cloud_sort'} filter
- * can also affect how tags are sorted.
- * @type string $order How to order the tags. Accepts 'ASC' (ascending),
- * 'DESC' (descending), or 'RAND' (random). Default 'ASC'.
- * @type int|bool $filter Whether to enable filtering of the final output
- * via {@see 'wp_generate_tag_cloud'}. Default 1.
- * @type array $topic_count_text Nooped plural text from _n_noop() to supply to
- * tag counts. Default null.
- * @type callable $topic_count_text_callback Callback used to generate nooped plural text for
- * tag counts based on the count. Default null.
- * @type callable $topic_count_scale_callback Callback used to determine the tag count scaling
- * value. Default default_topic_count_scale().
- * @type bool|int $show_count Whether to display the tag counts. Default 0. Accepts
- * 0, 1, or their bool equivalents.
+ * @type int|float $smallest Smallest font size used to display tags. Paired
+ * with the value of `$unit`, to determine CSS text
+ * size unit. Default 8 (pt).
+ * @type int|float $largest Largest font size used to display tags. Paired
+ * with the value of `$unit`, to determine CSS text
+ * size unit. Default 22 (pt).
+ * @type string $unit CSS text size unit to use with the `$smallest`
+ * and `$largest` values. Accepts any valid CSS text
+ * size unit. Default 'pt'.
+ * @type int $number The number of tags to return. Accepts any
+ * positive integer or zero to return all.
+ * Default 0.
+ * @type string $format Format to display the tag cloud in. Accepts 'flat'
+ * (tags separated with spaces), 'list' (tags displayed
+ * in an unordered list), or 'array' (returns an array).
+ * Default 'flat'.
+ * @type string $separator HTML or text to separate the tags. Default "\n" (newline).
+ * @type string $orderby Value to order tags by. Accepts 'name' or 'count'.
+ * Default 'name'. The {@see 'tag_cloud_sort'} filter
+ * can also affect how tags are sorted.
+ * @type string $order How to order the tags. Accepts 'ASC' (ascending),
+ * 'DESC' (descending), or 'RAND' (random). Default 'ASC'.
+ * @type int|bool $filter Whether to enable filtering of the final output
+ * via {@see 'wp_generate_tag_cloud'}. Default 1.
+ * @type array $topic_count_text Nooped plural text from _n_noop() to supply to
+ * tag counts. Default null.
+ * @type callable $topic_count_text_callback Callback used to generate nooped plural text for
+ * tag counts based on the count. Default null.
+ * @type callable $topic_count_scale_callback Callback used to determine the tag count scaling
+ * value. Default default_topic_count_scale().
+ * @type bool|int $show_count Whether to display the tag counts. Default 0. Accepts
+ * 0, 1, or their bool equivalents.
* }
* @return string|string[] Tag cloud as a string or an array, depending on 'format' argument.
*
@@ -970,7 +970,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
* - when the tag count is displayed (for example when users check the checkbox in the
* Tag Cloud widget), regardless of the tags font size
*/
- if ( $args['show_count'] || 0 !== $font_spread ) {
+ if ( $args['show_count'] || $font_spread > 0 ) {
$aria_label = true;
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index bfc4c9eb50..31eed82825 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta3-65160';
+$wp_version = '7.2-beta3-65161';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.