Make WordPress Core

Changeset 11130


Ignore:
Timestamp:
04/29/2009 09:01:51 PM (15 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r11123 r11130  
    511511    // 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)
    512512    $checked_categories = array();
    513     for ( $i = 0; isset($categories[$i]); $i++ ) {
    514         if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
    515             $checked_categories[] = $categories[$i];
    516             unset($categories[$i]);
    517         }
     513    $keys = array_keys( $categories );
     514   
     515    foreach( $keys as $k ) {
     516        if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
     517            $checked_categories[] = $categories[$k];
     518            unset( $categories[$k] );
     519        }   
    518520    }
    519521
Note: See TracChangeset for help on using the changeset viewer.