73 $taxonomy = 'category'; |
73 $taxonomy = 'category'; |
74 } else { |
74 } else { |
75 $taxonomy = $args['taxonomy']; |
75 $taxonomy = $args['taxonomy']; |
76 } |
76 } |
77 |
77 |
78 if ( $taxonomy == 'category' ) { |
78 if ( 'category' === $taxonomy ) { |
79 $name = 'post_category'; |
79 $name = 'post_category'; |
80 } else { |
80 } else { |
81 $name = 'tax_input[' . $taxonomy . ']'; |
81 $name = 'tax_input[' . $taxonomy . ']'; |
82 } |
82 } |
83 |
83 |
84 $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats']; |
84 $args['popular_cats'] = ! empty( $args['popular_cats'] ) ? array_map( 'intval', $args['popular_cats'] ) : array(); |
85 $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : ''; |
|
86 |
85 |
87 $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats']; |
86 $class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : ''; |
|
87 |
|
88 $args['selected_cats'] = ! empty( $args['selected_cats'] ) ? array_map( 'intval', $args['selected_cats'] ) : array(); |
88 |
89 |
89 if ( ! empty( $args['list_only'] ) ) { |
90 if ( ! empty( $args['list_only'] ) ) { |
90 $aria_checked = 'false'; |
91 $aria_checked = 'false'; |
91 $inner_class = 'category'; |
92 $inner_class = 'category'; |
92 |
93 |
93 if ( in_array( $category->term_id, $args['selected_cats'] ) ) { |
94 if ( in_array( $category->term_id, $args['selected_cats'], true ) ) { |
94 $inner_class .= ' selected'; |
95 $inner_class .= ' selected'; |
95 $aria_checked = 'true'; |
96 $aria_checked = 'true'; |
96 } |
97 } |
97 |
98 |
98 /** This filter is documented in wp-includes/category-template.php */ |
|
99 $output .= "\n" . '<li' . $class . '>' . |
99 $output .= "\n" . '<li' . $class . '>' . |
100 '<div class="' . $inner_class . '" data-term-id=' . $category->term_id . |
100 '<div class="' . $inner_class . '" data-term-id=' . $category->term_id . |
101 ' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' . |
101 ' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' . |
|
102 /** This filter is documented in wp-includes/category-template.php */ |
102 esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>'; |
103 esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>'; |
103 } else { |
104 } else { |
104 /** This filter is documented in wp-includes/category-template.php */ |
105 $is_selected = in_array( $category->term_id, $args['selected_cats'], true ); |
|
106 $is_disabled = ! empty( $args['disabled'] ); |
|
107 |
105 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . |
108 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . |
106 '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' . |
109 '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' . |
107 checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) . |
110 checked( $is_selected, true, false ) . |
108 disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . |
111 disabled( $is_disabled, true, false ) . ' /> ' . |
|
112 /** This filter is documented in wp-includes/category-template.php */ |
109 esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>'; |
113 esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>'; |
110 } |
114 } |
111 } |
115 } |
112 |
116 |
113 /** |
117 /** |