WordPress.org

Make WordPress Core

Ticket #7000: selected-cat-hierarchy.1.diff

File selected-cat-hierarchy.1.diff, 1.6 KB (added by sivel, 9 years ago)
  • wp-admin/includes/template.php

     
    460460
    461461        function start_el(&$output, $category, $depth, $args) {
    462462                extract($args);
    463 
     463                $parent_name = '';
     464                if ( $category->parent > 0 ) {
     465                        $parent = get_category($category->parent);
     466                        if ( ( in_array( $parent->term_id, $selected_cats ) && ! in_array( $category->term_id, $selected_cats ) ) || ( ! in_array( $parent->term_id, $selected_cats ) && in_array( $category->term_id, $selected_cats ) ) )
     467                                $parent_name = "{$parent->name}: ";
     468                }
    464469                $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
    465                 $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
     470                $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $parent_name . $category->name )) . '</label>';
    466471        }
    467472
    468473        function end_el(&$output, $category, $depth, $args) {