Opened 18 years ago
Closed 18 years ago
#5462 closed enhancement (fixed)
invalid nested category HTML list in admin
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.5 | Priority: | normal |
| Severity: | normal | Version: | 2.3.1 |
| Component: | General | Keywords: | has-patch |
| Focuses: | Cc: |
Description
'dropdown_categories' function in wp-admin/includes/template.php returns invalid html list
<ul> <li>a</li> <li>b</li> <ul> <li>b-1</li> <li>b-2</li> </ul> <li>c</li> </ul>
It should be
<ul> <li>a</li> <li>b <ul> <li>b-1</li> <li>b-2</li> </ul> </li> <li>c</li> </ul>
We just need to print '</li>' after child list if a category has children.
function write_nested_categories( $categories ) {
foreach ( $categories as $category ) {
echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), "</label>";
if ( $category['children'] ) {
echo "<ul>\n";
write_nested_categories( $category['children'] );
echo "</ul>\n";
}
echo "</li>";
}
}
It displayed well on blog, but while I was trying to make 'AJAX category adder for specific parent category', it matters.
Attachments (1)
Change History (3)
Note: See
TracTickets for help on using
tickets.
Thanks for your contributions to WordPress.
First, we will apply the patch to 2.4 (trunk), then backport it to 2.3 if we deem it to be important enough.