Allow for non-contiguous array indices. Props hailin. fixes #9670

git-svn-id: https://develop.svn.wordpress.org/trunk@11130 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-04-29 21:01:51 +00:00
parent b1bf7685ce
commit ef738c9b9b
1 changed files with 7 additions and 5 deletions

View File

@ -510,11 +510,13 @@ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $select
// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
$checked_categories = array(); $checked_categories = array();
for ( $i = 0; isset($categories[$i]); $i++ ) { $keys = array_keys( $categories );
if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
$checked_categories[] = $categories[$i]; foreach( $keys as $k ) {
unset($categories[$i]); if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
} $checked_categories[] = $categories[$k];
unset( $categories[$k] );
}
} }
// Put checked cats on top // Put checked cats on top