Make WordPress Core

Opened 6 weeks ago

Last modified 6 weeks ago

#62762 new enhancement

WP_Widget_Categories::widget(): use int or bool for $cat_args values instead of numeric strings

Reported by: marian1's profile marian1 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version:
Component: Widgets Keywords: has-patch
Focuses: Cc:

Description

Both $cat_args['show_count'] and $cat_args['hierarchical'] are currently set to '0' or '1' (numeric strings). See 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 wp_list_categories and 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.

Change History (1)

This ticket was mentioned in PR #8071 on WordPress/wordpress-develop by @marian1.


6 weeks ago
#1

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.