[wp-trac] [WordPress Trac] #5462: invalid nested category HTML list
in admin
WordPress Trac
wp-trac at lists.automattic.com
Thu Dec 13 02:17:57 GMT 2007
#5462: invalid nested category HTML list in admin
-------------------------+--------------------------------------------------
Reporter: 082net | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone: 2.3.2
Component: General | Version: 2.3.1
Severity: normal | Keywords: has-patch
-------------------------+--------------------------------------------------
'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.
--
Ticket URL: <http://trac.wordpress.org/ticket/5462>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list