Make WordPress Core

Ticket #2784: cast_to_array.diff

File cast_to_array.diff, 153.1 KB (added by markjaquith, 20 years ago)
  • wp-rss.php

     
    2121        <language><?php echo get_option('rss_language'); ?></language>
    2222        <?php do_action('rss_head'); ?>
    2323
    24 <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
     24<?php $items_count = 0; if ($posts) { foreach ( (array) $posts as $post) { start_wp(); ?>
    2525        <item>
    2626                <title><?php the_title_rss() ?></title>
    2727<?php if (get_settings('rss_use_excerpt')) { ?>
  • wp-includes/class-snoopy.php

     
    812812                        reset($this->cookies);
    813813                        if ( count($this->cookies) > 0 ) {
    814814                                $cookie_headers .= 'Cookie: ';
    815                                 foreach ( $this->cookies as $cookieKey => $cookieVal ) {
     815                                foreach ( (array) $this->cookies as $cookieKey => $cookieVal ) {
    816816                                $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
    817817                                }
    818818                                $headers .= substr($cookie_headers,0,-2) . "\r\n";
     
    976976                        reset($this->cookies);
    977977                        if ( count($this->cookies) > 0 ) {
    978978                                $cookie_str = 'Cookie: ';
    979                                 foreach ( $this->cookies as $cookieKey => $cookieVal ) {
     979                                foreach ( (array) $this->cookies as $cookieKey => $cookieVal ) {
    980980                                $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
    981981                                }
    982982                                $headers[] = substr($cookie_str,0,-2);
  • wp-includes/template-functions-general.php

     
    329329                $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
    330330                if ( $arcresults ) {
    331331                        $afterafter = $after;
    332                         foreach ( $arcresults as $arcresult ) {
     332                        foreach ( (array) $arcresults as $arcresult ) {
    333333                                $url    = get_month_link($arcresult->year,      $arcresult->month);
    334334                                if ( $show_post_count ) {
    335335                                        $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year);
     
    343343        } elseif ( 'daily' == $type ) {
    344344                $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    345345                if ( $arcresults ) {
    346                         foreach ( $arcresults as $arcresult ) {
     346                        foreach ( (array) $arcresults as $arcresult ) {
    347347                                $url    = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    348348                                $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    349349                                $text = mysql2date($archive_day_date_format, $date);
     
    355355                $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    356356                $arc_w_last = '';
    357357                if ( $arcresults ) {
    358                                 foreach ( $arcresults as $arcresult ) {
     358                                foreach ( (array) $arcresults as $arcresult ) {
    359359                                        if ( $arcresult->week != $arc_w_last ) {
    360360                                                $arc_year = $arcresult->yr;
    361361                                                $arc_w_last = $arcresult->week;
     
    372372                ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC ";
    373373                $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY $orderby $limit");
    374374                if ( $arcresults ) {
    375                         foreach ( $arcresults as $arcresult ) {
     375                        foreach ( (array) $arcresults as $arcresult ) {
    376376                                if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
    377377                                        $url  = get_permalink($arcresult);
    378378                                        $arc_title = $arcresult->post_title;
     
    462462                $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
    463463        }
    464464
    465         foreach ( $myweek as $wd ) {
     465        foreach ( (array) $myweek as $wd ) {
    466466                $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
    467467                echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
    468468        }
     
    506506                AND post_type = 'post' AND post_status = 'publish'
    507507                AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    508508        if ( $dayswithposts ) {
    509                 foreach ( $dayswithposts as $daywith ) {
     509                foreach ( (array) $dayswithposts as $daywith ) {
    510510                        $daywithpost[] = $daywith[0];
    511511                }
    512512        } else {
     
    529529                ."AND post_type = 'post' AND post_status = 'publish'"
    530530        );
    531531        if ( $ak_post_titles ) {
    532                 foreach ( $ak_post_titles as $ak_post_title ) {
     532                foreach ( (array) $ak_post_titles as $ak_post_title ) {
    533533                                if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
    534534                                        $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
    535535                                if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
     
    577577function allowed_tags() {
    578578        global $allowedtags;
    579579        $allowed = '';
    580         foreach ( $allowedtags as $tag => $attributes ) {
     580        foreach ( (array) $allowedtags as $tag => $attributes ) {
    581581                $allowed .= '<'.$tag;
    582582                if ( 0 < count($attributes) ) {
    583                         foreach ( $attributes as $attribute => $limits ) {
     583                        foreach ( (array) $attributes as $attribute => $limits ) {
    584584                                $allowed .= ' '.$attribute.'=""';
    585585                        }
    586586                }
  • wp-includes/template-functions-category.php

     
    5959        $thelist = '';
    6060        if ( '' == $separator ) {
    6161                $thelist .= '<ul class="post-categories">';
    62                 foreach ( $categories as $category ) {
     62                foreach ( (array) $categories as $category ) {
    6363                        $thelist .= "\n\t<li>";
    6464                        switch ( strtolower($parents) ) {
    6565                                case 'multiple':
     
    8181                $thelist .= '</ul>';
    8282        } else {
    8383                $i = 0;
    84                 foreach ( $categories as $category ) {
     84                foreach ( (array) $categories as $category ) {
    8585                        if ( 0 < $i )
    8686                                $thelist .= $separator . ' ';
    8787                        switch ( strtolower($parents) ) {
     
    140140                return '';
    141141
    142142        $cat_ids = get_all_category_ids();
    143         foreach ( $cat_ids as $cat_id ) {
     143        foreach ( (array) $cat_ids as $cat_id ) {
    144144                if ( $cat_id == $id)
    145145                        continue;
    146146
     
    266266                return array();
    267267
    268268        $category_list = array();
    269         foreach ( $categories as $category ) {
     269        foreach ( (array) $categories as $category ) {
    270270                if ( $category->category_parent == $category_id ) {
    271271                        $category_list[] = $category;
    272272                        if ( $children = _get_cat_children($category->cat_ID, $categories) )
     
    298298                $exclude = ''; 
    299299                $incategories = preg_split('/[\s,]+/',$include);
    300300                if ( count($incategories) ) {
    301                         foreach ( $incategories as $incat ) {
     301                        foreach ( (array) $incategories as $incat ) {
    302302                                if (empty($inclusions))
    303303                                        $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';
    304304                                else
     
    314314        if ( !empty($exclude) ) {
    315315                $excategories = preg_split('/[\s,]+/',$exclude);
    316316                if ( count($excategories) ) {
    317                         foreach ( $excategories as $excat ) {
     317                        foreach ( (array) $excategories as $excat ) {
    318318                                if (empty($exclusions))
    319319                                        $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';
    320320                                else
     
    346346                $stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
    347347                                                        WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id");
    348348                global $cat_stamps;
    349                 foreach ($stamps as $stamp)
     349                foreach ( (array) $stamps as $stamp)
    350350                        $cat_stamps[$stamp->category_id] = $stamp->ts;
    351351                function stamp_cat($cat) {
    352352                        global $cat_stamps;
  • wp-includes/locale.php

     
    3232                $this->weekday_initial[__('Friday')]    = __('F_Friday_initial');
    3333                $this->weekday_initial[__('Saturday')]  = __('S_Saturday_initial');
    3434
    35                 foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
     35                foreach ( (array) $this->weekday_initial as $weekday_ => $weekday_initial_) {
    3636                        $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
    3737                }
    3838
     
    7474                $this->month_abbrev[__('November')] = __('Nov_November_abbreviation');
    7575                $this->month_abbrev[__('December')] = __('Dec_December_abbreviation');
    7676
    77                 foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
     77                foreach ( (array) $this->month_abbrev as $month_ => $month_abbrev_) {
    7878                        $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
    7979                }
    8080
  • wp-includes/cache.php

     
    188188                if ('category' == $group) {
    189189                        $this->cache['category'] = array ();
    190190                        if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) {
    191                                 foreach ($dogs as $catt)
     191                                foreach ( (array) $dogs as $catt)
    192192                                        $this->cache['category'][$catt->cat_ID] = $catt;
    193193                        }
    194194                } else
     
    202202                                if ( ! $options )
    203203                                        return;
    204204
    205                                 foreach ($options as $option) {
     205                                foreach ( (array) $options as $option) {
    206206                                        $this->cache['options'][$option->option_name] = $option->option_value;
    207207                                }
    208208                        }
     
    258258                }
    259259
    260260                $stack = array_reverse($stack);  // Last added dirs are deepest
    261                 foreach($stack as $dir) {
     261                foreach( (array) $stack as $dir) {
    262262                        if ( $dir != $top_dir)
    263263                                @ rmdir($dir);
    264264                }
     
    326326
    327327                // Loop over dirty objects and save them.
    328328                $errors = 0;
    329                 foreach ($this->dirty_objects as $group => $ids) {
     329                foreach ( (array) $this->dirty_objects as $group => $ids) {
    330330                        $group_dir = $this->make_group_dir($group, $dir_perms);
    331331
    332332                        $ids = array_unique($ids);
    333                         foreach ($ids as $id) {
     333                        foreach ( (array) $ids as $id) {
    334334                                $cache_file = $group_dir.$this->hash($id).'.php';
    335335
    336336                                // Remove the cache file if the key is not set.
     
    376376                echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br/>";
    377377                echo "</p>";
    378378
    379                 foreach ($this->cache as $group => $cache) {
     379                foreach ( (array) $this->cache as $group => $cache) {
    380380                        echo "<p>";
    381381                        echo "<strong>Group:</strong> $group<br/>";
    382382                        echo "<strong>Cache:</strong>";
  • wp-includes/template-functions-post.php

     
    207207        if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = '$post_id' ORDER BY post_id, meta_key", ARRAY_A) ) {
    208208                // Change from flat structure to hierarchical:
    209209                $post_meta_cache = array();
    210                 foreach ( $meta_list as $metarow ) {
     210                foreach ( (array) $meta_list as $metarow ) {
    211211                        $mpid = $metarow['post_id'];
    212212                        $mkey = $metarow['meta_key'];
    213213                        $mval = $metarow['meta_value'];
     
    261261
    262262        if ( $keys = get_post_custom_keys() ) {
    263263                echo "<ul class='post-meta'>\n";
    264                 foreach ( $keys as $key ) {
     264                foreach ( (array) $keys as $key ) {
    265265                        $keyt = trim($key);
    266266                        if ( '_' == $keyt{0} )
    267267                                continue;
     
    297297                $pages = &$page_cache;
    298298
    299299        $page_list = array();
    300         foreach ( $pages as $page ) {
     300        foreach ( (array) $pages as $page ) {
    301301                if ( $page->post_parent == $page_id ) {
    302302                        $page_list[] = $page;
    303303                        if ( $children = get_page_children($page->ID, $pages) )
     
    329329                $meta_value = '';
    330330                $incpages = preg_split('/[\s,]+/',$include);
    331331                if ( count($incpages) ) {
    332                         foreach ( $incpages as $incpage ) {
     332                        foreach ( (array) $incpages as $incpage ) {
    333333                                if (empty($inclusions))
    334334                                        $inclusions = ' AND ( ID = ' . intval($incpage) . ' ';
    335335                                else
     
    344344        if ( !empty($exclude) ) {
    345345                $expages = preg_split('/[\s,]+/',$exclude);
    346346                if ( count($expages) ) {
    347                         foreach ( $expages as $expage ) {
     347                        foreach ( (array) $expages as $expage ) {
    348348                                if (empty($exclusions))
    349349                                        $exclusions = ' AND ( ID <> ' . intval($expage) . ' ';
    350350                                else
     
    497497
    498498                $types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime));
    499499                $exts = array('jpg', 'gif', 'png');
    500                 foreach ($types as $type) {
    501                         foreach ($exts as $ext) {
     500                foreach ( (array) $types as $type) {
     501                        foreach ( (array) $exts as $ext) {
    502502                                $src_file = "$icon_dir/$type.$ext";
    503503                                if ( file_exists($src_file) ) {
    504504                                        $src = "$icon_dir_uri/$type.$ext";
  • wp-includes/query.php

     
    709709                        $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
    710710                        $cat_array = preg_split('/[,\s]+/', $q['cat']);
    711711                        $in_cats = $out_cats = '';
    712                         foreach ( $cat_array as $cat ) {
     712                        foreach ( (array) $cat_array as $cat ) {
    713713                                $cat = intval($cat);
    714714                                $in = strstr($cat, '-') ? false : true;
    715715                                $cat = trim($cat, '-');
     
    740740                        $cat_paths = '/' . trim(urldecode($q['category_name']), '/');
    741741                        $q['category_name'] = sanitize_title(basename($cat_paths));
    742742                        $cat_paths = explode('/', $cat_paths);
    743                         foreach($cat_paths as $pathdir)
     743                        foreach( (array) $cat_paths as $pathdir)
    744744                                $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    745745
    746746                        //if we don't match the entire hierarchy fallback on just matching the nicename
  • wp-includes/template-functions-bookmarks.php

     
    9191
    9292        $output = '';
    9393
    94         foreach ($results as $row) {
     94        foreach ( (array) $results as $row) {
    9595                if (!isset($row->recently_updated)) $row->recently_updated = false;
    9696                        $output .= $before;
    9797                if ($show_updated && $row->recently_updated) {
     
    244244
    245245        // Display each category
    246246        if ($cats) {
    247                 foreach ($cats as $cat) {
     247                foreach ( (array) $cats as $cat) {
    248248                        // Handle each category.
    249249
    250250                        // Display the category name
     
    300300        $category_name = '';
    301301                $inclinks = preg_split('/[\s,]+/',$include);
    302302                if ( count($inclinks) ) {
    303                         foreach ( $inclinks as $inclink ) {
     303                        foreach ( (array) $inclinks as $inclink ) {
    304304                                if (empty($inclusions))
    305305                                        $inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
    306306                                else
     
    315315        if ( !empty($exclude) ) {
    316316                $exlinks = preg_split('/[\s,]+/',$exclude);
    317317                if ( count($exlinks) ) {
    318                         foreach ( $exlinks as $exlink ) {
     318                        foreach ( (array) $exlinks as $exlink ) {
    319319                                if (empty($exclusions))
    320320                                        $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
    321321                                else
     
    336336        if ( !empty($category) ) {
    337337                $incategories = preg_split('/[\s,]+/',$category);
    338338                if ( count($incategories) ) {
    339                         foreach ( $incategories as $incat ) {
     339                        foreach ( (array) $incategories as $incat ) {
    340340                                if (empty($category_query))
    341341                                        $category_query = ' AND ( category_id = ' . intval($incat) . ' ';
    342342                                else
  • wp-includes/wp-db.php

     
    253253                } elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
    254254                        if ( $this->last_result ) {
    255255                                $i = 0;
    256                                 foreach( $this->last_result as $row ) {
     256                                foreach( (array) $this->last_result as $row ) {
    257257                                        $new_array[$i] = (array) $row;
    258258                                        if ( $output == ARRAY_N ) {
    259259                                                $new_array[$i] = array_values($new_array[$i]);
     
    276276                if ( $this->col_info ) {
    277277                        if ( $col_offset == -1 ) {
    278278                                $i = 0;
    279                                 foreach($this->col_info as $col ) {
     279                                foreach( (array) $this->col_info as $col ) {
    280280                                        $new_array[$i] = $col->{$info_type};
    281281                                        $i++;
    282282                                }
  • wp-includes/rewrite.php

     
    119119
    120120        // Look for matches.
    121121        $request_match = $request;
    122         foreach ($rewrite as $match => $query) {
     122        foreach ( (array) $rewrite as $match => $query) {
    123123                // If the requesting file is the anchor of the match, prepend it
    124124                // to the path info.
    125125                if ( (! empty($url)) && (strpos($match, $url) === 0) ) {
     
    265265                $rewrite_rules = array();
    266266                $page_structure = $this->get_page_permastruct();
    267267                if( is_array( $attachment_uris ) ) {
    268                         foreach ($attachment_uris as $uri => $pagename) {
     268                        foreach ( (array) $attachment_uris as $uri => $pagename) {
    269269                                $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
    270270                                $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
    271271                        }
    272272                }
    273273                if( is_array( $uris ) ) {
    274                         foreach ($uris as $uri => $pagename) {
     274                        foreach ( (array) $uris as $uri => $pagename) {
    275275                                $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
    276276                                $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
    277277                        }
     
    296296                $this->date_structure = '';
    297297                $date_endian = '';
    298298
    299                 foreach ($endians as $endian) {
     299                foreach ( (array) $endians as $endian) {
    300300                        if (false !== strpos($this->permalink_structure, $endian)) {
    301301                                $date_endian= $endian;
    302302                                break;
     
    311311                $front = $this->front;
    312312                preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
    313313                $tok_index = 1;
    314                 foreach ($tokens[0] as $token) {
     314                foreach ( (array) $tokens[0] as $token) {
    315315                        if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
    316316                                $front = $front . 'date/';
    317317                                break;
     
    470470        function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
    471471                //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
    472472                $feedregex2 = '';
    473                 foreach ($this->feeds as $feed_name) {
     473                foreach ( (array) $this->feeds as $feed_name) {
    474474                        $feedregex2 .= $feed_name . '|';
    475475                }
    476476                $feedregex2 = '(' . trim($feedregex2, '|') .  ')/?$';
     
    485485                //build up an array of endpoint regexes to append => queries to append
    486486                if ($endpoints) {
    487487                        $ep_query_append = array ();
    488                         foreach ($this->endpoints as $endpoint) {
     488                        foreach ( (array) $this->endpoints as $endpoint) {
    489489                                //match everything after the endpoint name, but allow for nothing to appear there
    490490                                $epmatch = $endpoint[1] . '(/(.*))?/?$';
    491491                                //this will be appended on to the rest of the query for each dir
     
    599599                               
    600600                                //do endpoints
    601601                                if ($endpoints) {
    602                                         foreach ($ep_query_append as $regex => $ep) {
     602                                        foreach ( (array) $ep_query_append as $regex => $ep) {
    603603                                                //add the endpoints on if the mask fits
    604604                                                if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
    605605                                                        $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
     
    639639                                        $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
    640640                                       
    641641                                        //do endpoints for attachments
    642                                         if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
     642                                        if ($endpoint) { foreach ( (array) $ep_query_append as $regex => $ep) {
    643643                                                if ($ep[0] & EP_ATTACHMENT) {
    644644                                                        $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
    645645                                                        $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
     
    677677                        } //if($num_toks)
    678678                        //add the rules for this dir to the accumulating $post_rewrite
    679679                        $post_rewrite = array_merge($rewrite, $post_rewrite);
    680                 } //foreach ($dir)
     680                } //foreach ( (array) $dir)
    681681                return $post_rewrite; //the finished rules. phew!
    682682        }
    683683
     
    768768                $rules .= "RewriteBase $home_root\n";
    769769               
    770770                //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
    771                 foreach ($this->non_wp_rules as $match => $query) {
     771                foreach ( (array) $this->non_wp_rules as $match => $query) {
    772772                        // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    773773                        $match = str_replace('.+?', '.+', $match);
    774774
     
    789789                                "RewriteCond %{REQUEST_FILENAME} -d\n" .
    790790                                "RewriteRule ^.*$ - [S=$num_rules]\n";
    791791
    792                         foreach ($rewrite as $match => $query) {
     792                        foreach ( (array) $rewrite as $match => $query) {
    793793                                // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    794794                                $match = str_replace('.+?', '.+', $match);
    795795
  • wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php

     
    3434        function checkWords($wordArray) {
    3535                if ($fh = fopen($this->tmpfile, "w")) {
    3636                        fwrite($fh, "!\n");
    37                         foreach($wordArray as $key => $value)
     37                        foreach( (array) $wordArray as $key => $value)
    3838                                fwrite($fh, "^" . $value . "\n");
    3939
    4040                        fclose($fh);
     
    4747                $returnData = array();
    4848                $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
    4949
    50                 foreach($dataArr as $dstr) {
     50                foreach( (array) $dataArr as $dstr) {
    5151                        $matches = array();
    5252
    5353                        // Skip this line.
     
    7676                $returnData = array();
    7777                $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
    7878
    79                 foreach($dataArr as $dstr) {
     79                foreach( (array) $dataArr as $dstr) {
    8080                        $matches = array();
    8181
    8282                        // Skip this line.
  • wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php

     
    6161        $querystring = '';
    6262        if (is_array($data)) {
    6363            // Change data in to postable data
    64                 foreach ($data as $key => $val) {
     64                foreach ( (array) $data as $key => $val) {
    6565                        if (is_array($val)) {
    66                                 foreach ($val as $val2) {
     66                                foreach ( (array) $val as $val2) {
    6767                                        $querystring .= urlencode($key).'='.urlencode($val2).'&';
    6868                                }
    6969                        } else {
     
    165165            if (!is_array($cookies)) {
    166166                $cookies = array($cookies);
    167167            }
    168             foreach ($cookies as $cookie) {
     168            foreach ( (array) $cookies as $cookie) {
    169169                if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) {
    170170                    $this->cookies[$m[1]] = $m[2];
    171171                }
     
    212212        // Cookies
    213213        if ($this->cookies) {
    214214            $cookie = 'Cookie: ';
    215             foreach ($this->cookies as $key => $value) {
     215            foreach ( (array) $this->cookies as $key => $value) {
    216216                $cookie .= "$key=$value; ";
    217217            }
    218218            $headers[] = $cookie;
  • wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php

     
    3939                }
    4040
    4141                $wordError = array();
    42                 foreach($wordArray as $word) {
     42                foreach( (array) $wordArray as $word) {
    4343                        if(!pspell_check($this->plink, trim($word)))
    4444                                $wordError[] = $word;
    4545                }
  • wp-includes/js/tinymce/tiny_mce_gzip.php

     
    169169
    170170        // Load all plugins and their language packs
    171171        $plugins = explode(",", $plugins);
    172         foreach ($plugins as $plugin) {
     172        foreach ( (array) $plugins as $plugin) {
    173173                $pluginFile = realpath("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js");
    174174                /* WP $languageFile = realpath("plugins/" . $plugin . "/langs/" . $lang . ".js"); WP */
    175175
  • wp-includes/functions-compat.php

     
    9090        $keys     = array_keys($input);
    9191        $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
    9292
    93         foreach ($keys as $key) {
     93        foreach ( (array) $keys as $key) {
    9494            $output[$casefunc($key)] = $input[$key];
    9595        }
    9696
  • wp-includes/capabilities.php

     
    2222
    2323                $this->role_objects = array();
    2424                $this->role_names =  array();
    25                 foreach ($this->roles as $role => $data) {
     25                foreach ( (array) $this->roles as $role => $data) {
    2626                        $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']);
    2727                        $this->role_names[$role] = $this->roles[$role]['name'];
    2828                }
     
    174174
    175175                //Build $allcaps from role caps, overlay user's $caps
    176176                $this->allcaps = array();
    177                 foreach($this->roles as $role) {
     177                foreach( (array) $this->roles as $role) {
    178178                        $role = $wp_roles->get_role($role);
    179179                        $this->allcaps = array_merge($this->allcaps, $role->capabilities);
    180180                }
     
    197197        }
    198198
    199199        function set_role($role) {
    200                 foreach($this->roles as $oldrole)
     200                foreach( (array) $this->roles as $oldrole)
    201201                        unset($this->caps[$oldrole]);
    202202                $this->caps[$role] = true;
    203203                $this->roles = array($role => true);
     
    251251                $caps = call_user_func_array('map_meta_cap', $args);
    252252                // Must have ALL requested caps
    253253                $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
    254                 foreach ($caps as $cap) {
     254                foreach ( (array) $caps as $cap) {
    255255                        //echo "Checking cap $cap<br/>";
    256256                        if(empty($capabilities[$cap]) || !$capabilities[$cap])
    257257                                return false;
  • wp-includes/functions-post.php

     
    528528        $delete_cats = array_diff($old_categories,$post_categories);
    529529
    530530        if ($delete_cats) {
    531                 foreach ($delete_cats as $del) {
     531                foreach ( (array) $delete_cats as $del) {
    532532                        $wpdb->query("
    533533                                DELETE FROM $wpdb->post2cat
    534534                                WHERE category_id = $del
     
    541541        $add_cats = array_diff($post_categories, $old_categories);
    542542
    543543        if ($add_cats) {
    544                 foreach ($add_cats as $new_cat) {
     544                foreach ( (array) $add_cats as $new_cat) {
    545545                        $wpdb->query("
    546546                                INSERT INTO $wpdb->post2cat (post_id, category_id)
    547547                                VALUES ($post_ID, $new_cat)");
     
    550550
    551551        // Update category counts.
    552552        $all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
    553         foreach ( $all_affected_cats as $cat_id ) {
     553        foreach ( (array) $all_affected_cats as $cat_id ) {
    554554                $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
    555555                $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
    556556                wp_cache_delete($cat_id, 'category');
     
    572572        if ( 'publish' == $post->post_status && 'post' == $post->post_type ) {
    573573                $categories = wp_get_post_cats('', $post->ID);
    574574                if( is_array( $categories ) ) {
    575                         foreach ( $categories as $cat_id ) {
     575                        foreach ( (array) $categories as $cat_id ) {
    576576                                $wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'");
    577577                                wp_cache_delete($cat_id, 'category');
    578578                        }
     
    663663                }
    664664
    665665                $trackback_urls = explode(',', $tb_list);
    666                 foreach($trackback_urls as $tb_url) {
     666                foreach( (array) $trackback_urls as $tb_url) {
    667667                    $tb_url = trim($tb_url);
    668668                    trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
    669669                }
     
    676676        do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
    677677
    678678        if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) {
    679                 foreach ($chars[1] as $char) {
     679                foreach ( (array) $chars[1] as $char) {
    680680                        // If it's an encoded char in the normal ASCII set, reject
    681681                        if ( 38 == $char )
    682682                                continue; // Unless it's &
     
    690690                return false; // If moderation keys are empty
    691691        $words = explode("\n", $mod_keys );
    692692
    693         foreach ($words as $word) {
     693        foreach ( (array) $words as $word) {
    694694                $word = trim($word);
    695695
    696696                // Skip empty lines
     
    752752        $post_title = apply_filters('the_title', $post->post_title);
    753753        $post_title = strip_tags($post_title);
    754754
    755         if ($to_ping) : foreach ($to_ping as $tb_ping) :
     755        if ($to_ping) : foreach ( (array) $to_ping as $tb_ping) :
    756756                $tb_ping = trim($tb_ping);
    757757                if ( !in_array($tb_ping, $pinged) ) {
    758758                        trackback($tb_ping, $post_title, $excerpt, $post_id);
     
    779779        if ( !is_array( $custom_fields ) )
    780780                return $pung;
    781781
    782         foreach ( $custom_fields as $key => $val ) {
     782        foreach ( (array) $custom_fields as $key => $val ) {
    783783                if ( 'enclosure' != $key || !is_array( $val ) )
    784784                        continue;
    785                 foreach( $val as $enc ) {
     785                foreach( (array) $val as $enc ) {
    786786                        $enclosure = split( "\n", $enc );
    787787                        $pung[] = trim( $enclosure[ 0 ] );
    788788                }
     
    815815//immediately follow their parents
    816816function get_page_hierarchy($posts, $parent = 0) {
    817817        $result = array ( );
    818         if ($posts) { foreach ($posts as $post) {
     818        if ($posts) { foreach ( (array) $posts as $post) {
    819819                if ($post->post_parent == $parent) {
    820820                        $result[$post->ID] = $post->post_name;
    821821                        $children = get_page_hierarchy($posts, $post->ID);
     
    838838
    839839        if ($posts) {
    840840
    841                 foreach ($posts as $id => $post) {
     841                foreach ( (array) $posts as $id => $post) {
    842842
    843843                        // URI => page name
    844844                        $uri = get_page_uri($id);
    845845                        $attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$id'");
    846846                        if ( $attachments ) {
    847                                 foreach ( $attachments as $attachment ) {
     847                                foreach ( (array) $attachments as $attachment ) {
    848848                                        $attach_uri = get_page_uri($attachment->ID);
    849849                                        $page_attachment_uris[$attach_uri] = $attachment->ID;
    850850                                }
     
    10301030        // Do Trackbacks
    10311031        $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
    10321032        if ( is_array($trackbacks) ) {
    1033                 foreach ( $trackbacks as $trackback ) {
     1033                foreach ( (array) $trackbacks as $trackback ) {
    10341034                        do_trackbacks($trackback->ID);
    10351035                }
    10361036        }
  • wp-includes/classes.php

     
    2020                $cnt = 0;
    2121                $id_list = explode( ',', $id_list );
    2222
    23                 foreach ( $id_list as $comment ) {
     23                foreach ( (array) $id_list as $comment ) {
    2424                        if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) {
    2525                                $cnt++;
    2626                        }
     
    3333        function find_spam() {
    3434                $in_queue = 0;
    3535
    36                 foreach( $this->comment_list as $comment ) {
     36                foreach( (array) $this->comment_list as $comment ) {
    3737                        if( $comment->approved == 1 ) {
    38                                 foreach( $this->spam_words as $word ) {
     38                                foreach( (array) $this->spam_words as $word ) {
    3939                                        $word = trim($word);
    4040                                        if ( empty( $word ) )
    4141                                                continue;
     
    149149
    150150                        // Look for matches.
    151151                        $request_match = $request;
    152                         foreach ($rewrite as $match => $query) {
     152                        foreach ( (array) $rewrite as $match => $query) {
    153153                                // If the requesting file is the anchor of the match, prepend it
    154154                                // to the path info.
    155155                                if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) {
     
    279279                        }
    280280                }
    281281
    282                 foreach ($this->private_query_vars as $wpvar) {
     282                foreach ( (array) $this->private_query_vars as $wpvar) {
    283283                        if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar] && ! isset($this->extra_query_vars[$wpvar]) ) {
    284284                                $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
    285285                                $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]);
     
    292292        function register_globals() {
    293293                global $wp_query;
    294294                // Extract updated query vars back into global namespace.
    295                 foreach ($wp_query->query_vars as $key => $value) {
     295                foreach ( (array) $wp_query->query_vars as $key => $value) {
    296296                        $GLOBALS[$key] = $value;
    297297                }
    298298
     
    373373                // Return all messages if no code specified.
    374374                if ( empty($code) ) {
    375375                        $all_messages = array();
    376                         foreach ( $this->errors as $code => $messages )
     376                        foreach ( (array) $this->errors as $code => $messages )
    377377                                $all_messages = array_merge($all_messages, $messages);
    378378
    379379                        return $all_messages;
     
    431431       
    432432                $flat = ($to_depth == -1) ? true : false;
    433433       
    434                 foreach ( $elements as $element ) {
     434                foreach ( (array) $elements as $element ) {
    435435                        // If flat, start and end the element and skip the level checks.
    436436                        if ( $flat) {
    437437                                // Start the element.
  • wp-includes/template-functions-links.php

     
    264264        $sql_exclude_cats = '';
    265265        if ( !empty($excluded_categories) ) {
    266266                $blah = explode(' and ', $excluded_categories);
    267                 foreach ( $blah as $category ) {
     267                foreach ( (array) $blah as $category ) {
    268268                        $category = intval($category);
    269269                        $sql_cat_ids = " OR pc.category_ID = '$category'";
    270270                }
     
    297297        $sql_exclude_cats = '';
    298298        if ( !empty($excluded_categories) ) {
    299299                $blah = explode(' and ', $excluded_categories);
    300                 foreach ( $blah as $category ) {
     300                foreach ( (array) $blah as $category ) {
    301301                        $category = intval($category);
    302302                        $sql_cat_ids = " OR pc.category_ID = '$category'";
    303303                }
  • wp-includes/deprecated.php

     
    206206    $cat_id = -1;
    207207    $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
    208208    if ($results) {
    209         foreach ($results as $result) {
     209        foreach ( (array) $results as $result) {
    210210            $cat_id = $result->cat_ID;
    211211        }
    212212    }
     
    246246 **
    247247 ** Use this like:
    248248 ** $links = get_linkobjectsbyname('fred');
    249  ** foreach ($links as $link) {
     249 ** foreach ( (array) $links as $link) {
    250250 **   echo '<li>'.$link->link_name.'</li>';
    251251 ** }
    252252 **/
     
    257257    //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
    258258    // TODO: Fix me.
    259259    if ($results) {
    260         foreach ($results as $result) {
     260        foreach ( (array) $results as $result) {
    261261            $cat_id = $result->cat_id;
    262262        }
    263263    }
     
    280280 ** Use this like:
    281281 ** $links = get_linkobjects(1);
    282282 ** if ($links) {
    283  **   foreach ($links as $link) {
     283 **   foreach ( (array) $links as $link) {
    284284 **     echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
    285285 **   }
    286286 ** }
     
    326326
    327327    $results = $wpdb->get_results($sql);
    328328    if ($results) {
    329         foreach ($results as $result) {
     329        foreach ( (array) $results as $result) {
    330330            $result->link_url         = $result->link_url;
    331331            $result->link_name        = $result->link_name;
    332332            $result->link_description = $result->link_description;
  • wp-includes/cron.php

     
    5858        $crons = get_option( 'cron' );
    5959        if ( empty($crons) )
    6060                return false;
    61         foreach ( $crons as $timestamp => $cron )
     61        foreach ( (array) $crons as $timestamp => $cron )
    6262                if ( isset( $cron[$hook] ) )
    6363                        return $timestamp;
    6464        return false;
     
    8585                return;
    8686
    8787        $schedules = wp_get_schedules();
    88         foreach ( $crons as $timestamp => $cronhooks ) {
     88        foreach ( (array) $crons as $timestamp => $cronhooks ) {
    8989                if ( $timestamp > time() ) break;
    90                 foreach ( $cronhooks as $hook => $args ) {
     90                foreach ( (array) $cronhooks as $hook => $args ) {
    9191                        if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
    9292                                continue;
    9393                        spawn_cron();
  • wp-includes/comment.php

     
    1212        if ( !empty($mod_keys) ) {
    1313                $words = explode("\n", $mod_keys );
    1414
    15                 foreach ($words as $word) {
     15                foreach ( (array) $words as $word) {
    1616                        $word = trim($word);
    1717
    1818                        // Skip empty lines
     
    348348        $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    349349
    350350        // Escape data pulled from DB.
    351         foreach ($comment as $key => $value)
     351        foreach ( (array) $comment as $key => $value)
    352352                $comment[$key] = $wpdb->escape($value);
    353353
    354354        // Merge old and new fields with new fields overwriting old ones.
     
    418418        // http://dummy-weblog.org/post.php
    419419        // We don't wanna ping first and second types, even if they have a valid <link/>
    420420
    421         foreach($post_links_temp[0] as $link_test) :
     421        foreach( (array) $post_links_temp[0] as $link_test) :
    422422                if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
    423423                                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
    424424                        $test = parse_url($link_test);
     
    431431
    432432        do_action('pre_ping',  array(&$post_links, &$pung));
    433433
    434         foreach ($post_links as $pagelinkedto){
     434        foreach ( (array) $post_links as $pagelinkedto){
    435435                debug_fwrite($log, "Processing -- $pagelinkedto\n");
    436436                $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
    437437
  • wp-includes/theme.php

     
    120120
    121121        sort($theme_files);
    122122
    123         foreach($theme_files as $theme_file) {
     123        foreach( (array) $theme_files as $theme_file) {
    124124                if ( ! is_readable("$theme_root/$theme_file") ) {
    125125                        $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
    126126                        continue;
     
    213213        // Resolve theme dependencies.
    214214        $theme_names = array_keys($themes);
    215215
    216         foreach ($theme_names as $theme_name) {
     216        foreach ( (array) $theme_names as $theme_name) {
    217217                $themes[$theme_name]['Parent Theme'] = '';
    218218                if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
    219                         foreach ($theme_names as $parent_theme_name) {
     219                        foreach ( (array) $theme_names as $parent_theme_name) {
    220220                                if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
    221221                                        $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
    222222                                        break;
     
    247247        $current_theme = 'WordPress Default';
    248248
    249249        if ( $themes ) {
    250                 foreach ($theme_names as $theme_name) {
     250                foreach ( (array) $theme_names as $theme_name) {
    251251                        if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
    252252                                        $themes[$theme_name]['Template'] == $current_template ) {
    253253                                $current_theme = $themes[$theme_name]['Name'];
  • wp-includes/class-IXR.php

     
    1818        $this->type = $type;
    1919        if ($type == 'struct') {
    2020            /* Turn all the values in the array in to new IXR_Value objects */
    21             foreach ($this->data as $key => $value) {
     21            foreach ( (array) $this->data as $key => $value) {
    2222                $this->data[$key] = new IXR_Value($value);
    2323            }
    2424        }
     
    7878                break;
    7979            case 'array':
    8080                $return = '<array><data>'."\n";
    81                 foreach ($this->data as $item) {
     81                foreach ( (array) $this->data as $item) {
    8282                    $return .= '  <value>'.$item->getXml()."</value>\n";
    8383                }
    8484                $return .= '</data></array>';
     
    8686                break;
    8787            case 'struct':
    8888                $return = '<struct>'."\n";
    89                 foreach ($this->data as $name => $value) {
     89                foreach ( (array) $this->data as $name => $value) {
    9090                                        $name = htmlspecialchars($name);
    9191                    $return .= "  <member><name>$name</name><value>";
    9292                    $return .= $value->getXml()."</value></member>\n";
     
    104104    function isStruct($array) {
    105105        /* Nasty function to check if an array is a struct or not */
    106106        $expected = 0;
    107         foreach ($array as $key => $value) {
     107        foreach ( (array) $array as $key => $value) {
    108108            if ((string)$key != (string)$expected) {
    109109                return true;
    110110            }
     
    397397    function multiCall($methodcalls) {
    398398        // See http://www.xmlrpc.com/discuss/msgReader$1208
    399399        $return = array();
    400         foreach ($methodcalls as $call) {
     400        foreach ( (array) $methodcalls as $call) {
    401401            $method = $call['methodName'];
    402402            $params = $call['params'];
    403403            if ($method == 'system.multicall') {
     
    432432<params>
    433433
    434434EOD;
    435         foreach ($this->args as $arg) {
     435        foreach ( (array) $this->args as $arg) {
    436436            $this->xml .= '<param><value>';
    437437            $v = new IXR_Value($arg);
    438438            $this->xml .= $v->getXml();
     
    754754        // We should be returning an array of types
    755755        $types = $this->signatures[$method];
    756756        $return = array();
    757         foreach ($types as $type) {
     757        foreach ( (array) $types as $type) {
    758758            switch ($type) {
    759759                case 'string':
    760760                    $return[] = 'string';
  • wp-includes/kses.php

     
    154154
    155155        $attr2 = '';
    156156
    157         foreach ($attrarr as $arreach) {
     157        foreach ( (array) $attrarr as $arreach) {
    158158                if (!@ isset ($allowed_html[strtolower($element)][strtolower($arreach['name'])]))
    159159                        continue; # the attribute is not allowed
    160160
     
    169169                else {
    170170                        # there are some checks
    171171                        $ok = true;
    172                         foreach ($current as $currkey => $currval)
     172                        foreach ( (array) $current as $currkey => $currval)
    173173                                if (!wp_kses_check_attr_val($arreach['value'], $arreach['vless'], $currkey, $currval)) {
    174174                                        $ok = false;
    175175                                        break;
     
    404404{
    405405        $outarray = array ();
    406406
    407         foreach ($inarray as $inkey => $inval) {
     407        foreach ( (array) $inarray as $inkey => $inval) {
    408408                $outkey = strtolower($inkey);
    409409                $outarray[$outkey] = array ();
    410410
    411                 foreach ($inval as $inkey2 => $inval2) {
     411                foreach ( (array) $inval as $inkey2 => $inval2) {
    412412                        $outkey2 = strtolower($inkey2);
    413413                        $outarray[$outkey][$outkey2] = $inval2;
    414414                } # foreach $inval
     
    457457        $string2 = strtolower($string2);
    458458
    459459        $allowed = false;
    460         foreach ($allowed_protocols as $one_protocol)
     460        foreach ( (array) $allowed_protocols as $one_protocol)
    461461                if (strtolower($one_protocol) == $string2) {
    462462                        $allowed = true;
    463463                        break;
  • wp-includes/functions.php

     
    254254        }
    255255        $wpdb->show_errors();
    256256
    257         foreach ($options as $option) {
     257        foreach ( (array) $options as $option) {
    258258                // "When trying to design a foolproof system,
    259259                //  never underestimate the ingenuity of the fools :)" -- Dougal
    260260                if ( 'siteurl' == $option->option_name )
     
    383383                $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
    384384AND meta_key = '$key' AND meta_value = '$value'");
    385385                $cache_key = $post_meta_cache['$post_id'][$key];
    386                 if ($cache_key) foreach ( $cache_key as $index => $data )
     386                if ($cache_key) foreach ( (array) $cache_key as $index => $data )
    387387                        if ( $data == $value )
    388388                                unset($post_meta_cache['$post_id'][$key][$index]);
    389389        }
     
    408408
    409409        $values = array();
    410410        if ( $metalist ) {
    411                 foreach ($metalist as $metarow) {
     411                foreach ( (array) $metalist as $metarow) {
    412412                        $values[] = $metarow[0];
    413413                }
    414414        }
     
    447447meta_key = '$key' AND post_id = '$post_id'");
    448448                $cache_key = $post_meta_cache['$post_id'][$key];
    449449                if ( !empty($cache_key) )
    450                         foreach ($cache_key as $index => $data)
     450                        foreach ( (array) $cache_key as $index => $data)
    451451                                $post_meta_cache['$post_id'][$key][$index] = $original_value;
    452452        } else {
    453453                $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
    454454meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
    455455                $cache_key = $post_meta_cache['$post_id'][$key];
    456456                if ( !empty($cache_key) )
    457                         foreach ($cache_key as $index => $data)
     457                        foreach ( (array) $cache_key as $index => $data)
    458458                                if ( $data == $original_prev )
    459459                                        $post_meta_cache['$post_id'][$key][$index] = $original_value;
    460460        }
     
    527527        $children = $wpdb->get_results($query);
    528528
    529529        if ( $children ) {
    530                 foreach ( $children as $key => $child ) {
     530                foreach ( (array) $children as $key => $child ) {
    531531                        $post_cache[$child->ID] =& $children[$key];
    532532                        $kids[$child->ID] =& $children[$key];
    533533                }
     
    538538        if ( $output == OBJECT ) {
    539539                return $kids;
    540540        } elseif ( $output == ARRAY_A ) {
    541                 foreach ( $kids as $kid )
     541                foreach ( (array) $kids as $kid )
    542542                        $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
    543543                return $weeuns;
    544544        } elseif ( $output == ARRAY_N ) {
    545                 foreach ( $kids as $kid )
     545                foreach ( (array) $kids as $kid )
    546546                        $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
    547547                return $babes;
    548548        } else {
     
    558558        $page_paths = '/' . trim($page_path, '/');
    559559        $leaf_path  = sanitize_title(basename($page_paths));
    560560        $page_paths = explode('/', $page_paths);
    561         foreach($page_paths as $pathdir)
     561        foreach( (array) $page_paths as $pathdir)
    562562                $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    563563
    564564        $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'");
     
    566566        if ( empty($pages) )
    567567                return NULL;
    568568
    569         foreach ($pages as $page) {
     569        foreach ( (array) $pages as $page) {
    570570                $path = '/' . $leaf_path;
    571571                $curpage = $page;
    572572                while ($curpage->post_parent != 0) {
     
    634634        $category_paths = '/' . trim($category_path, '/');
    635635        $leaf_path  = sanitize_title(basename($category_paths));
    636636        $category_paths = explode('/', $category_paths);
    637         foreach($category_paths as $pathdir)
     637        foreach( (array) $category_paths as $pathdir)
    638638                $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    639639
    640640        $categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'");
     
    642642        if ( empty($categories) )
    643643                return NULL;
    644644
    645         foreach ($categories as $category) {
     645        foreach ( (array) $categories as $category) {
    646646                $path = '/' . $leaf_path;
    647647                $curcategory = $category;
    648648                while ($curcategory->category_parent != 0) {
     
    763763        $services = trim($services);
    764764        if ( '' != $services ) {
    765765                $services = explode("\n", $services);
    766                 foreach ($services as $service) {
     766                foreach ( (array) $services as $service) {
    767767                        weblog_ping($service);
    768768                }
    769769        }
     
    907907        debug_fwrite($log, 'Post contents:');
    908908        debug_fwrite($log, $content."\n");
    909909
    910         foreach($post_links_temp[0] as $link_test) :
     910        foreach( (array) $post_links_temp[0] as $link_test) :
    911911                if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
    912912                        $test = parse_url($link_test);
    913913                        if ( isset($test['query']) )
     
    917917                endif;
    918918        endforeach;
    919919
    920         foreach ($post_links as $url) :
     920        foreach ( (array) $post_links as $url) :
    921921                if ( $url != '' && !$wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE post_id = '$post_ID' AND meta_key = 'enclosure' AND meta_value LIKE ('$url%')") ) {
    922922                        if ( $headers = wp_get_http_headers( $url) ) {
    923923                                $len = (int) $headers['content-length'];
     
    10441044function merge_filters($tag) {
    10451045        global $wp_filter;
    10461046        if ( isset($wp_filter['all']) ) {
    1047                 foreach ($wp_filter['all'] as $priority => $functions) {
     1047                foreach ( (array) $wp_filter['all'] as $priority => $functions) {
    10481048                        if ( isset($wp_filter[$tag][$priority]) )
    10491049                                $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
    10501050                        else
     
    10671067        if ( !isset($wp_filter[$tag]) ) {
    10681068                return $string;
    10691069        }
    1070         foreach ($wp_filter[$tag] as $priority => $functions) {
     1070        foreach ( (array) $wp_filter[$tag] as $priority => $functions) {
    10711071                if ( !is_null($functions) ) {
    1072                         foreach($functions as $function) {
     1072                        foreach( (array) $functions as $function) {
    10731073
    10741074                                $all_args = array_merge(array($string), $args);
    10751075                                $function_name = $function['function'];
     
    10961096
    10971097        // check that we don't already have the same filter at the same priority
    10981098        if ( isset($wp_filter[$tag]["$priority"]) ) {
    1099                 foreach($wp_filter[$tag]["$priority"] as $filter) {
     1099                foreach( (array) $wp_filter[$tag]["$priority"] as $filter) {
    11001100                        // uncomment if we want to match function AND accepted_args
    11011101                        // if ( $filter == array($function, $accepted_args) ) {
    11021102                        if ( $filter['function'] == $function_to_add ) {
     
    11151115
    11161116        // rebuild the list of filters
    11171117        if ( isset($wp_filter[$tag]["$priority"]) ) {
    1118                 foreach($wp_filter[$tag]["$priority"] as $filter) {
     1118                foreach( (array) $wp_filter[$tag]["$priority"] as $filter) {
    11191119                        if ( $filter['function'] != $function_to_remove ) {
    11201120                                $new_function_list[] = $filter;
    11211121                        }
     
    11401140        if ( !isset($wp_filter[$tag]) ) {
    11411141                return;
    11421142        }
    1143         foreach ($wp_filter[$tag] as $priority => $functions) {
     1143        foreach ( (array) $wp_filter[$tag] as $priority => $functions) {
    11441144                if ( !is_null($functions) ) {
    1145                         foreach($functions as $function) {
     1145                        foreach( (array) $functions as $function) {
    11461146
    11471147                                $function_name = $function['function'];
    11481148                                $accepted_args = $function['accepted_args'];
     
    12131213                $incposts = preg_split('/[\s,]+/',$include);
    12141214                $numberposts = count($incposts);  // only the number of posts included
    12151215                if ( count($incposts) ) {
    1216                         foreach ( $incposts as $incpost ) {
     1216                        foreach ( (array) $incposts as $incpost ) {
    12171217                                if (empty($inclusions))
    12181218                                        $inclusions = ' AND ( ID = ' . intval($incpost) . ' ';
    12191219                                else
     
    12281228        if ( !empty($exclude) ) {
    12291229                $exposts = preg_split('/[\s,]+/',$exclude);
    12301230                if ( count($exposts) ) {
    1231                         foreach ( $exposts as $expost ) {
     1231                        foreach ( (array) $exposts as $expost ) {
    12321232                                if (empty($exclusions))
    12331233                                        $exclusions = ' AND ( ID <> ' . intval($expost) . ' ';
    12341234                                else
     
    13061306        if ( empty($dogs) )
    13071307                return;
    13081308
    1309         foreach ($dogs as $catt)
     1309        foreach ( (array) $dogs as $catt)
    13101310                $category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
    13111311}
    13121312
     
    13321332        if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
    13331333                // Change from flat structure to hierarchical:
    13341334                $post_meta_cache = array();
    1335                 foreach ($meta_list as $metarow) {
     1335                foreach ( (array) $meta_list as $metarow) {
    13361336                        $mpid = $metarow['post_id'];
    13371337                        $mkey = $metarow['meta_key'];
    13381338                        $mval = $metarow['meta_value'];
     
    14111411                $qs[func_get_arg(0)] = func_get_arg(1);
    14121412        }
    14131413
    1414         foreach($qs as $k => $v) {
     1414        foreach( (array) $qs as $k => $v) {
    14151415                if ( $v != '' ) {
    14161416                        if ( $ret != '' )
    14171417                                $ret .= '&';
     
    14291429function add_magic_quotes($array) {
    14301430        global $wpdb;
    14311431
    1432         foreach ($array as $k => $v) {
     1432        foreach ( (array) $array as $k => $v) {
    14331433                if ( is_array($v) ) {
    14341434                        $array[$k] = add_magic_quotes($v);
    14351435                } else {
     
    15111511                        return '';
    15121512        }
    15131513
    1514         foreach ($metas as $index => $meta) {
     1514        foreach ( (array) $metas as $index => $meta) {
    15151515                @ $value = unserialize($meta->meta_value);
    15161516                if ( $value === FALSE )
    15171517                        $value = $meta->meta_value;
  • wp-includes/pluggable-functions.php

     
    7777        $wpdb->show_errors();
    7878
    7979        if ($metavalues) {
    80                 foreach ( $metavalues as $meta ) {
     80                foreach ( (array) $metavalues as $meta ) {
    8181                        @ $value = unserialize($meta->meta_value);
    8282                        if ($value === FALSE)
    8383                                $value = $meta->meta_value;
     
    130130        $wpdb->show_errors();
    131131
    132132        if ($metavalues) {
    133                 foreach ( $metavalues as $meta ) {
     133                foreach ( (array) $metavalues as $meta ) {
    134134                        @ $value = unserialize($meta->meta_value);
    135135                        if ($value === FALSE)
    136136                                $value = $meta->meta_value;
     
    265265if ( !function_exists('check_ajax_referer') ) :
    266266function check_ajax_referer() {
    267267        $cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
    268         foreach ( $cookie as $tasty ) {
     268        foreach ( (array) $cookie as $tasty ) {
    269269                if ( false !== strpos($tasty, USER_COOKIE) )
    270270                        $user = substr(strstr($tasty, '='), 1);
    271271                if ( false !== strpos($tasty, PASS_COOKIE) )
  • wp-includes/script-loader.php

     
    8484                if ( ! $handles = (array) $handles )
    8585                        return array();
    8686                $return = array();
    87                 foreach ( $handles as $handle ) {
     87                foreach ( (array) $handles as $handle ) {
    8888                        $handle = explode('?', $handle);
    8989                        if ( isset($handle[1]) )
    9090                                $this->args[$handle[0]] = $handle[1];
  • wp-includes/feed-functions.php

     
    131131function the_category_rss($type = 'rss') {
    132132    $categories = get_the_category();
    133133    $the_list = '';
    134     foreach ($categories as $category) {
     134    foreach ( (array) $categories as $category) {
    135135        $category->cat_name = convert_chars($category->cat_name);
    136136        if ('rdf' == $type) {
    137137            $the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>";
     
    151151                while( list( $key, $val ) = each( $custom_fields ) ) {
    152152                        if( $key == 'enclosure' ) {
    153153                                if (is_array($val)) {
    154                                         foreach($val as $enc) {
     154                                        foreach( (array) $val as $enc) {
    155155                                                $enclosure = split( "\n", $enc );
    156156                                                print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
    157157                                        }
  • wp-includes/vars.php

     
    9292
    9393
    9494// generates smilies' search & replace arrays
    95 foreach($wpsmiliestrans as $smiley => $img) {
     95foreach( (array) $wpsmiliestrans as $smiley => $img) {
    9696        $wp_smiliessearch[] = $smiley;
    9797        $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
    9898        $wp_smiliesreplace[] = " <img src='" . get_settings('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
  • wp-includes/rss-functions.php

     
    524524        if ( $rss and !$rss->ERROR) {
    525525
    526526                // find Etag, and Last-Modified
    527                 foreach($resp->headers as $h) {
     527                foreach( (array) $resp->headers as $h) {
    528528                        // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
    529529                        if (strpos($h, ": ")) {
    530530                                list($field, $val) = explode(": ", $h, 2);
     
    823823                if ( $rss ) {
    824824                        echo "<ul>";
    825825                        $rss->items = array_slice($rss->items, 0, $num_items);
    826                                 foreach ($rss->items as $item ) {
     826                                foreach ( (array) $rss->items as $item ) {
    827827                                        echo "<li>\n";
    828828                                        echo "<a href='$item[link]' title='$item[description]'>";
    829829                                        echo htmlentities($item['title']);
     
    841841        $rss = fetch_rss($url);
    842842        if ( $rss ) {
    843843                $rss->items = array_slice($rss->items, 0, $num_items);
    844                 foreach ($rss->items as $item ) {
     844                foreach ( (array) $rss->items as $item ) {
    845845                        echo "<li>\n";
    846846                        echo "<a href='$item[link]' title='$item[description]'>";
    847847                        echo htmlentities($item['title']);
  • wp-includes/template-functions-author.php

     
    179179        $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
    180180        $authors = $wpdb->get_results($query);
    181181
    182         foreach ( $authors as $author ) {
     182        foreach ( (array) $authors as $author ) {
    183183                $author = get_userdata( $author->ID );
    184184                $posts = get_usernumposts($author->ID);
    185185                $name = $author->nickname;
  • xmlrpc.php

     
    157157        function escape(&$array) {
    158158                global $wpdb;
    159159
    160                 foreach ($array as $k => $v) {
     160                foreach ( (array) $array as $k => $v) {
    161161                        if (is_array($v)) {
    162162                                $this->escape($array[$k]);
    163163                        } else if (is_object($v)) {
     
    282282            return $this->error;
    283283          }
    284284
    285           foreach ($posts_list as $entry) {
     285          foreach ( (array) $posts_list as $entry) {
    286286         
    287287            $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
    288288            $categories = implode(',', wp_get_post_cats(1, $entry['ID']));
     
    573573          $post_category = array();
    574574
    575575          if (is_array($catnames)) {
    576             foreach ($catnames as $cat) {
     576            foreach ( (array) $catnames as $cat) {
    577577              $post_category[] = get_cat_ID($cat);
    578578            }
    579579          }
     
    625625          $post_category = array();
    626626
    627627          if (is_array($catnames)) {
    628             foreach ($catnames as $cat) {
     628            foreach ( (array) $catnames as $cat) {
    629629              $post_category[] = get_cat_ID($cat);
    630630            }
    631631          }
     
    696696
    697697            $categories = array();
    698698            $catids = wp_get_post_cats('', $post_ID);
    699             foreach($catids as $catid) {
     699            foreach( (array) $catids as $catid) {
    700700              $categories[] = get_cat_name($catid);
    701701            }
    702702
     
    751751            return $this->error;
    752752          }
    753753
    754           foreach ($posts_list as $entry) {
     754          foreach ( (array) $posts_list as $entry) {
    755755         
    756756            $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
    757757            $categories = array();
    758758            $catids = wp_get_post_cats('', $entry['ID']);
    759             foreach($catids as $catid) {
     759            foreach( (array) $catids as $catid) {
    760760              $categories[] = get_cat_name($catid);
    761761            }
    762762
     
    813813
    814814          // FIXME: can we avoid using direct SQL there?
    815815          if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {
    816             foreach ($cats as $cat) {
     816            foreach ( (array) $cats as $cat) {
    817817              $struct['categoryId'] = $cat['cat_ID'];
    818818              $struct['description'] = $cat['cat_name'];
    819819              $struct['categoryName'] = $cat['cat_name'];
     
    891891            return $this->error;
    892892          }
    893893
    894           foreach ($posts_list as $entry) {
     894          foreach ( (array) $posts_list as $entry) {
    895895         
    896896            $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
    897897
     
    932932
    933933          // FIXME: can we avoid using direct SQL there?
    934934          if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
    935             foreach ($cats as $cat) {
     935            foreach ( (array) $cats as $cat) {
    936936              $struct['categoryId'] = $cat['cat_ID'];
    937937              $struct['categoryName'] = $cat['cat_name'];
    938938
     
    961961          $catids = wp_get_post_cats('', intval($post_ID));
    962962          // first listed category will be the primary category
    963963          $isPrimary = true;
    964           foreach($catids as $catid) {
     964          foreach( (array) $catids as $catid) {
    965965            $categories[] = array(
    966966              'categoryName' => get_cat_name($catid),
    967967              'categoryId' => $catid,
     
    992992          if ( !current_user_can('edit_post', $post_ID) )
    993993            return new IXR_Error(401, 'Sorry, you can not edit this post.');
    994994
    995           foreach($categories as $cat) {
     995          foreach( (array) $categories as $cat) {
    996996            $catids[] = $cat['categoryId'];
    997997          }
    998998
     
    10061006        function mt_supportedMethods($args) {
    10071007
    10081008          $supported_methods = array();
    1009           foreach($this->methods as $key=>$value) {
     1009          foreach( (array) $this->methods as $key=>$value) {
    10101010            $supported_methods[] = $key;
    10111011          }
    10121012
     
    10411041          }
    10421042
    10431043          $trackback_pings = array();
    1044           foreach($comments as $comment) {
     1044          foreach( (array) $comments as $comment) {
    10451045            if ( 'trackback' == $comment->comment_type ) {
    10461046              $content = $comment->comment_content;
    10471047              $title = substr($content, 8, (strpos($content, '</strong>') - 8));
     
    12051205                $link = preg_replace( $sem_regexp_pb, $sem_regexp_fix, $pagelinkedfrom );
    12061206
    12071207                $finished = false;
    1208                 foreach ( $p as $para ) {
     1208                foreach ( (array) $p as $para ) {
    12091209                        if ( $finished )
    12101210                                continue;
    12111211                        if ( strstr( $para, $pagelinkedto ) ) {
     
    12741274                }
    12751275
    12761276                $pingbacks = array();
    1277                 foreach($comments as $comment) {
     1277                foreach( (array) $comments as $comment) {
    12781278                        if ( 'pingback' == $comment->comment_type )
    12791279                                $pingbacks[] = $comment->comment_author_url;
    12801280                }
  • wp-mail.php

     
    3030        $bodysignal = 0;
    3131        $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
    3232                                         'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
    33         foreach ($message as $line) :
     33        foreach ( (array) $message as $line) :
    3434                if (strlen($line) < 3) $bodysignal = 1;
    3535
    3636                if ($bodysignal) {
  • wp-content/plugins/wp-db-backup.php

     
    8181                                        <script type="text/javascript"><!--\\
    8282                                ';
    8383                                if($this->backup_errors) {
    84                                         foreach($this->backup_errors as $error) {
     84                                        foreach( (array) $this->backup_errors as $error) {
    8585                                                echo "window.parent.addError('$error');\n";
    8686                                        }
    8787                                }
     
    198198                $core_tables = $_POST['core_tables'];
    199199                $tables = array_merge($core_tables, $also_backup);
    200200                $step_count = 1;
    201                 foreach ($tables as $table) {
     201                foreach ( (array) $tables as $table) {
    202202                        $rec_count = $wpdb->get_var("SELECT count(*) FROM {$table}");
    203203                        $rec_segments = ceil($rec_count / ROWS_PER_SEGMENT);
    204204                        $table_count = 0;
     
    279279                if($this->fp) $this->close($this->fp);
    280280
    281281                if($this->backup_errors) {
    282                         foreach($this->backup_errors as $error) {
     282                        foreach( (array) $this->backup_errors as $error) {
    283283                                echo "window.parent.addError('$error');\n";
    284284                        }
    285285                }
     
    472472
    473473                if(($segment == 'none') || ($segment >= 0)) {
    474474                        $ints = array();
    475                         foreach ($table_structure as $struct) {
     475                        foreach ( (array) $table_structure as $struct) {
    476476                                if ( (0 === strpos($struct->Type, 'tinyint')) ||
    477477                                        (0 === strpos(strtolower($struct->Type), 'smallint')) ||
    478478                                        (0 === strpos(strtolower($struct->Type), 'mediumint')) ||
     
    510510                                $search = array("\x00", "\x0a", "\x0d", "\x1a");
    511511                                $replace = array('\0', '\n', '\r', '\Z');
    512512                                if($table_data) {
    513                                         foreach ($table_data as $row) {
     513                                        foreach ( (array) $table_data as $row) {
    514514                                                $values = array();
    515                                                 foreach ($row as $key => $value) {
     515                                                foreach ( (array) $row as $key => $value) {
    516516                                                        if ($ints[strtolower($key)]) {
    517517                                                                $values[] = $value;
    518518                                                        } else {
     
    588588                else
    589589                        $tables = $core_tables;
    590590
    591                 foreach ($tables as $table) {
     591                foreach ( (array) $tables as $table) {
    592592                        // Increase script execution time-limit to 15 min for every table.
    593593                        if ( !ini_get('safe_mode')) @set_time_limit(15*60);
    594594                        // Create the SQL statements
     
    702702
    703703                if (count($this->backup_errors)) {
    704704                        $feedback .= '<div class="updated error">' . __('The following errors were reported:') . "<pre>";
    705                         foreach($this->backup_errors as $error) {
     705                        foreach( (array) $this->backup_errors as $error) {
    706706                                $feedback .= "{$error}\n";  //Errors are already localized
    707707                        }
    708708                        $feedback .= "</pre></div>";
     
    763763                echo '<form method="post">';
    764764                echo '<table align="center" cellspacing="5" cellpadding="5"><tr><td width="50%" align="left" class="alternate" valign="top">';
    765765                echo __('These core WordPress tables will always be backed up:') . '<br /><ul>';
    766                 foreach ($wp_backup_default_tables as $table) {
     766                foreach ( (array) $wp_backup_default_tables as $table) {
    767767                        echo "<li><input type='hidden' name='core_tables[]' value='$table' />$table</li>";
    768768                }
    769769                echo '</ul></td><td width="50%" align="left" valign="top">';
    770770                if (count($other_tables) > 0) {
    771771                        echo __('You may choose to include any of the following tables:') . ' <br />';
    772                         foreach ($other_tables as $table) {
     772                        foreach ( (array) $other_tables as $table) {
    773773                                echo "<label style=\"display:block;\"><input type='checkbox' name='other_tables[]' value='{$table}' /> {$table}</label>";
    774774                        }
    775775                }
     
    784784                // Check DB dize.
    785785                $table_status = $wpdb->get_results("SHOW TABLE STATUS FROM " . $this->backquote(DB_NAME));
    786786                $core_size = $db_size = 0;
    787                 foreach($table_status as $table) {
     787                foreach( (array) $table_status as $table) {
    788788                        $table_size = $table->Data_length - $table->Data_free;
    789789                        if(in_array($table->Name, $wp_backup_default_tables)) {
    790790                                $core_size += $table_size;
     
    816816                        echo __('Schedule: ');
    817817                        $wp_cron_backup_schedule = get_option('wp_cron_backup_schedule');
    818818                        $schedule = array(0 => __('None'), 1 => __('Daily'));
    819                         foreach ($schedule as $value => $name) {
     819                        foreach ( (array) $schedule as $value => $name) {
    820820                                echo ' <input type="radio" name="cron_schedule"';
    821821                                if ($wp_cron_backup_schedule == $value) {
    822822                                        echo ' checked="checked" ';
     
    836836                        }
    837837                        if (count($other_tables) > 0) {
    838838                                echo '<tr><td colspan="2" align="left">' . __('Tables to include:') . '<br />';
    839                                 foreach ($other_tables as $table) {
     839                                foreach ( (array) $other_tables as $table) {
    840840                                        echo '<input type="checkbox" ';
    841841                                        if (in_array($table, $cron_tables)) {
    842842                                                echo 'checked=checked ';
  • wp-content/themes/classic/comments.php

     
    1111<?php if ( $comments ) : ?>
    1212<ol id="commentlist">
    1313
    14 <?php foreach ($comments as $comment) : ?>
     14<?php foreach ( (array) $comments as $comment) : ?>
    1515        <li id="comment-<?php comment_ID() ?>">
    1616        <?php comment_text() ?>
    1717        <p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
  • wp-content/themes/classic/comments-popup.php

     
    11<?php
    22/* Don't remove these lines. */
    33add_filter('comment_text', 'popuplinks');
    4 foreach ($posts as $post) { start_wp();
     4foreach ( (array) $posts as $post) { start_wp();
    55?>
    66<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    77<html xmlns="http://www.w3.org/1999/xhtml">
     
    4040
    4141<?php if ($comments) { ?>
    4242<ol id="commentlist">
    43 <?php foreach ($comments as $comment) { ?>
     43<?php foreach ( (array) $comments as $comment) { ?>
    4444        <li id="comment-<?php comment_ID() ?>">
    4545        <?php comment_text() ?>
    4646        <p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
  • wp-content/themes/default/footer.php

     
    1414<!-- Gorgeous design by Michael Heilemann - http://binarybonsai.com/kubrick/ -->
    1515<?php /* "Just what do you think you're doing Dave?" */ ?>
    1616
     17<!--
     18<?php print_r($wpdb->queries); ?>
     19-->
    1720                <?php wp_footer(); ?>
    1821</body>
    1922</html>
  • wp-content/themes/default/images/header-img.php

     
    99// Assign and validate the color values
    1010$default = false;
    1111$vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2'));
    12 foreach ( $vars as $var => $subvars ) {
     12foreach ( (array) $vars as $var => $subvars ) {
    1313        if ( isset($_GET[$var]) ) {
    14                 foreach ( $subvars as $index => $subvar ) {
     14                foreach ( (array) $subvars as $index => $subvar ) {
    1515                        $length = strlen($_GET[$var]) / 3;
    1616                        $v = substr($_GET[$var], $index * $length, $length);
    1717                        if ( $length == 1 ) $v = '' . $v . $v;
  • wp-content/themes/default/comments.php

     
    2424
    2525        <ol class="commentlist">
    2626
    27         <?php foreach ($comments as $comment) : ?>
     27        <?php foreach ( (array) $comments as $comment) : ?>
    2828
    2929                <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    3030                        <cite><?php comment_author_link() ?></cite> Says:
  • wp-content/themes/default/comments-popup.php

     
    11<?php
    22/* Don't remove these lines. */
    33add_filter('comment_text', 'popuplinks');
    4 foreach ($posts as $post) { start_wp();
     4foreach ( (array) $posts as $post) { start_wp();
    55?>
    66<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    77<html xmlns="http://www.w3.org/1999/xhtml">
     
    4040
    4141<?php if ($comments) { ?>
    4242<ol id="commentlist">
    43 <?php foreach ($comments as $comment) { ?>
     43<?php foreach ( (array) $comments as $comment) { ?>
    4444        <li id="comment-<?php comment_ID() ?>">
    4545        <?php comment_text() ?>
    4646        <p><cite><?php comment_type('Comment', 'Trackback', 'Pingback'); ?> by <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
  • wp-register.php

     
    104104<div class="error">
    105105        <p>
    106106        <?php
    107         foreach($errors as $error) echo "$error<br />";
     107        foreach( (array) $errors as $error) echo "$error<br />";
    108108        ?>
    109109        </p>
    110110</div>
  • wp-links-opml.php

     
    3636 $prev_cat_id = 0;
    3737 $results = $wpdb->get_results($sql);
    3838 if ($results) {
    39      foreach ($results as $result) {
     39     foreach ( (array) $results as $result) {
    4040         if ($result->link_category != $prev_cat_id) { // new category
    4141             if ($prev_cat_id != 0)  { // not first time
    4242?>
  • wp-rss2.php

     
    2727        <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
    2828        <language><?php echo get_option('rss_language'); ?></language>
    2929        <?php do_action('rss2_head'); ?>
    30         <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
     30        <?php $items_count = 0; if ($posts) { foreach ( (array) $posts as $post) { start_wp(); ?>
    3131        <item>
    3232                <title><?php the_title_rss() ?></title>
    3333                <link><?php permalink_single_rss() ?></link>
  • wp-commentsrss2.php

     
    4545                }
    4646        // this line is WordPress' motor, do not delete it.
    4747                if ($comments) {
    48                         foreach ($comments as $comment) {
     48                        foreach ( (array) $comments as $comment) {
    4949                                $GLOBALS['comment'] =& $comment;
    5050                                // Some plugins may need to know the metadata
    5151                                // associated with this comment's post:
  • wp-atom.php

     
    2323        <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright>
    2424        <generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
    2525        <?php do_action('atom_head'); ?>
    26         <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
     26        <?php $items_count = 0; if ($posts) { foreach ( (array) $posts as $post) { start_wp(); ?>
    2727        <entry>
    2828                <author>
    2929                        <name><?php the_author() ?></name>
  • wp-settings.php

     
    1111        $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
    1212
    1313        $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
    14         foreach ( $input as $k => $v )
     14        foreach ( (array) $input as $k => $v )
    1515                if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) )
    1616                        unset($GLOBALS[$k]);
    1717}
     
    173173if ( get_settings('active_plugins') ) {
    174174        $current_plugins = get_settings('active_plugins');
    175175        if ( is_array($current_plugins) ) {
    176                 foreach ($current_plugins as $plugin) {
     176                foreach ( (array) $current_plugins as $plugin) {
    177177                        if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
    178178                                include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
    179179                }
  • wp-cron.php

     
    99$crons = get_option('cron');
    1010if (!is_array($crons) || array_shift(array_keys($crons)) > time())
    1111        return;
    12 foreach ($crons as $timestamp => $cronhooks) {
     12foreach ( (array) $crons as $timestamp => $cronhooks) {
    1313        if ($timestamp > time()) break;
    14         foreach($cronhooks as $hook => $args) {
     14        foreach( (array) $cronhooks as $hook => $args) {
    1515                do_action($hook, $args['args']);
    1616                $schedule = $args['schedule'];
    1717                if($schedule != false) {
  • wp-admin/menu-header.php

     
    55
    66get_admin_page_parent();
    77
    8 foreach ($menu as $item) {
     8foreach ( (array) $menu as $item) {
    99        $class = '';
    1010
    1111        // 0 = name, 1 = capability, 2 = file
     
    2828?>
    2929<ul id="submenu">
    3030<?php
    31 foreach ($submenu["$parent_file"] as $item) :
     31foreach ( (array) $submenu["$parent_file"] as $item) :
    3232         if ( !current_user_can($item[1]) )
    3333                 continue;
    3434
  • wp-admin/inline-uploading.php

     
    198198var filename = new Array();
    199199var icon = new Array();
    200200";
    201         foreach ( $attachments as $key => $attachment ) {
     201        foreach ( (array) $attachments as $key => $attachment ) {
    202202                $ID = $attachment['ID'];
    203203                $href = get_attachment_link($ID);
    204204                $meta = get_post_meta($ID, '_wp_attachment_metadata', true);
  • wp-admin/update-links.php

     
    3535   
    3636        $returns = explode("\n", $body);
    3737   
    38         foreach ($returns as $return) :
     38        foreach ( (array) $returns as $return) :
    3939                $time = $wpdb->escape( substr($return, 0, 19) );
    4040                $uri = $wpdb->escape( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
    4141                $wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'");
  • wp-admin/users.php

     
    2222
    2323        $userids = $_POST['users'];
    2424        $update = 'promote';
    25         foreach($userids as $id) {
     25        foreach( (array) $userids as $id) {
    2626                // The new role of the current user must also have edit_users caps
    2727                if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {
    2828                        $update = 'err_admin_role';
     
    5151        $userids = $_POST['users'];
    5252
    5353        $update = 'del';
    54         foreach ($userids as $id) {
     54        foreach ( (array) $userids as $id) {
    5555                if($id == $current_user->id) {
    5656                        $update = 'err_admin_del';
    5757                        continue;
     
    9393<ul>
    9494<?php
    9595        $go_delete = false;
    96         foreach ($userids as $id) {
     96        foreach ( (array) $userids as $id) {
    9797                $user = new WP_User($id);
    9898                if ($id == $current_user->id) {
    9999                        echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
     
    104104        }
    105105        $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
    106106        $user_dropdown = '<select name="reassign_user">';
    107         foreach ($all_logins as $login) {
     107        foreach ( (array) $all_logins as $login) {
    108108                if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) ) {
    109109                        $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
    110110                }
     
    149149
    150150        $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;");
    151151
    152         foreach($userids as $userid) {
     152        foreach( (array) $userids as $userid) {
    153153                $tmp_user = new WP_User($userid);
    154154                $roles = $tmp_user->roles;
    155155                $role = array_shift($roles);
     
    194194        <div class="error">
    195195                <ul>
    196196                <?php
    197                         foreach ( $errors->get_error_messages() as $message )
     197                        foreach ( (array) $errors->get_error_messages() as $message )
    198198                                 echo "<li>$message</li>";
    199199                ?>
    200200                </ul>
     
    209209        <h2><?php _e('User List by Role'); ?></h2>
    210210<table class="widefat">
    211211<?php
    212 foreach($roleclasses as $role => $roleclass) {
     212foreach( (array) $roleclasses as $role => $roleclass) {
    213213        ksort($roleclass);
    214214?>
    215215
     
    229229</thead>
    230230<tbody id="role-<?php echo $role; ?>"><?php
    231231$style = '';
    232 foreach ($roleclass as $user_object) {
     232foreach ( (array) $roleclass as $user_object) {
    233233        $style = (' class="alternate"' == $style) ? '' : ' class="alternate"';
    234234        echo "\n\t" . user_row( $user_object, $style );
    235235}
  • wp-admin/edit-comments.php

     
    5454        check_admin_referer('bulk-comments');
    5555
    5656        $i = 0;
    57         foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
     57        foreach ( (array) $_POST['delete_comments'] as $comment) : // Check the permissions on each
    5858                $comment = (int) $comment;
    5959                $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
    6060                // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
     
    101101
    102102                echo "<ol id='the-list' class='commentlist' $start>";
    103103                $i = 0;
    104                 foreach ($comments as $comment) {
     104                foreach ( (array) $comments as $comment) {
    105105                ++$i; $class = '';
    106106                $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
    107107                        $comment_status = wp_get_comment_status($comment->comment_ID);
     
    133133 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p>
    134134                </li>
    135135
    136 <?php } // end foreach($comment) ?>
     136<?php } // end foreach( (array) $comment) ?>
    137137</ol>
    138138
    139139<div id="ajax-response"></div>
     
    163163        <th scope="col" colspan="3">' .  __('Actions') . '</th>
    164164  </tr>
    165165</thead>';
    166                 foreach ($comments as $comment) {
     166                foreach ( (array) $comments as $comment) {
    167167                $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
    168168                $comment_status = wp_get_comment_status($comment->comment_ID);
    169169                $class = ('alternate' == $class) ? '' : 'alternate';
  • wp-admin/admin-ajax.php

     
    121121                die('-1');
    122122        $names = explode(',', $_POST['newcat']);
    123123        $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>";
    124         foreach ( $names as $cat_name ) {
     124        foreach ( (array) $names as $cat_name ) {
    125125                $cat_name = trim($cat_name);
    126126                if ( !$category_nicename = sanitize_title($cat_name) )
    127127                        die('0');
     
    215215        require_once( ABSPATH . WPINC . '/registration-functions.php');
    216216        $user_id = add_user();
    217217        if ( is_wp_error( $user_id ) ) {
    218                 foreach( $user_id->get_error_messages() as $message )
     218                foreach( (array) $user_id->get_error_messages() as $message )
    219219                        echo "$message<br />";
    220220        exit;
    221221        } elseif ( !$user_id ) {
  • wp-admin/profile-update.php

     
    1212$errors = edit_user($user_ID);
    1313
    1414if ( is_wp_error( $errors ) ) {
    15         foreach( $errors->get_error_messages() as $message )
     15        foreach( (array) $errors->get_error_messages() as $message )
    1616                echo "$message<br />";
    1717        exit;
    1818}
  • wp-admin/install-helper.php

     
    1010 */
    1111function maybe_create_table($table_name, $create_ddl) {
    1212    global $wpdb;
    13     foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
     13    foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) {
    1414        if ($table == $table_name) {
    1515            return true;
    1616        }
     
    1818    //didn't find it try to create it.
    1919    $q = $wpdb->query($create_ddl);
    2020    // we cannot directly tell that whether this succeeded!
    21     foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
     21    foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) {
    2222        if ($table == $table_name) {
    2323            return true;
    2424        }
     
    3434 */
    3535function maybe_add_column($table_name, $column_name, $create_ddl) {
    3636    global $wpdb, $debug;
    37     foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
     37    foreach ( (array) $wpdb->get_col("DESC $table_name",0) as $column ) {
    3838        if ($debug) echo("checking $column == $column_name<br />");
    3939        if ($column == $column_name) {
    4040            return true;
     
    4343    //didn't find it try to create it.
    4444    $q = $wpdb->query($create_ddl);
    4545    // we cannot directly tell that whether this succeeded!
    46     foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
     46    foreach ( (array) $wpdb->get_col("DESC $table_name",0) as $column ) {
    4747        if ($column == $column_name) {
    4848            return true;
    4949        }
     
    6060 */
    6161function maybe_drop_column($table_name, $column_name, $drop_ddl) {
    6262    global $wpdb;
    63     foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
     63    foreach ( (array) $wpdb->get_col("DESC $table_name",0) as $column ) {
    6464        if ($column == $column_name) {
    6565            //found it try to drop it.
    6666            $q = $wpdb->query($drop_ddl);
    6767            // we cannot directly tell that whether this succeeded!
    68             foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
     68            foreach ( (array) $wpdb->get_col("DESC $table_name",0) as $column ) {
    6969                if ($column == $column_name) {
    7070                    return false;
    7171                }
     
    9696    $diffs = 0;
    9797    $results = $wpdb->get_results("DESC $table_name");
    9898   
    99     foreach ($results as $row ) {
     99    foreach ( (array) $results as $row ) {
    100100        if ($debug > 1) print_r($row);
    101101        if ($row->Field == $col_name) {
    102102            // got our column, check the params
  • wp-admin/theme-editor.php

     
    9393                <?php _e('Select theme to edit:') ?>
    9494                <select name="theme" id="theme">
    9595        <?php
    96                 foreach ($themes as $a_theme) {
     96                foreach ( (array) $themes as $a_theme) {
    9797                $theme_name = $a_theme['Name'];
    9898                if ($theme_name == $theme) $selected = " selected='selected'";
    9999                else $selected = '';
     
    121121if ($allowed_files) :
    122122?>
    123123  <ul>
    124 <?php foreach($allowed_files as $allowed_file) : ?>
     124<?php foreach( (array) $allowed_files as $allowed_file) : ?>
    125125                 <li><a href="theme-editor.php?file=<?php echo "$allowed_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo get_file_description($allowed_file); ?></a></li>
    126126<?php endforeach; ?>
    127127  </ul>
  • wp-admin/upgrade-functions.php

     
    187187        // Get the title and ID of every post, post_name to check if it already has a value
    188188        $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
    189189        if ($posts) {
    190                 foreach($posts as $post) {
     190                foreach( (array) $posts as $post) {
    191191                        if ('' == $post->post_name) {
    192192                                $newtitle = sanitize_title($post->post_title);
    193193                                $wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
     
    196196        }
    197197
    198198        $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
    199         foreach ($categories as $category) {
     199        foreach ( (array) $categories as $category) {
    200200                if ('' == $category->category_nicename) {
    201201                        $newtitle = sanitize_title($category->cat_name);
    202202                        $wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
     
    210210
    211211        $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
    212212        if ($done_ids) :
    213                 foreach ($done_ids as $done_id) :
     213                foreach ( (array) $done_ids as $done_id) :
    214214                        $done_posts[] = $done_id->post_id;
    215215                endforeach;
    216216                $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
     
    220220
    221221        $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
    222222        if ($allposts) :
    223                 foreach ($allposts as $post) {
     223                foreach ( (array) $allposts as $post) {
    224224                        // Check to see if it's already been imported
    225225                        $cat = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
    226226                        if (!$cat && 0 != $post->post_category) { // If there's no result
     
    254254
    255255    // Set user_nicename.
    256256        $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
    257         foreach ($users as $user) {
     257        foreach ( (array) $users as $user) {
    258258                if ('' == $user->user_nicename) {
    259259                        $newname = sanitize_title($user->user_nickname);
    260260                        $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
     
    262262        }
    263263
    264264        $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
    265         foreach ($users as $row) {
     265        foreach ( (array) $users as $row) {
    266266                if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
    267267                           $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
    268268                }
     
    311311    // Remove extraneous backslashes.
    312312        $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
    313313        if ($posts) {
    314                 foreach($posts as $post) {
     314                foreach( (array) $posts as $post) {
    315315            $post_content = addslashes(deslash($post->post_content));
    316316            $post_title = addslashes(deslash($post->post_title));
    317317            $post_excerpt = addslashes(deslash($post->post_excerpt));
     
    327327    // Remove extraneous backslashes.
    328328        $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
    329329        if ($comments) {
    330                 foreach($comments as $comment) {
     330                foreach( (array) $comments as $comment) {
    331331            $comment_content = addslashes(deslash($comment->comment_content));
    332332            $comment_author = addslashes(deslash($comment->comment_author));
    333333            $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
     
    337337    // Remove extraneous backslashes.
    338338        $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
    339339        if ($links) {
    340                 foreach($links as $link) {
     340                foreach( (array) $links as $link) {
    341341            $link_name = addslashes(deslash($link->link_name));
    342342            $link_description = addslashes(deslash($link->link_description));
    343343            $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
     
    370370
    371371        // Some versions have multiple duplicate option_name rows with the same values
    372372        $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
    373         foreach ( $options as $option ) {
     373        foreach ( (array) $options as $option ) {
    374374                if ( 1 != $option->dupes ) { // Could this be done in the query?
    375375                        $limit = $option->dupes - 1;
    376376                        $dupe_ids = $wpdb->get_col("SELECT option_id FROM $wpdb->options WHERE option_name = '$option->option_name' LIMIT $limit");
     
    388388        populate_roles_160();
    389389
    390390        $users = $wpdb->get_results("SELECT * FROM $wpdb->users");
    391         foreach ( $users as $user ) :
     391        foreach ( (array) $users as $user ) :
    392392                if ( !empty( $user->user_firstname ) )
    393393                        update_usermeta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
    394394                if ( !empty( $user->user_lastname ) )
     
    432432        endforeach;
    433433        $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
    434434        $wpdb->hide_errors();
    435         foreach ( $old_user_fields as $old )
     435        foreach ( (array) $old_user_fields as $old )
    436436                $wpdb->query("ALTER TABLE $wpdb->users DROP $old");
    437437        $wpdb->show_errors();
    438438
    439439        if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts
    440440                $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
    441                 foreach ( $categories as $cat_id ) {
     441                foreach ( (array) $categories as $cat_id ) {
    442442                        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'");
    443443                        $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
    444444                }
     
    447447        // populate comment_count field of posts table
    448448        $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
    449449        if( is_array( $comments ) ) {
    450                 foreach ($comments as $comment) {
     450                foreach ( (array) $comments as $comment) {
    451451                        $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );
    452452                }
    453453        }
     
    456456        // the mime type in post_type instead of post_mime_type.
    457457        if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
    458458                $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
    459                 foreach ($objects as $object) {
     459                foreach ( (array) $objects as $object) {
    460460                        $wpdb->query("UPDATE $wpdb->posts SET post_status = 'attachment',
    461461                        post_mime_type = '$object->post_type',
    462462                        post_type = ''
     
    476476                // Update status and type.
    477477                $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
    478478
    479                 if ( ! empty($posts) ) foreach ($posts as $post) {
     479                if ( ! empty($posts) ) foreach ( (array) $posts as $post) {
    480480                        $status = $post->post_status;
    481481                        $type = 'post';
    482482
     
    503503               
    504504                $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
    505505                if ( !empty($posts) )
    506                         foreach ( $posts as $post )
     506                        foreach ( (array) $posts as $post )
    507507                                wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', $post->ID);
    508508        }
    509509        if ( $wp_current_db_version < 3570 ) {
    510510                // Create categories for link categories if a category with the same
    511511                // name doesn't exist.  Create a map of link cat IDs to cat IDs.
    512512                $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories"); 
    513                 foreach ( $link_cats as $link_cat) {
     513                foreach ( (array) $link_cats as $link_cat) {
    514514                        if ( $cat_id = category_exists($link_cat->cat_name) ) {
    515515                                $link_cat_id_map[$link_cat->cat_id] = $cat_id;
    516516                                $default_link_cat = $cat_id;
     
    522522
    523523                // Associate links to cats.
    524524                $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
    525                 if ( !empty($links) ) foreach ( $links as $link ) {
     525                if ( !empty($links) ) foreach ( (array) $links as $link ) {
    526526                        $link_cat = $link_cat_id_map[$link->link_category];
    527527                        $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
    528528                        if (!$cat && 0 != $link->link_category) {
     
    537537                // Count links per category.
    538538                if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) {
    539539                        $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
    540                         foreach ( $categories as $cat_id ) {
     540                        foreach ( (array) $categories as $cat_id ) {
    541541                                $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
    542542                                $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
    543543                        }
     
    550550// General
    551551function maybe_create_table($table_name, $create_ddl) {
    552552    global $wpdb;
    553     foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
     553    foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) {
    554554        if ($table == $table_name) {
    555555            return true;
    556556        }
     
    558558    //didn't find it try to create it.
    559559    $q = $wpdb->query($create_ddl);
    560560    // we cannot directly tell that whether this succeeded!
    561     foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
     561    foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) {
    562562        if ($table == $table_name) {
    563563            return true;
    564564        }
     
    593593 */
    594594function maybe_add_column($table_name, $column_name, $create_ddl) {
    595595    global $wpdb, $debug;
    596     foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
     596    foreach ( (array) $wpdb->get_col("DESC $table_name", 0) as $column ) {
    597597        if ($debug) echo("checking $column == $column_name<br />");
    598598        if ($column == $column_name) {
    599599            return true;
     
    602602    //didn't find it try to create it.
    603603    $q = $wpdb->query($create_ddl);
    604604    // we cannot directly tell that whether this succeeded!
    605     foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
     605    foreach ( (array) $wpdb->get_col("DESC $table_name", 0) as $column ) {
    606606        if ($column == $column_name) {
    607607            return true;
    608608        }
     
    615615function get_alloptions_110() {
    616616        global $wpdb;
    617617        if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
    618                 foreach ($options as $option) {
     618                foreach ( (array) $options as $option) {
    619619                        // "When trying to design a foolproof system,
    620620                        //  never underestimate the ingenuity of the fools :)" -- Dougal
    621621                        if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
     
    677677        $for_update = array();
    678678
    679679        // Create a tablename index for an array ($cqueries) of queries
    680         foreach($queries as $qry) {
     680        foreach( (array) $queries as $qry) {
    681681                if(preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
    682682                        $cqueries[strtolower($matches[1])] = $qry;
    683683                        $for_update[$matches[1]] = 'Created table '.$matches[1];
     
    699699        // Check to see which tables and fields exist
    700700        if($tables = $wpdb->get_col('SHOW TABLES;')) {
    701701                // For every table in the database
    702                 foreach($tables as $table) {
     702                foreach( (array) $tables as $table) {
    703703                        // If a table query exists for the database table...
    704704                        if( array_key_exists(strtolower($table), $cqueries) ) {
    705705                                // Clear the field and index arrays
     
    715715                                //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
    716716
    717717                                // For every field line specified in the query
    718                                 foreach($flds as $fld) {
     718                                foreach( (array) $flds as $fld) {
    719719                                        // Extract the field name
    720720                                        preg_match("|^([^ ]*)|", trim($fld), $fvals);
    721721                                        $fieldname = $fvals[1];
     
    746746                                $tablefields = $wpdb->get_results("DESCRIBE {$table};");
    747747
    748748                                // For every field in the table
    749                                 foreach($tablefields as $tablefield) {
     749                                foreach( (array) $tablefields as $tablefield) {
    750750                                        // If the table field exists in the field array...
    751751                                        if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
    752752                                                // Get the field type from the query
     
    781781                                }
    782782
    783783                                // For every remaining field specified for the table
    784                                 foreach($cfields as $fieldname => $fielddef) {
     784                                foreach( (array) $cfields as $fieldname => $fielddef) {
    785785                                        // Push a query line into $cqueries that adds the field to that table
    786786                                        $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
    787787                                        $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
     
    796796                                        unset($index_ary);
    797797
    798798                                        // For every index in the table
    799                                         foreach($tableindices as $tableindex) {
     799                                        foreach( (array) $tableindices as $tableindex) {
    800800                                                // Add the index to the index data array
    801801                                                $keyname = $tableindex->Key_name;
    802802                                                $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
     
    804804                                        }
    805805
    806806                                        // For each actual index in the index array
    807                                         foreach($index_ary as $index_name => $index_data) {
     807                                        foreach( (array) $index_ary as $index_name => $index_data) {
    808808                                                // Build a create string to compare to the query
    809809                                                $index_string = '';
    810810                                                if($index_name == 'PRIMARY') {
     
    819819                                                }
    820820                                                $index_columns = '';
    821821                                                // For each column in the index
    822                                                 foreach($index_data['columns'] as $column_data) {
     822                                                foreach( (array) $index_data['columns'] as $column_data) {
    823823                                                        if($index_columns != '') $index_columns .= ',';
    824824                                                        // Add the field to the column list string
    825825                                                        $index_columns .= $column_data['fieldname'];
     
    839839                                }
    840840
    841841                                // For every remaining index specified for the table
    842                                 foreach($indices as $index) {
     842                                foreach( (array) $indices as $index) {
    843843                                        // Push a query line into $cqueries that adds the index to that table
    844844                                        $cqueries[] = "ALTER TABLE {$table} ADD $index";
    845845                                        $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index;
     
    856856
    857857        $allqueries = array_merge($cqueries, $iqueries);
    858858        if($execute) {
    859                 foreach($allqueries as $query) {
     859                foreach( (array) $allqueries as $query) {
    860860                        //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
    861861                        $wpdb->query($query);
    862862                }
     
    870870
    871871        $alterations = dbDelta($wp_queries);
    872872        echo "<ol>\n";
    873         foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
     873        foreach( (array) $alterations as $alteration) echo "<li>$alteration</li>\n";
    874874        echo "</ol>\n";
    875875}
    876876
     
    892892        // standard WP files are copied.
    893893        $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
    894894
    895         foreach ($files as $oldfile => $newfile) {
     895        foreach ( (array) $files as $oldfile => $newfile) {
    896896                if ($oldfile == 'index.php')
    897897                        $oldpath = $home_path;
    898898                else
     
    917917                if ($lines) {
    918918                        $f = fopen("$site_dir/$newfile", 'w');
    919919
    920                         foreach ($lines as $line) {
     920                        foreach ( (array) $lines as $line) {
    921921                                if (preg_match('/require.*wp-blog-header/', $line))
    922922                                        $line = '//' . $line;
    923923
     
    971971        if ($stylelines) {
    972972                $f = fopen("$site_dir/style.css", 'w');
    973973
    974                 foreach ($stylelines as $line) {
     974                foreach ( (array) $stylelines as $line) {
    975975                        if (strstr($line, "Theme Name:")) $line = "Theme Name: $theme_name";
    976976                        elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl');
    977977                        elseif (strstr($line, "Description:")) $line = "Description: Your theme";
  • wp-admin/templates.php

     
    107107<h3><?php _e('Recent'); ?></h3>
    108108<?php
    109109echo '<ol>';
    110 foreach ($recents as $recent) :
     110foreach ( (array) $recents as $recent) :
    111111        echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>";
    112112endforeach;
    113113echo '</ol>';
     
    116116<h3><?php _e('Common'); ?></h3>
    117117        <?php $common_files = array('index.php', '.htaccess', 'my-hacks.php');
    118118 $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php');
    119  foreach ($old_files as $old_file) {
     119 foreach ( (array) $old_files as $old_file) {
    120120         if (file_exists(ABSPATH . $old_file))
    121121                 $common_files[] = $old_file;
    122122 } ?>
    123123  <ul>
    124          <?php foreach ($common_files as $common_file) : ?>
     124         <?php foreach ( (array) $common_files as $common_file) : ?>
    125125          <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li>
    126126         <?php endforeach; ?>
    127127  </ul>
  • wp-admin/admin-functions.php

     
    115115
    116116        $i = 0;
    117117        $search = "# id=(\"|')p(\d+)\\1#i";
    118         foreach ( $anchor_matches[0] as $anchor ) {
     118        foreach ( (array) $anchor_matches[0] as $anchor ) {
    119119                if ( 0 == preg_match($search, $anchor, $id_matches) )
    120120                        continue;
    121121
     
    225225
    226226        // Meta Stuff
    227227        if ($_POST['meta']) {
    228                 foreach ($_POST['meta'] as $key => $value)
     228                foreach ( (array) $_POST['meta'] as $key => $value)
    229229                        update_meta($key, $value['key'], $value['value']);
    230230        }
    231231
    232232        if ($_POST['deletemeta']) {
    233                 foreach ($_POST['deletemeta'] as $key => $value)
     233                foreach ( (array) $_POST['deletemeta'] as $key => $value)
    234234                        delete_meta($key);
    235235        }
    236236
     
    364364function wp_dropdown_roles( $default = false ) {
    365365        global $wp_roles;
    366366        $r = '';
    367         foreach($wp_roles->role_names as $role => $name)
     367        foreach( (array) $wp_roles->role_names as $role => $name)
    368368                if ( $default == $role ) // Make default first in list
    369369                        $p = "\n\t<option selected='selected' value='$role'>$name</option>";
    370370                else
     
    609609        $result = array ();
    610610
    611611        if (is_array($cats)) {
    612                 foreach ($cats as $cat) {
     612                foreach ( (array) $cats as $cat) {
    613613                        $result[$cat]['children'] = get_nested_categories($default, $cat);
    614614                        $result[$cat]['cat_ID'] = $cat;
    615615                        $result[$cat]['checked'] = in_array($cat, $checked_categories);
     
    623623}
    624624
    625625function write_nested_categories($categories) {
    626         foreach ($categories as $category) {
     626        foreach ( (array) $categories as $category) {
    627627                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($category['cat_name']), "</label></li>\n";
    628628
    629629                if ( $category['children'] ) {
     
    646646                $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    647647
    648648        if ($categories) {
    649                 foreach ($categories as $category) {
     649                foreach ( (array) $categories as $category) {
    650650                        if ($category->category_parent == $parent) {
    651651                                $category->cat_name = wp_specialchars($category->cat_name,'double');
    652652                                $pad = str_repeat('&#8212; ', $level);
     
    690690        if (! $pages)
    691691                return false;
    692692
    693         foreach ($pages as $post) {
     693        foreach ( (array) $pages as $post) {
    694694                setup_postdata($post);
    695695                if ( $hierarchy && ($post->post_parent != $parent) )
    696696                        continue;
     
    750750                $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    751751        }
    752752        if ($categories) {
    753                 foreach ($categories as $category) {
     753                foreach ( (array) $categories as $category) {
    754754                        if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
    755755                                $pad = str_repeat('&#8211; ', $level);
    756756                                $category->cat_name = wp_specialchars($category->cat_name);
     
    895895        </thead>
    896896<?php
    897897        $r ="\n\t<tbody id='the-list'>";
    898         foreach ($meta as $entry) {
     898        foreach ( (array) $meta as $entry) {
    899899                ++ $count;
    900900                if ($count % 2)
    901901                        $style = 'alternate';
     
    954954<option value="#NONE#"><?php _e('- Select -'); ?></option>
    955955<?php
    956956
    957         foreach ($keys as $key) {
     957        foreach ( (array) $keys as $key) {
    958958                echo "\n\t<option value='$key'>$key</option>";
    959959        }
    960960?>
     
    10801080                $foundit = false;
    10811081                if ($markerdata) {
    10821082                        $state = true;
    1083                         foreach ($markerdata as $n => $markerline) {
     1083                        foreach ( (array) $markerdata as $n => $markerline) {
    10841084                                if (strstr($markerline, "# BEGIN {$marker}"))
    10851085                                        $state = false;
    10861086                                if ($state) {
     
    10921092                                if (strstr($markerline, "# END {$marker}")) {
    10931093                                        fwrite($f, "# BEGIN {$marker}\n");
    10941094                                        if (is_array($insertion))
    1095                                                 foreach ($insertion as $insertline)
     1095                                                foreach ( (array) $insertion as $insertline)
    10961096                                                        fwrite($f, "{$insertline}\n");
    10971097                                        fwrite($f, "# END {$marker}\n");
    10981098                                        $state = true;
     
    11021102                }
    11031103                if (!$foundit) {
    11041104                        fwrite($f, "# BEGIN {$marker}\n");
    1105                         foreach ($insertion as $insertline)
     1105                        foreach ( (array) $insertion as $insertline)
    11061106                                fwrite($f, "{$insertline}\n");
    11071107                        fwrite($f, "# END {$marker}\n");
    11081108                }
     
    11261126        if ($markerdata = explode("\n", implode('', file($filename))));
    11271127        {
    11281128                $state = false;
    1129                 foreach ($markerdata as $markerline) {
     1129                foreach ( (array) $markerdata as $markerline) {
    11301130                        if (strstr($markerline, "# END {$marker}"))
    11311131                                $state = false;
    11321132                        if ($state)
     
    12481248        $page_templates = array ();
    12491249
    12501250        if (is_array($templates)) {
    1251                 foreach ($templates as $template) {
     1251                foreach ( (array) $templates as $template) {
    12521252                        $template_data = implode('', file(ABSPATH.$template));
    12531253                        preg_match("|Template Name:(.*)|i", $template_data, $name);
    12541254                        preg_match("|Description:(.*)|i", $template_data, $description);
     
    12811281        $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order");
    12821282
    12831283        if ($items) {
    1284                 foreach ($items as $item) {
     1284                foreach ( (array) $items as $item) {
    12851285                        // A page cannot be it's own parent.
    12861286                        if (!empty ($post_ID)) {
    12871287                                if ($item->ID == $post_ID) {
     
    13171317                return true;
    13181318
    13191319        if (isset ($submenu[$parent])) {
    1320                 foreach ($submenu[$parent] as $submenu_array) {
     1320                foreach ( (array) $submenu[$parent] as $submenu_array) {
    13211321                        if ($submenu_array[2] == $pagenow) {
    13221322                                if (current_user_can($submenu_array[1]))
    13231323                                        return true;
     
    13271327                }
    13281328        }
    13291329
    1330         foreach ($menu as $menu_array) {
     1330        foreach ( (array) $menu as $menu_array) {
    13311331                //echo "parent array: " . $menu_array[2];
    13321332                if ($menu_array[2] == $parent) {
    13331333                        if (current_user_can($menu_array[1]))
     
    13551355
    13561356        $parent = $parent1 = get_admin_page_parent();
    13571357        if (empty ($parent)) {
    1358                 foreach ($menu as $menu_array) {
     1358                foreach ( (array) $menu as $menu_array) {
    13591359                        if (isset ($menu_array[3])) {
    13601360                                if ($menu_array[2] == $pagenow) {
    13611361                                        $title = $menu_array[3];
     
    13691369                }
    13701370        } else {
    13711371                foreach (array_keys($submenu) as $parent) {
    1372                         foreach ($submenu[$parent] as $submenu_array) {
     1372                        foreach ( (array) $submenu[$parent] as $submenu_array) {
    13731373                                if (isset ($submenu_array[3])) {
    13741374                                        if ($submenu_array[2] == $pagenow) {
    13751375                                                $title = $submenu_array[3];
     
    14031403        }
    14041404
    14051405        if ($pagenow == 'admin.php' && isset ($plugin_page)) {
    1406                 foreach ($menu as $parent_menu) {
     1406                foreach ( (array) $menu as $parent_menu) {
    14071407                        if ($parent_menu[2] == $plugin_page) {
    14081408                                $parent_file = $plugin_page;
    14091409                                if ( isset($real_parent_file[$parent_file]) )
     
    14151415        }
    14161416
    14171417        foreach (array_keys($submenu) as $parent) {
    1418                 foreach ($submenu[$parent] as $submenu_array) {
     1418                foreach ( (array) $submenu[$parent] as $submenu_array) {
    14191419                        if ( isset($real_parent_file[$parent]) )
    14201420                                $parent = $real_parent_file[$parent];
    14211421                        if ($submenu_array[2] == $pagenow) {
     
    14651465        // parent file someone is trying to link back to the parent manually.  In
    14661466        // this case, don't automatically add a link back to avoid duplication.
    14671467        if (!isset ($submenu[$parent]) && $file != $parent) {
    1468                 foreach ($menu as $parent_menu) {
     1468                foreach ( (array) $menu as $parent_menu) {
    14691469                        if ($parent_menu[2] == $parent) {
    14701470                                $submenu[$parent][] = $parent_menu;
    14711471                        }
     
    16541654
    16551655        sort($plugin_files);
    16561656
    1657         foreach ($plugin_files as $plugin_file) {
     1657        foreach ( (array) $plugin_files as $plugin_file) {
    16581658                if ( !is_readable("$plugin_root/$plugin_file"))
    16591659                        continue;
    16601660
     
    18441844        if ( $test_type ) {
    18451845                $type = false;
    18461846                $ext = false;
    1847                 foreach ($mimes as $ext_preg => $mime_match) {
     1847                foreach ( (array) $mimes as $ext_preg => $mime_match) {
    18481848                        $ext_preg = '![^.]\.(' . $ext_preg . ')$!i';
    18491849                        if ( preg_match($ext_preg, $file['name'], $ext_matches) ) {
    18501850                                $type = $mime_match;
  • wp-admin/edit-page-form.php

     
    104104<div class="dbx-content">
    105105<select name="post_author_override" id="post_author_override">
    106106<?php
    107 foreach ($authors as $o) :
     107foreach ( (array) $authors as $o) :
    108108$o = get_userdata( $o->ID );
    109109if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
    110110else $selected = '';
  • wp-admin/moderation.php

     
    2323
    2424$comment = array();
    2525if (isset($_POST["comment"])) {
    26         foreach ($_POST["comment"] as $k => $v) {
     26        foreach ( (array) $_POST["comment"] as $k => $v) {
    2727                $comment[intval($k)] = $v;
    2828        }
    2929}
     
    4242        $item_approved = 0;
    4343        $item_spam = 0;
    4444
    45         foreach($comment as $key => $value) {
     45        foreach( (array) $comment as $key => $value) {
    4646        if ($feelinglucky && 'later' == $value)
    4747                $value = 'delete';
    4848            switch($value) {
     
    137137    <ol id="the-list" class="commentlist">
    138138<?php
    139139$i = 0;
    140     foreach($comments as $comment) {
     140    foreach( (array) $comments as $comment) {
    141141        ++$i;
    142142        $comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date);
    143143        $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
  • wp-admin/index.php

     
    2323<ul>
    2424<?php
    2525$rss->items = array_slice($rss->items, 0, 10);
    26 foreach ($rss->items as $item ) {
     26foreach ( (array) $rss->items as $item ) {
    2727?>
    2828        <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wp_specialchars($item['title']); ?></a></li>
    2929<?php } ?>
     
    4848<ul>
    4949<?php
    5050if ( $comments ) {
    51 foreach ($comments as $comment) {
     51foreach ( (array) $comments as $comment) {
    5252        echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
    5353        edit_comment_link(__("Edit"), ' <small>(', ')</small>');
    5454        echo '</li>';
     
    6666<h3><?php _e('Posts'); ?> <a href="edit.php" title="<?php _e('More posts...'); ?>">&raquo;</a></h3>
    6767<ul>
    6868<?php
    69 foreach ($recentposts as $post) {
     69foreach ( (array) $recentposts as $post) {
    7070        if ($post->post_title == '')
    7171                $post->post_title = sprintf(__('Post #%s'), $post->ID);
    7272        echo "<li><a href='post.php?action=edit&amp;post=$post->ID'>";
     
    8585<h3><?php _e('Scheduled Entries:') ?></h3>
    8686<ul>
    8787<?php
    88 foreach ($scheduled as $post) {
     88foreach ( (array) $scheduled as $post) {
    8989        if ($post->post_title == '')
    9090                $post->post_title = sprintf(__('Post #%s'), $post->ID);
    9191        echo "<li>" . sprintf(__('%1$s in %2$s'), "<a href='post.php?action=edit&amp;post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a>", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') ))  . "</li>";
     
    132132<h3><?php _e('WordPress Development Blog'); ?></h3>
    133133<?php
    134134$rss->items = array_slice($rss->items, 0, 3);
    135 foreach ($rss->items as $item ) {
     135foreach ( (array) $rss->items as $item ) {
    136136?>
    137137<h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4>
    138138<p><?php echo $item['description']; ?></p>
     
    151151<ul>
    152152<?php
    153153$rss->items = array_slice($rss->items, 0, 20);
    154 foreach ($rss->items as $item ) {
     154foreach ( (array) $rss->items as $item ) {
    155155?>
    156156<li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li>
    157157<?php
  • wp-admin/admin-db.php

     
    186186        // Only set posts and links to the default category if they're not in another category already.
    187187        $default_cat = get_option('default_category');
    188188        $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
    189         if ( is_array($posts) ) foreach ($posts as $post_id) {
     189        if ( is_array($posts) ) foreach ( (array) $posts as $post_id) {
    190190                $cats = wp_get_post_cats('', $post_id);
    191191                if ( 1 == count($cats) )
    192192                        $cats = array($default_cat);
     
    197197
    198198        $default_link_cat = get_option('default_link_category');
    199199        $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
    200         if ( is_array($links) ) foreach ($links as $link_id) {
     200        if ( is_array($links) ) foreach ( (array) $links as $link_id) {
    201201                $cats = wp_get_link_cats($link_id);
    202202                if ( 1 == count($cats) )
    203203                        $cats = array($default_link_cat);
     
    221221
    222222function wp_create_categories($categories, $post_id = '') {
    223223        $cat_ids = array ();
    224         foreach ($categories as $category) {
     224        foreach ( (array) $categories as $category) {
    225225                if ($id = category_exists($category))
    226226                        $cat_ids[] = $id;
    227227                else
     
    253253                $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
    254254
    255255                if ($post_ids) {
    256                         foreach ($post_ids as $post_id)
     256                        foreach ( (array) $post_ids as $post_id)
    257257                                wp_delete_post($post_id);
    258258                }
    259259
     
    384384       
    385385        $categories = wp_get_link_cats($link_id);
    386386        if( is_array( $categories ) ) {
    387                 foreach ( $categories as $category ) {
     387                foreach ( (array) $categories as $category ) {
    388388                        $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
    389389                        wp_cache_delete($category, 'category');
    390390                }
     
    434434        $delete_cats = array_diff($old_categories,$link_categories);
    435435
    436436        if ($delete_cats) {
    437                 foreach ($delete_cats as $del) {
     437                foreach ( (array) $delete_cats as $del) {
    438438                        $wpdb->query("
    439439                                DELETE FROM $wpdb->link2cat
    440440                                WHERE category_id = $del
     
    447447        $add_cats = array_diff($link_categories, $old_categories);
    448448
    449449        if ($add_cats) {
    450                 foreach ($add_cats as $new_cat) {
     450                foreach ( (array) $add_cats as $new_cat) {
    451451                        $wpdb->query("
    452452                                INSERT INTO $wpdb->link2cat (link_id, category_id)
    453453                                VALUES ($link_ID, $new_cat)");
     
    456456       
    457457        // Update category counts.
    458458        $all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
    459         foreach ( $all_affected_cats as $cat_id ) {
     459        foreach ( (array) $all_affected_cats as $cat_id ) {
    460460                $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
    461461                $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
    462462                wp_cache_delete($cat_id, 'category');
  • wp-admin/import/livejournal.php

     
    3636                $posts = $posts[1];
    3737                unset($importdata);
    3838                echo '<ol>';
    39                 foreach ($posts as $post) {
     39                foreach ( (array) $posts as $post) {
    4040                        preg_match('|<subject>(.*?)</subject>|is', $post, $post_title);
    4141                        $post_title = $wpdb->escape(trim($post_title[1]));
    4242                        if ( empty($post_title) ) {
     
    8181                        if ( $comments ) {
    8282                                $comment_post_ID = $post_id;
    8383                                $num_comments = 0;
    84                                 foreach ($comments as $comment) {
     84                                foreach ( (array) $comments as $comment) {
    8585                                        preg_match('|<event>(.*?)</event>|is', $comment, $comment_content);
    8686                                        $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
    8787                                        $comment_content = $this->unhtmlentities($comment_content);
  • wp-admin/import/dotclear.php

     
    221221                if(is_array($categories))
    222222                {
    223223                        echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
    224                         foreach ($categories as $category)
     224                        foreach ( (array) $categories as $category)
    225225                        {
    226226                                $count++;
    227227                                extract($category);
     
    262262                if(is_array($users))
    263263                {
    264264                        echo '<p>'.__('Importing Users...').'<br /><br /></p>';
    265                         foreach($users as $user)
     265                        foreach( (array) $users as $user)
    266266                        {
    267267                                $count++;
    268268                                extract($user);
     
    312312                                update_usermeta( $ret_id, 'rich_editing', 'false');
    313313                                update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
    314314                                update_usermeta( $ret_id, 'last_name', csc ($user_nom));
    315                         }// End foreach($users as $user)
     315                        }// End foreach( (array) $users as $user)
    316316
    317317                        // Store id translation array for future use
    318318                        add_option('dcid2wpid',$dcid2wpid);
     
    339339                if(is_array($posts))
    340340                {
    341341                        echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
    342                         foreach($posts as $post)
     342                        foreach( (array) $posts as $post)
    343343                        {
    344344                                $count++;
    345345                                extract($post);
     
    430430                if(is_array($comments))
    431431                {
    432432                        echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
    433                         foreach($comments as $comment)
     433                        foreach( (array) $comments as $comment)
    434434                        {
    435435                                $count++;
    436436                                extract($comment);
     
    501501                if(is_array($links))
    502502                {
    503503                        echo '<p>'.__('Importing Links...').'<br /><br /></p>';
    504                         foreach($links as $link)
     504                        foreach( (array) $links as $link)
    505505                        {
    506506                                $count++;
    507507                                extract($link);
  • wp-admin/import/mt.php

     
    3636        <?php
    3737
    3838
    39                 foreach ($users as $user) {
     39                foreach ( (array) $users as $user) {
    4040                        echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
    4141                }
    4242?>
     
    8585        function get_mt_authors() {
    8686                $temp = array ();
    8787                $i = -1;
    88                 foreach ($this->posts as $post) {
     88                foreach ( (array) $this->posts as $post) {
    8989                        if ('' != trim($post)) {
    9090                                ++ $i;
    9191                                preg_match("|AUTHOR:(.*)|", $post, $thematch);
     
    110110                $formnames = array ();
    111111                $selectnames = array ();
    112112
    113                 foreach ($_POST['user'] as $key => $line) {
     113                foreach ( (array) $_POST['user'] as $key => $line) {
    114114                        $newname = trim(stripslashes($line));
    115115                        if ($newname == '')
    116116                                $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
    117117                        array_push($formnames, "$newname");
    118118                } // $formnames is the array with the form entered names
    119119
    120                 foreach ($_POST['userselect'] as $user => $key) {
     120                foreach ( (array) $_POST['userselect'] as $user => $key) {
    121121                        $selected = trim(stripslashes($key));
    122122                        array_push($selectnames, "$selected");
    123123                }
     
    146146                echo '<ol id="authors">';
    147147                echo '<form action="?import=mt&amp;step=2&amp;id=' . $this->id . '" method="post">';
    148148                $j = -1;
    149                 foreach ($authors as $author) {
     149                foreach ( (array) $authors as $author) {
    150150                        ++ $j;
    151151                        echo '<li>Current author: <strong>'.$author.'</strong><br />'.'Create user <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br /> or map to existing ';
    152152                        $this->users_form($j);
     
    179179                global $wpdb;
    180180                $i = -1;
    181181                echo "<div class='wrap'><ol>";
    182                 foreach ($this->posts as $post) {
     182                foreach ( (array) $this->posts as $post) {
    183183                        if ('' != trim($post)) {
    184184                                ++ $i;
    185185                                unset ($post_categories);
     
    215215
    216216                                // Grab the metadata from what's left
    217217                                $metadata = explode("\n", $post);
    218                                 foreach ($metadata as $line) {
     218                                foreach ( (array) $metadata as $line) {
    219219                                        preg_match("/^(.*?):(.*)/", $line, $token);
    220220                                        $key = trim($token[1]);
    221221                                        $value = trim($token[2]);
     
    299299                                // Now for comments
    300300                                $comments = explode("-----\nCOMMENT:", $comments[0]);
    301301                                $num_comments = 0;
    302                                 foreach ($comments as $comment) {
     302                                foreach ( (array) $comments as $comment) {
    303303                                        if ('' != trim($comment)) {
    304304                                                // Author
    305305                                                preg_match("|AUTHOR:(.*)|", $comment, $comment_author);
     
    341341                                $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]);
    342342                                $pings = explode("-----\nPING:", $pings[0]);
    343343                                $num_pings = 0;
    344                                 foreach ($pings as $ping) {
     344                                foreach ( (array) $pings as $ping) {
    345345                                        if ('' != trim($ping)) {
    346346                                                // 'Author'
    347347                                                preg_match("|BLOG NAME:(.*)|", $ping, $comment_author);
  • wp-admin/import/blogger.php

     
    4949
    5050                // put the rest of the headers in an array
    5151                $response_header_array = array();
    52                 foreach($response_header_lines as $header_line) {
     52                foreach( (array) $response_header_lines as $header_line) {
    5353                        list($header,$value) = explode(': ', $header_line, 2);
    5454                        $response_header_array[$header] .= $value."\n";
    5555                }
    5656
    5757                $cookie_array = array();
    5858                $cookies = explode("\n", $response_header_array["Set-Cookie"]);
    59                 foreach($cookies as $this_cookie) { array_push($cookie_array, "Cookie: ".$this_cookie); }
     59                foreach( (array) $cookies as $this_cookie) { array_push($cookie_array, "Cookie: ".$this_cookie); }
    6060
    6161                return array("code" => $response_code, "header" => $response_header_array, "cookies" => $cookie_array, "body" => $response_body);
    6262        }
     
    118118        function post_blogger($url, $header = false, $paramary = false, $parse=true) {
    119119                $params = '';
    120120                if ( is_array($paramary) ) {
    121                         foreach($paramary as $key=>$value)
     121                        foreach( (array) $paramary as $key=>$value)
    122122                                if($key && $value != '')
    123123                                        $params.=$key."=".urlencode(stripslashes($value))."&";
    124124                }
     
    149149        function show_blogs() {
    150150                global $import;
    151151                echo '<h1>' . __('Selecting a Blog') . "</h1>\n<ul>";
    152                 foreach ( $this->import['blogs'] as $blog ) {
     152                foreach ( (array) $this->import['blogs'] as $blog ) {
    153153                        if (9 == $blog['nextstep']) $status = "100%";
    154154                        elseif (8 == $blog['nextstep']) $status = "90%";
    155155                        elseif (7 == $blog['nextstep']) $status = "82.5%";
     
    244244                                die(__('No blogs found for this user.'));
    245245                        $this->import['blogs'] = array();
    246246                        $template = '<MainPage><br /><br /><br /><p>'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover <a href="http://wordpress.org/">a better blogging tool</a>.').'</p><BloggerArchives><a class="archive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>';
    247                         foreach ( $blogsary[1] as $key => $id ) {
     247                        foreach ( (array) $blogsary[1] as $key => $id ) {
    248248                                // Define the required Blogger options.
    249249                                $blog_opts = array(
    250250                                        'blog-options-basic' => false,
     
    256256                                );
    257257
    258258                                // Build the blog options array template
    259                                 foreach ($blog_opts as $blog_opt => $modify)
     259                                foreach ( (array) $blog_opts as $blog_opt => $modify)
    260260                                        $new_opts["$blog_opt"] = array('backup'=>false, 'modify' => $modify, 'error'=>false);
    261261
    262262                                $this->import['blogs']["$id"] = array(
     
    292292        function backup_settings() {
    293293                $output.= '<h1>'.__('Backing up Blogger options')."</h1>\n";
    294294                $form = false;
    295                 foreach ($this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary) {
     295                foreach ( (array) $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary) {
    296296                        if ( $blog_opt == $_GET['form'] ) {
    297297                                // Save the posted form data
    298298                                $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup'] = $_POST;
     
    366366                if (! strstr($bloghtml['body'], '<a class="archive"') )
    367367                        die(__('Your Blogger blog did not take the new template or did not respond.'));
    368368                preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives);
    369                 foreach ($archives[1] as $archive) {
     369                foreach ( (array) $archives[1] as $archive) {
    370370                        $this->import['blogs'][$_GET['blog']]['archives'][$archive] = false;
    371371                }
    372372                $this->set_next_step(6);
     
    379379                $output = '<h2>'.__('Importing Blogger archives into WordPress').'</h2>';
    380380                $did_one = false;
    381381                $post_array = $posts = array();
    382                 foreach ( $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) {
     382                foreach ( (array) $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) {
    383383                        $archivename = substr(basename($url),0,7);
    384384                        if ( $status || $did_one ) {
    385385                                $foo = 'bar';
     
    497497                                }
    498498                                if ( count($post_array) ) {
    499499                                        krsort($post_array);
    500                                         foreach($post_array as $post) {
     500                                        foreach( (array) $post_array as $post) {
    501501                                                if ( ! $comment_post_ID = $post['ID'] )
    502502                                                        $comment_post_ID = wp_insert_post($post['post']);
    503503                                                if ( $post['comments'] ) {
    504                                                         foreach ( $post['comments'] as $comment ) {
     504                                                        foreach ( (array) $post['comments'] as $comment ) {
    505505                                                                $comment['comment_post_ID'] = $comment_post_ID;
    506506                                                                wp_insert_comment($comment);
    507507                                                        }
     
    533533                        $this->import['reversed'] = true;
    534534                        update_option('import-blogger', $this->import);
    535535                }
    536                 foreach ( $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary ) {
     536                foreach ( (array) $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary ) {
    537537                        if ( $did_one ) {
    538538                                $output .= "<p>$blog_opt</p>\n";
    539539                        } elseif ( $optary['restored'] || ! $optary['modify'] ) {
  • wp-admin/import/textpattern.php

     
    163163                if(is_array($categories))
    164164                {
    165165                        echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
    166                         foreach ($categories as $category)
     166                        foreach ( (array) $categories as $category)
    167167                        {
    168168                                $count++;
    169169                                extract($category);
     
    204204                if(is_array($users))
    205205                {
    206206                        echo '<p>'.__('Importing Users...').'<br /><br /></p>';
    207                         foreach($users as $user)
     207                        foreach( (array) $users as $user)
    208208                        {
    209209                                $count++;
    210210                                extract($user);
     
    252252
    253253                                update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] );
    254254                                update_usermeta( $ret_id, 'rich_editing', 'false');
    255                         }// End foreach($users as $user)
     255                        }// End foreach( (array) $users as $user)
    256256
    257257                        // Store id translation array for future use
    258258                        add_option('txpid2wpid',$txpid2wpid);
     
    279279                if(is_array($posts))
    280280                {
    281281                        echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
    282                         foreach($posts as $post)
     282                        foreach( (array) $posts as $post)
    283283                        {
    284284                                $count++;
    285285                                extract($post);
     
    360360                if(is_array($comments))
    361361                {
    362362                        echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
    363                         foreach($comments as $comment)
     363                        foreach( (array) $comments as $comment)
    364364                        {
    365365                                $count++;
    366366                                extract($comment);
     
    428428                if(is_array($links))
    429429                {
    430430                        echo '<p>'.__('Importing Links...').'<br /><br /></p>';
    431                         foreach($links as $link)
     431                        foreach( (array) $links as $link)
    432432                        {
    433433                                $count++;
    434434                                extract($link);
  • wp-admin/import/blogware.php

     
    3838                $posts = $posts[1];
    3939                unset($importdata);
    4040                echo '<ol>';           
    41                 foreach ($posts as $post) {
     41                foreach ( (array) $posts as $post) {
    4242                        flush();
    4343                        preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
    4444                        $post_type = $post_type[1];
     
    5757                        $categories = $categories[1];
    5858
    5959                        $cat_index = 0;
    60                         foreach ($categories as $category) {
     60                        foreach ( (array) $categories as $category) {
    6161                                $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
    6262                                $cat_index++;
    6363                        }
     
    104104                        if ( $comments ) {
    105105                                $comment_post_ID = $post_id;
    106106                                $num_comments = 0;
    107                                 foreach ($comments as $comment) {
     107                                foreach ( (array) $comments as $comment) {
    108108                                        preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
    109109                                        $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
    110110                                        $comment_content = $this->unhtmlentities($comment_content);
  • wp-admin/import/greymatter.php

     
    101101        chdir($gmpath);
    102102        $userbase = file("gm-authors.cgi");
    103103
    104         foreach($userbase as $user) {
     104        foreach( (array) $userbase as $user) {
    105105                $userdata=explode("|", $user);
    106106
    107107                $user_ip="127.0.0.1";
  • wp-admin/import/rss.php

     
    3636                preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
    3737                $this->posts = $this->posts[1];
    3838                $index = 0;
    39                 foreach ($this->posts as $post) {
     39                foreach ( (array) $this->posts as $post) {
    4040                        preg_match('|<title>(.*?)</title>|is', $post, $post_title);
    4141                        $post_title = $wpdb->escape(trim($post_title[1]));
    4242
     
    6363                        }
    6464
    6565                        $cat_index = 0;
    66                         foreach ($categories as $category) {
     66                        foreach ( (array) $categories as $category) {
    6767                                $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
    6868                                $cat_index++;
    6969                        }
     
    9898        function import_posts() {
    9999                echo '<ol>';
    100100
    101                 foreach ($this->posts as $post) {
     101                foreach ( (array) $this->posts as $post) {
    102102                        echo "<li>".__('Importing post...');
    103103
    104104                        extract($post);
  • wp-admin/import/wordpress.php

     
    4141?><select name="userselect[<?php echo $n; ?>]">
    4242        <option value="#NONE#">- Select -</option>
    4343        <?php
    44                 foreach ($users as $user) {
     44                foreach ( (array) $users as $user) {
    4545                        echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
    4646                }
    4747?>
     
    8888        function get_wp_authors() {
    8989                $temp = array ();
    9090                $i = -1;
    91                 foreach ($this->posts as $post) {
     91                foreach ( (array) $this->posts as $post) {
    9292                        if ('' != trim($post)) {
    9393                                ++ $i;
    9494                                $author = $this->get_tag( $post, 'dc:creator' );
     
    112112                $formnames = array ();
    113113                $selectnames = array ();
    114114
    115                 foreach ($_POST['user'] as $key => $line) {
     115                foreach ( (array) $_POST['user'] as $key => $line) {
    116116                        $newname = trim(stripslashes($line));
    117117                        if ($newname == '')
    118118                                $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
    119119                        array_push($formnames, "$newname");
    120120                } // $formnames is the array with the form entered names
    121121
    122                 foreach ($_POST['userselect'] as $user => $key) {
     122                foreach ( (array) $_POST['userselect'] as $user => $key) {
    123123                        $selected = trim(stripslashes($key));
    124124                        array_push($selectnames, "$selected");
    125125                }
     
    146146                echo '<ol id="authors">';
    147147                echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
    148148                $j = -1;
    149                 foreach ($authors as $author) {
     149                foreach ( (array) $authors as $author) {
    150150                        ++ $j;
    151151                        echo '<li>Current author: <strong>'.$author.'</strong><br />'.'Create user <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br /> or map to existing ';
    152152                        $this->users_form($j);
     
    179179                global $wpdb;
    180180                $i = -1;
    181181                echo '<ol>';
    182                 foreach ($this->posts as $post) {
     182                foreach ( (array) $this->posts as $post) {
    183183
    184184                        // There are only ever one of these
    185185                        $post_title     = $this->get_tag( $post, 'title' );
     
    203203                        $categories = $categories[1];
    204204
    205205                        $cat_index = 0;
    206                         foreach ($categories as $category) {
     206                        foreach ( (array) $categories as $category) {
    207207                                $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
    208208                                $cat_index++;
    209209                        }
     
    229229                                preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
    230230                                $comments = $comments[1];
    231231                                $num_comments = 0;
    232                                 if ( $comments) { foreach ($comments as $comment) {
     232                                if ( $comments) { foreach ( (array) $comments as $comment) {
    233233                                        $comment_author       = $this->get_tag( $comment, 'wp:comment_author');
    234234                                        $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
    235235                                        $comment_author_IP    = $this->get_tag( $comment, 'wp:comment_author_IP');
     
    253253                                // Now for post meta
    254254                                preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
    255255                                $postmeta = $postmeta[1];
    256                                 if ( $postmeta) { foreach ($postmeta as $p) {
     256                                if ( $postmeta) { foreach ( (array) $postmeta as $p) {
    257257                                        $key   = $this->get_tag( $p, 'wp:meta_key' );
    258258                                        $value = $this->get_tag( $p, 'wp:meta_value' );
    259259                                        add_post_meta( $post_id, $key, $value );
  • wp-admin/edit-form-advanced.php

     
    3838if ('' != $post->pinged) {
    3939        $pings = '<p>'. __('Already pinged:') . '</p><ul>';
    4040        $already_pinged = explode("\n", trim($post->pinged));
    41         foreach ($already_pinged as $pinged_url) {
     41        foreach ( (array) $already_pinged as $pinged_url) {
    4242                $pings .= "\n\t<li>$pinged_url</li>";
    4343        }
    4444        $pings .= '</ul>';
     
    120120<div class="dbx-content">
    121121<select name="post_author_override" id="post_author_override">
    122122<?php
    123 foreach ($authors as $o) :
     123foreach ( (array) $authors as $o) :
    124124$o = get_userdata( $o->ID );
    125125if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
    126126else $selected = '';
  • wp-admin/menu.php

     
    5252$submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
    5353
    5454// Create list of page plugin hook names.
    55 foreach ($menu as $menu_page) {
     55foreach ( (array) $menu as $menu_page) {
    5656        $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
    5757}
    5858
    5959do_action('admin_menu', '');
    6060
    6161// Loop over submenus and remove pages for which the user does not have privs.
    62 foreach ($submenu as $parent => $sub) {
    63         foreach ($sub as $index => $data) {
     62foreach ( (array) $submenu as $parent => $sub) {
     63        foreach ( (array) $sub as $index => $data) {
    6464                if ( ! current_user_can($data[1]) ) {
    6565                        $menu_nopriv[$data[2]] = true;
    6666                        unset($submenu[$parent][$index]);
     
    7575// Remove menus that have no accessible submenus and require privs that the user does not have.
    7676// Menus for which the original parent is not acessible due to lack of privs will have the next
    7777// submenu in line be assigned as the new menu parent.
    78 foreach ( $menu as $id => $data ) {
     78foreach ( (array) $menu as $id => $data ) {
    7979        // If submenu is empty...
    8080        if ( empty($submenu[$data[2]]) ) {
    8181                // And user doesn't have privs, remove menu.
     
    9494                        $real_parent_file[$old_parent] = $new_parent;
    9595                        $menu[$id][2] = $new_parent;
    9696                       
    97                         foreach ($submenu[$old_parent] as $index => $data) {
     97                        foreach ( (array) $submenu[$old_parent] as $index => $data) {
    9898                                $submenu[$new_parent][$index] = $submenu[$old_parent][$index];
    9999                                unset($submenu[$old_parent][$index]);
    100100                        }
  • wp-admin/link-import.php

     
    4747<?php _e('Category:') ?> <select name="cat_id">
    4848<?php
    4949$categories = get_categories('hide_empty=0');
    50 foreach ($categories as $category) {
     50foreach ( (array) $categories as $category) {
    5151?>
    5252<option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option>
    5353<?php
  • wp-admin/plugins.php

     
    4141
    4242// If a plugin file does not exist, remove it from the list of active
    4343// plugins.
    44 foreach ($check_plugins as $check_plugin) {
     44foreach ( (array) $check_plugins as $check_plugin) {
    4545        if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
    4646                        $current = get_settings('active_plugins');
    4747                        $key = array_search($check_plugin, $current);
     
    9696
    9797        uksort($plugins, 'sort_plugins');
    9898
    99         foreach($plugins as $plugin_file => $plugin_data) {
     99        foreach( (array) $plugins as $plugin_file => $plugin_data) {
    100100                $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
    101101
    102102                if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
  • wp-admin/edit.php

     
    1818    <p><strong><?php _e('Your Drafts:') ?></strong>
    1919    <?php
    2020        $i = 0;
    21         foreach ($drafts as $draft) {
     21        foreach ( (array) $drafts as $draft) {
    2222                if (0 != $i)
    2323                        echo ', ';
    2424                $draft->post_title = stripslashes($draft->post_title);
     
    3535    <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
    3636    <?php
    3737        $i = 0;
    38         foreach ($other_drafts as $draft) {
     38        foreach ( (array) $other_drafts as $draft) {
    3939                if (0 != $i)
    4040                        echo ', ';
    4141                $draft->post_title = stripslashes($draft->post_title);
     
    9090        <legend><?php _e('Browse Month&hellip;') ?></legend>
    9191    <select name='m'>
    9292        <?php
    93                 foreach ($arc_result as $arc_row) {
     93                foreach ( (array) $arc_result as $arc_row) {
    9494                        if ( $arc_row->yyear == 0 )
    9595                                continue;
    9696                        $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
     
    137137        <thead>
    138138        <tr>
    139139
    140 <?php foreach($posts_columns as $column_display_name) { ?>
     140<?php foreach( (array) $posts_columns as $column_display_name) { ?>
    141141        <th scope="col"><?php echo $column_display_name; ?></th>
    142142<?php } ?>
    143143
     
    147147<?php
    148148if ($posts) {
    149149$bgcolor = '';
    150 foreach ($posts as $post) { start_wp();
     150foreach ( (array) $posts as $post) { start_wp();
    151151add_filter('the_title','wp_specialchars');
    152152$class = ('alternate' == $class) ? '' : 'alternate';
    153153?>
     
    155155
    156156<?php
    157157
    158 foreach($posts_columns as $column_name=>$column_display_name) {
     158foreach( (array) $posts_columns as $column_name=>$column_display_name) {
    159159
    160160        switch($column_name) {
    161161
     
    254254<ol id="the-list" class="commentlist">
    255255<?php
    256256$i = 0;
    257 foreach ($comments as $comment) {
     257foreach ( (array) $comments as $comment) {
    258258
    259259                ++$i; $class = '';
    260260                $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
  • wp-admin/options.php

     
    3232        check_admin_referer('update-options');
    3333
    3434        if (!$_POST['page_options']) {
    35                 foreach ($_POST as $key => $value) {
     35                foreach ( (array) $_POST as $key => $value) {
    3636                        $options[] = $key;
    3737                }
    3838        } else {
     
    4747        // Options that if not there have 0 value but need to be something like "closed"
    4848        $nonbools = array('default_ping_status', 'default_comment_status');
    4949        if ($options) {
    50                 foreach ($options as $option) {
     50                foreach ( (array) $options as $option) {
    5151                        $option = trim($option);
    5252                        $value = trim(stripslashes($_POST[$option]));
    5353                                if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
     
    9595<?php
    9696$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
    9797
    98 foreach ($options as $option) :
     98foreach ( (array) $options as $option) :
    9999        $value = wp_specialchars($option->option_value, 'single');
    100100        echo "
    101101<tr>
  • wp-admin/link.php

     
    4242                }
    4343
    4444                $deleted = 0;
    45                 foreach ($linkcheck as $link_id) {
     45                foreach ( (array) $linkcheck as $link_id) {
    4646                        $link_id = (int) $link_id;
    4747                       
    4848                        if ( wp_delete_link($link_id) )
  • wp-admin/profile.php

     
    122122      <th scope="row"><?php _e('Additional Capabilities:') ?></th>
    123123      <td><?php
    124124                        $output = '';
    125                         foreach($profileuser->caps as $cap => $value) {
     125                        foreach( (array) $profileuser->caps as $cap => $value) {
    126126                                if(!$wp_roles->is_role($cap)) {
    127127                                        if($output != '') $output .= ', ';
    128128                                        $output .= $value ? $cap : "Denied: {$cap}";
  • wp-admin/user-edit.php

     
    6363<div class="error">
    6464        <ul>
    6565        <?php
    66         foreach( $errors->get_error_messages() as $message )
     66        foreach( (array) $errors->get_error_messages() as $message )
    6767                echo "<li>$message</li>";
    6868        ?>
    6969        </ul>
     
    9090<?php
    9191// print_r($profileuser);
    9292echo '<select name="role">';
    93 foreach($wp_roles->role_names as $role => $name) {
     93foreach( (array) $wp_roles->role_names as $role => $name) {
    9494        $selected = ($profileuser->has_cap($role)) ? ' selected="selected"' : '';
    9595        echo "<option value=\"{$role}\"{$selected}>{$name}</option>";
    9696}
     
    180180      <th scope="row"><?php _e('Additional Capabilities:') ?></th>
    181181      <td><?php
    182182                        $output = '';
    183                         foreach($profileuser->caps as $cap => $value) {
     183                        foreach( (array) $profileuser->caps as $cap => $value) {
    184184                                if(!$wp_roles->is_role($cap)) {
    185185                                        if($output != '') $output .= ', ';
    186186                                        $output .= $value ? $cap : "Denied: {$cap}";
  • wp-admin/setup-config.php

     
    154154    require_once('../wp-includes/wp-db.php');
    155155        $handle = fopen('../wp-config.php', 'w');
    156156
    157     foreach ($configFile as $line_num => $line) {
     157    foreach ( (array) $configFile as $line_num => $line) {
    158158        switch (substr($line,0,16)) {
    159159            case "define('DB_NAME'":
    160160                fwrite($handle, str_replace("wordpress", $dbname, $line));
  • wp-admin/link-manager.php

     
    9595<?php $categories = get_categories("hide_empty=1&type=link"); ?>
    9696<select name="cat_id">
    9797<option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option>
    98 <?php foreach ($categories as $cat): ?>
     98<?php foreach ( (array) $categories as $cat): ?>
    9999<option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo wp_specialchars($cat->cat_name); ?>
    100100</option>
    101101<?php endforeach; ?>
     
    133133        $cat_id = '';
    134134$links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0");
    135135if ($links)
    136         foreach ($links as $link) {
     136        foreach ( (array) $links as $link) {
    137137                $link->link_name = wp_specialchars($link->link_name);
    138138                $link->link_description = wp_specialchars($link->link_description);
    139139                $link->link_url = wp_specialchars($link->link_url);
     
    161161        <?php
    162162
    163163                $cat_names = array();
    164                 foreach ($link->link_category as $category) {
     164                foreach ( (array) $link->link_category as $category) {
    165165                        $cat_name = get_the_category_by_ID($category);
    166166                        $cat_name = wp_specialchars($cat_name);
    167167                        if ( $cat_id != $category )
  • wp-admin/import.php

     
    3434
    3535<?php
    3636        $style = '';
    37         foreach ($importers as $id => $data) {
     37        foreach ( (array) $importers as $id => $data) {
    3838                $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
    3939                $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>";
    4040
  • wp-admin/options-writing.php

     
    3434<td><select name="default_category" id="default_category">
    3535<?php
    3636$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    37 foreach ($categories as $category) :
     37foreach ( (array) $categories as $category) :
    3838if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'";
    3939else $selected = '';
    4040echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     
    4646<th scope="row"><?php _e('Default bookmark category:') ?></th>
    4747<td><select name="default_link_category" id="default_link_category">
    4848<?php
    49 foreach ($categories as $category) :
     49foreach ( (array) $categories as $category) :
    5050if ($category->cat_ID == get_settings('default_link_category')) $selected = " selected='selected'";
    5151else $selected = '';
    5252echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     
    8383<td><select name="default_email_category" id="default_email_category">
    8484<?php
    8585//Alreay have $categories from default_category
    86 foreach ($categories as $category) :
     86foreach ( (array) $categories as $category) :
    8787if ($category->cat_ID == get_settings('default_email_category')) $selected = " selected='selected'";
    8888else $selected = '';
    8989echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
  • wp-admin/export.php

     
    4848        <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
    4949        <language><?php echo get_option('rss_language'); ?></language>
    5050        <?php do_action('rss2_head'); ?>
    51         <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
     51        <?php if ($posts) { foreach ( (array) $posts as $post) { start_wp(); ?>
    5252<item>
    5353<title><?php the_title_rss() ?></title>
    5454<link><?php permalink_single_rss() ?></link>
     
    7171$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
    7272if ( $postmeta ) {
    7373?>
    74 <?php foreach( $postmeta as $meta ) { ?>
     74<?php foreach( (array) $postmeta as $meta ) { ?>
    7575<wp:postmeta>
    7676<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
    7777<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
     
    8080<?php } ?>
    8181<?php
    8282$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
    83 if ( $comments ) { foreach ( $comments as $c ) { ?>
     83if ( $comments ) { foreach ( (array) $comments as $c ) { ?>
    8484<wp:comment>
    8585<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
    8686<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
  • wp-admin/plugin-editor.php

     
    8989if ($plugin_files) :
    9090?>
    9191  <ul>
    92 <?php foreach($plugin_files as $plugin_file) : ?>
     92<?php foreach( (array) $plugin_files as $plugin_file) : ?>
    9393                 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
    9494<?php endforeach; ?>
    9595  </ul>
  • wp-admin/upgrade-schema.php

     
    235235
    236236        // Delete unused options
    237237        $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
    238         foreach ($unusedoptions as $option) :
     238        foreach ( (array) $unusedoptions as $option) :
    239239                delete_option($option);
    240240        endforeach;
    241241
    242242        // Set up a few options not to load by default
    243243        $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
    244         foreach ($fatoptions as $fatoption) :
     244        foreach ( (array) $fatoptions as $fatoption) :
    245245                $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
    246246        endforeach;
    247247}
     
    342342
    343343function populate_roles_210() {
    344344        $roles = array('administrator', 'editor');
    345         foreach ($roles as $role) {
     345        foreach ( (array) $roles as $role) {
    346346                $role = get_role($role);
    347347                if ( empty($role) )
    348348                        continue;
  • wp-admin/themes.php

     
    5858$theme_names = array_keys($themes);
    5959natcasesort($theme_names);
    6060
    61 foreach ($theme_names as $theme_name) {
     61foreach ( (array) $theme_names as $theme_name) {
    6262        if ( $theme_name == $ct->name )
    6363                continue;
    6464        $template = $themes[$theme_name]['Template'];
     
    106106        $theme_names = array_keys($broken_themes);
    107107        natcasesort($theme_names);
    108108
    109         foreach ($theme_names as $theme_name) {
     109        foreach ( (array) $theme_names as $theme_name) {
    110110                $title = $broken_themes[$theme_name]['Title'];
    111111                $description = $broken_themes[$theme_name]['Description'];
    112112