change_radiolist = $change_radiolist; $this->checklist_no_top = $checklist_no_top; $this->required = $required; } function category_has_children( $term_id = 0, $taxonomy = 'category' ) { $children = get_terms( $taxonomy, array( 'child_of' => $term_id, 'hide_empty' => false ) ); return ( $children ); } public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { if ( empty( $args['taxonomy'] ) ) { $taxonomy = 'category'; } else { $taxonomy = $args['taxonomy']; } if ( $taxonomy == 'category' ) { $name = 'post_category'; } else { $name = 'tax_input[' . $taxonomy . ']'; } $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats']; $class_names = in_array( $category->term_id, $args['popular_cats'] ) ? 'popular-category' : ''; $class_names = apply_filters( 'aac_category_wrapper_class', $class_names, $category ); $class = ''; if(!empty($class_names)){ $class = ' class="'.$class_names.'"'; } $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats']; $required = ''; if($this->required == true){ $required = 'required'; } if ( ! empty( $args['list_only'] ) ) { $aria_cheched = 'false'; $inner_class = 'category'; if ( in_array( $category->term_id, $args['selected_cats'] ) ) { $inner_class .= ' selected'; $aria_cheched = 'true'; } /** This filter is documented in wp-includes/category-template.php */ $output .= "\n" . '' . ''; } else { $input_type = 'checkbox'; if($this->change_radiolist == true){ $input_type = 'radio'; } $input_class = 'rwmb-'.$input_type; $input_class = apply_filters( 'aac_category_input_class', $input_class, $category ); if($this->checklist_no_top == true){ if( $this->category_has_children( $category->term_id, $category->taxonomy ) ) { $output .= "\n
  • " . '' . esc_html( apply_filters( 'the_category', $category->name ) ) . ''; }else{ /** This filter is documented in wp-includes/category-template.php */ $output .= "\n
  • " . ''; } }else{ /** This filter is documented in wp-includes/category-template.php */ $output .= "\n
  • " . ''; } } } }