Make WordPress Core


Ignore:
Timestamp:
12/20/2014 10:46:53 PM (10 years ago)
Author:
wonderboymusic
Message:

For clarity, initialize some arrays that previously were only assigned via short circuit in loops.

See #30799.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r30735 r30982  
    353353        return $kids;
    354354    } elseif ( $output == ARRAY_A ) {
    355         foreach ( (array) $kids as $kid )
     355        $weeuns = array();
     356        foreach ( (array) $kids as $kid ) {
    356357            $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
     358        }
    357359        return $weeuns;
    358360    } elseif ( $output == ARRAY_N ) {
    359         foreach ( (array) $kids as $kid )
     361        $babes = array();
     362        foreach ( (array) $kids as $kid ) {
    360363            $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
     364        }
    361365        return $babes;
    362366    } else {
     
    16821686        $object->labels['all_items'] = $object->labels['menu_name'];
    16831687
    1684     foreach ( $nohier_vs_hier_defaults as $key => $value )
    1685             $defaults[$key] = $object->hierarchical ? $value[1] : $value[0];
    1686 
     1688    $defaults = array();
     1689    foreach ( $nohier_vs_hier_defaults as $key => $value ) {
     1690        $defaults[$key] = $object->hierarchical ? $value[1] : $value[0];
     1691    }
    16871692    $labels = array_merge( $defaults, $object->labels );
    16881693    return (object)$labels;
     
    25112516    if ( is_string($post_mime_types) )
    25122517        $post_mime_types = array_map('trim', explode(',', $post_mime_types));
     2518
     2519    $wheres = array();
     2520
    25132521    foreach ( (array) $post_mime_types as $mime_type ) {
    25142522        $mime_type = preg_replace('/\s/', '', $mime_type);
     
    51415149        }
    51425150
     5151        $types = array();
    51435152        // Icon basename - extension = MIME wildcard.
    51445153        foreach ( $icon_files as $file => $uri )
     
    55145523            $ptypes = $post_type;
    55155524        } elseif ( 'any' == $post_type ) {
     5525            $ptypes = array();
    55165526            // Just use the post_types in the supplied posts.
    5517             foreach ( $posts as $post )
     5527            foreach ( $posts as $post ) {
    55185528                $ptypes[] = $post->post_type;
     5529            }
    55195530            $ptypes = array_unique($ptypes);
    55205531        } else {
Note: See TracChangeset for help on using the changeset viewer.