WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/06/2008 08:31:54 PM (13 years ago)
Author:
markjaquith
Message:

Cast to array when using foreach(). Props santosj (and thanks for your perseverance!). fixes #2784

File:
1 edited

Legend:

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

    r8498 r8572  
    435435        if ( $arcresults ) {
    436436            $afterafter = $after;
    437             foreach ( $arcresults as $arcresult ) {
     437            foreach ( (array) $arcresults as $arcresult ) {
    438438                $url    = get_month_link($arcresult->year,  $arcresult->month);
    439439                $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
     
    456456        if ($arcresults) {
    457457            $afterafter = $after;
    458             foreach ($arcresults as $arcresult) {
     458            foreach ( (array) $arcresults as $arcresult) {
    459459                $url = get_year_link($arcresult->year);
    460460                $text = sprintf('%d', $arcresult->year);
     
    477477        if ( $arcresults ) {
    478478            $afterafter = $after;
    479             foreach ( $arcresults as $arcresult ) {
     479            foreach ( (array) $arcresults as $arcresult ) {
    480480                $url    = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    481481                $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
     
    501501        $afterafter = $after;
    502502        if ( $arcresults ) {
    503                 foreach ( $arcresults as $arcresult ) {
     503                foreach ( (array) $arcresults as $arcresult ) {
    504504                    if ( $arcresult->week != $arc_w_last ) {
    505505                        $arc_year = $arcresult->yr;
     
    529529        }
    530530        if ( $arcresults ) {
    531             foreach ( $arcresults as $arcresult ) {
     531            foreach ( (array) $arcresults as $arcresult ) {
    532532                if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
    533533                    $url  = get_permalink($arcresult);
     
    669669        AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    670670    if ( $dayswithposts ) {
    671         foreach ( $dayswithposts as $daywith ) {
     671        foreach ( (array) $dayswithposts as $daywith ) {
    672672            $daywithpost[] = $daywith[0];
    673673        }
     
    690690    );
    691691    if ( $ak_post_titles ) {
    692         foreach ( $ak_post_titles as $ak_post_title ) {
     692        foreach ( (array) $ak_post_titles as $ak_post_title ) {
    693693
    694694                $post_title = apply_filters( "the_title", $ak_post_title->post_title );
     
    757757    global $allowedtags;
    758758    $allowed = '';
    759     foreach ( $allowedtags as $tag => $attributes ) {
     759    foreach ( (array) $allowedtags as $tag => $attributes ) {
    760760        $allowed .= '<'.$tag;
    761761        if ( 0 < count($attributes) ) {
     
    10671067
    10681068    // Who knows what else people pass in $args
    1069     $total    = (int) $total;
     1069    $total  = (int) $total;
    10701070    if ( $total < 2 )
    10711071        return;
Note: See TracChangeset for help on using the changeset viewer.