[wp-trac] [WordPress Trac] #62762: WP_Widget_Categories::widget(): use int or bool for $cat_args values instead of numeric strings

WordPress Trac noreply at wordpress.org
Wed Jan 1 23:17:01 UTC 2025


#62762: WP_Widget_Categories::widget(): use int or bool for $cat_args values
instead of numeric strings
-------------------------+-----------------------------
 Reporter:  marian1      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Widgets      |    Version:
 Severity:  trivial      |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Both `$cat_args['show_count']` and `$cat_args['hierarchical']` are
 currently set to `'0'` or `'1'` (numeric strings). See
 [https://github.com/WordPress/WordPress/blob/275d202ae3baac4e674538fd5bc3bc660825d0e0
 /wp-includes/widgets/class-wp-widget-categories.php#L54-L68 lines 54 to 68
 in class-wp-widget-categories.php]. These values are then passed to
 `wp_dropdown_categories()` or `wp_list_categories()`, both of which are
 documented to expect `int|bool` for `$cat_args['show_count']` and
 `$cat_args['hierarchical']`. See the function references for
 [https://developer.wordpress.org/reference/functions/wp_list_categories/
 wp_list_categories] and
 [https://developer.wordpress.org/reference/functions/wp_dropdown_categories/
 wp_dropdown_categories].

 As using integers or booleans instead of numeric strings does not alter
 the behaviour of `WP_Widget_Categories::widget()`, specifying
 `$cat_args['show_count']` and `$cat_args['hierarchical']` either as
 booleans or integers would increase type consistency.

 Also, `$dropdown` (line 56) is set to `'0'` or `'1'` and could be set to
 `true` or `false` instead.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62762>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list