[wp-trac] [WordPress Trac] #51137: wp_terms_checklist not checking selected taxonomy items with selected_cats option
WordPress Trac
noreply at wordpress.org
Tue Aug 25 13:11:40 UTC 2020
#51137: wp_terms_checklist not checking selected taxonomy items with selected_cats
option
--------------------------+-----------------------------
Reporter: brianhogg | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.5
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
Since WP 5.5, using the `selected_cats` option with an array of taxonomy
IDs as strings no longer selects those items in the checklist. It appears
line 174 of wp-admin/includes/template.php is using a strict type
comparison for in_array:
{{{
if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'], true )
) {
}}}
Since form results are often returned as strings, and the term ID will
always be an integer in the WP_Term class, I think the strict flag should
be removed. Otherwise anyone using the function would need to ensure the
array elements are integers with something like `array_map( 'intval', ...
)`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51137>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list