--- a/wp/wp-admin/includes/class-walker-category-checklist.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/includes/class-walker-category-checklist.php Tue Dec 15 13:49:49 2020 +0100
@@ -21,7 +21,7 @@
public $db_fields = array(
'parent' => 'parent',
'id' => 'term_id',
- ); //TODO: decouple this
+ ); // TODO: Decouple this.
/**
* Starts the list before the elements are added.
@@ -75,37 +75,41 @@
$taxonomy = $args['taxonomy'];
}
- if ( $taxonomy == 'category' ) {
+ if ( 'category' === $taxonomy ) {
$name = 'post_category';
} else {
$name = 'tax_input[' . $taxonomy . ']';
}
- $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
- $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
+ $args['popular_cats'] = ! empty( $args['popular_cats'] ) ? array_map( 'intval', $args['popular_cats'] ) : array();
- $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
+ $class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : '';
+
+ $args['selected_cats'] = ! empty( $args['selected_cats'] ) ? array_map( 'intval', $args['selected_cats'] ) : array();
if ( ! empty( $args['list_only'] ) ) {
$aria_checked = 'false';
$inner_class = 'category';
- if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
+ if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
$inner_class .= ' selected';
$aria_checked = 'true';
}
- /** This filter is documented in wp-includes/category-template.php */
$output .= "\n" . '<li' . $class . '>' .
'<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' .
+ /** This filter is documented in wp-includes/category-template.php */
esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
} else {
- /** This filter is documented in wp-includes/category-template.php */
+ $is_selected = in_array( $category->term_id, $args['selected_cats'], true );
+ $is_disabled = ! empty( $args['disabled'] );
+
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
- checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
- disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
+ checked( $is_selected, true, false ) .
+ disabled( $is_disabled, true, false ) . ' /> ' .
+ /** This filter is documented in wp-includes/category-template.php */
esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
}
}