Make WordPress Core

Ticket #2784: foreach_refresh.diff

File foreach_refresh.diff, 149.8 KB (added by markjaquith, 19 years ago)

Patch refresh for /trunk/

  • 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_option('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/post-template.php

     
    215215
    216216        if ( $keys = get_post_custom_keys() ) {
    217217                echo "<ul class='post-meta'>\n";
    218                 foreach ( $keys as $key ) {
     218                foreach ( (array) $keys as $key ) {
    219219                        $keyt = trim($key);
    220220                        if ( '_' == $keyt{0} )
    221221                                continue;
     
    375375
    376376                $types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime));
    377377                $exts = array('jpg', 'gif', 'png');
    378                 foreach ($types as $type) {
    379                         foreach ($exts as $ext) {
     378                foreach ( (array) $types as $type) {
     379                        foreach ( (array) $exts as $ext) {
    380380                                $src_file = "$icon_dir/$type.$ext";
    381381                                if ( file_exists($src_file) ) {
    382382                                        $src = "$icon_dir_uri/$type.$ext";
  • wp-includes/plugin.php

     
    99
    1010        // check that we don't already have the same filter at the same priority
    1111        if ( isset($wp_filter[$tag]["$priority"]) ) {
    12                 foreach($wp_filter[$tag]["$priority"] as $filter) {
     12                foreach( (array) $wp_filter[$tag]["$priority"] as $filter) {
    1313                        // uncomment if we want to match function AND accepted_args
    1414                        // if ( $filter == array($function, $accepted_args) ) {
    1515                        if ( $filter['function'] == $function_to_add ) {
     
    3535        if ( !isset($wp_filter[$tag]) ) {
    3636                return $string;
    3737        }
    38         foreach ($wp_filter[$tag] as $priority => $functions) {
     38        foreach ( (array) $wp_filter[$tag] as $priority => $functions) {
    3939                if ( !is_null($functions) ) {
    40                         foreach($functions as $function) {
     40                        foreach( (array) $functions as $function) {
    4141
    4242                                $function_name = $function['function'];
    4343                                $accepted_args = $function['accepted_args'];
     
    6060function merge_filters($tag) {
    6161        global $wp_filter;
    6262        if ( isset($wp_filter['all']) ) {
    63                 foreach ($wp_filter['all'] as $priority => $functions) {
     63                foreach ( (array) $wp_filter['all'] as $priority => $functions) {
    6464                        if ( isset($wp_filter[$tag][$priority]) )
    6565                                $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
    6666                        else
     
    8181        // rebuild the list of filters
    8282        if ( isset($wp_filter[$tag]["$priority"]) ) {
    8383                $new_function_list = array();
    84                 foreach($wp_filter[$tag]["$priority"] as $filter) {
     84                foreach( (array) $wp_filter[$tag]["$priority"] as $filter) {
    8585                        if ( $filter['function'] != $function_to_remove ) {
    8686                                $new_function_list[] = $filter;
    8787                        }
     
    114114        if ( !isset($wp_filter[$tag]) )
    115115                return;
    116116
    117         foreach ($wp_filter[$tag] as $priority => $functions) {
     117        foreach ( (array) $wp_filter[$tag] as $priority => $functions) {
    118118                if ( !is_null($functions) ) {
    119                         foreach($functions as $function) {
     119                        foreach( (array) $functions as $function) {
    120120
    121121                                $function_name = $function['function'];
    122122                                $accepted_args = $function['accepted_args'];
     
    142142        if ( !isset($wp_filter[$tag]) )
    143143                return;
    144144
    145         foreach ($wp_filter[$tag] as $priority => $functions) {
     145        foreach ( (array) $wp_filter[$tag] as $priority => $functions) {
    146146                if ( !is_null($functions) ) {
    147                         foreach($functions as $function) {
     147                        foreach( (array) $functions as $function) {
    148148
    149149                                $function_name = $function['function'];
    150150                                $accepted_args = $function['accepted_args'];
  • wp-includes/locale.php

     
    3535                $this->weekday_initial[__('Friday')]    = __('F_Friday_initial');
    3636                $this->weekday_initial[__('Saturday')]  = __('S_Saturday_initial');
    3737
    38                 foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
     38                foreach ( (array) $this->weekday_initial as $weekday_ => $weekday_initial_) {
    3939                        $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
    4040                }
    4141
     
    7777                $this->month_abbrev[__('November')] = __('Nov_November_abbreviation');
    7878                $this->month_abbrev[__('December')] = __('Dec_December_abbreviation');
    7979
    80                 foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
     80                foreach ( (array) $this->month_abbrev as $month_ => $month_abbrev_) {
    8181                        $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
    8282                }
    8383
     
    9898
    9999                include($locale_file);
    100100
    101                 foreach ( $this->locale_vars as $var ) {
     101                foreach ( (array) $this->locale_vars as $var ) {
    102102                        $this->$var = $$var;   
    103103                }
    104104        }
  • 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/bookmark.php

     
    4242        $category_name = '';
    4343                $inclinks = preg_split('/[\s,]+/',$include);
    4444                if ( count($inclinks) ) {
    45                         foreach ( $inclinks as $inclink ) {
     45                        foreach ( (array) $inclinks as $inclink ) {
    4646                                if (empty($inclusions))
    4747                                        $inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
    4848                                else
     
    5757        if ( !empty($exclude) ) {
    5858                $exlinks = preg_split('/[\s,]+/',$exclude);
    5959                if ( count($exlinks) ) {
    60                         foreach ( $exlinks as $exlink ) {
     60                        foreach ( (array) $exlinks as $exlink ) {
    6161                                if (empty($exclusions))
    6262                                        $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
    6363                                else
     
    7878        if ( !empty($category) ) {
    7979                $incategories = preg_split('/[\s,]+/',$category);
    8080                if ( count($incategories) ) {
    81                         foreach ( $incategories as $incat ) {
     81                        foreach ( (array) $incategories as $incat ) {
    8282                                if (empty($category_query))
    8383                                        $category_query = ' AND ( category_id = ' . intval($incat) . ' ';
    8484                                else
  • wp-includes/query.php

     
    360360                        , 'preview'
    361361                );
    362362
    363                 foreach ($keys as $key) {
     363                foreach ( (array) $keys as $key) {
    364364                        if ( !isset($array[$key]))
    365365                                $array[$key] = '';
    366366                }
     
    780780                        $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
    781781                        $cat_array = preg_split('/[,\s]+/', $q['cat']);
    782782                        $in_cats = $out_cats = $out_posts = '';
    783                         foreach ( $cat_array as $cat ) {
     783                        foreach ( (array) $cat_array as $cat ) {
    784784                                $cat = intval($cat);
    785785                                $in = strstr($cat, '-') ? false : true;
    786786                                $cat = trim($cat, '-');
     
    796796                        if ( strlen($out_cats) > 0 ) {
    797797                                $ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id IN ($out_cats)");
    798798                                if ( is_array($ids) && count($ids > 0) ) {
    799                                         foreach ( $ids as $id )
     799                                        foreach ( (array) $ids as $id )
    800800                                                $out_posts .= "$id, ";
    801801                                        $out_posts = substr($out_posts, 0, -2);
    802802                                }
     
    819819                        $cat_paths = '/' . trim(urldecode($q['category_name']), '/');
    820820                        $q['category_name'] = sanitize_title(basename($cat_paths));
    821821                        $cat_paths = explode('/', $cat_paths);
    822                         foreach($cat_paths as $pathdir)
     822                        foreach( (array) $cat_paths as $pathdir)
    823823                                $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    824824
    825825                        //if we don't match the entire hierarchy fallback on just matching the nicename
  • wp-includes/link-template.php

     
    272272        $sql_exclude_cats = '';
    273273        if ( !empty($excluded_categories) ) {
    274274                $blah = explode(' and ', $excluded_categories);
    275                 foreach ( $blah as $category ) {
     275                foreach ( (array) $blah as $category ) {
    276276                        $category = intval($category);
    277277                        $sql_cat_ids = " OR pc.category_ID = '$category'";
    278278                }
     
    305305        $sql_exclude_cats = '';
    306306        if ( !empty($excluded_categories) ) {
    307307                $blah = explode(' and ', $excluded_categories);
    308                 foreach ( $blah as $category ) {
     308                foreach ( (array) $blah as $category ) {
    309309                        $category = intval($category);
    310310                        $sql_cat_ids = " OR pc.category_ID = '$category'";
    311311                }
  • wp-includes/wp-db.php

     
    258258                } elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
    259259                        if ( $this->last_result ) {
    260260                                $i = 0;
    261                                 foreach( $this->last_result as $row ) {
     261                                foreach( (array) $this->last_result as $row ) {
    262262                                        $new_array[$i] = (array) $row;
    263263                                        if ( $output == ARRAY_N ) {
    264264                                                $new_array[$i] = array_values($new_array[$i]);
     
    281281                if ( $this->col_info ) {
    282282                        if ( $col_offset == -1 ) {
    283283                                $i = 0;
    284                                 foreach($this->col_info as $col ) {
     284                                foreach( (array) $this->col_info as $col ) {
    285285                                        $new_array[$i] = $col->{$info_type};
    286286                                        $i++;
    287287                                }
  • wp-includes/author-template.php

     
    188188        $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
    189189        $authors = $wpdb->get_results($query);
    190190
    191         foreach ( $authors as $author ) {
     191        foreach ( (array) $authors as $author ) {
    192192                $author = get_userdata( $author->ID );
    193193                $posts = get_usernumposts($author->ID);
    194194                $name = $author->nickname;
  • wp-includes/category.php

     
    3737                $exclude = '';
    3838                $incategories = preg_split('/[\s,]+/',$include);
    3939                if ( count($incategories) ) {
    40                         foreach ( $incategories as $incat ) {
     40                        foreach ( (array) $incategories as $incat ) {
    4141                                if (empty($inclusions))
    4242                                        $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';
    4343                                else
     
    5353        if ( !empty($exclude) ) {
    5454                $excategories = preg_split('/[\s,]+/',$exclude);
    5555                if ( count($excategories) ) {
    56                         foreach ( $excategories as $excat ) {
     56                        foreach ( (array) $excategories as $excat ) {
    5757                                if (empty($exclusions))
    5858                                        $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';
    5959                                else
     
    8989                $stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
    9090                                                        WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id");
    9191                global $cat_stamps;
    92                 foreach ($stamps as $stamp)
     92                foreach ( (array) $stamps as $stamp)
    9393                        $cat_stamps[$stamp->category_id] = $stamp->ts;
    9494                function stamp_cat($cat) {
    9595                        global $cat_stamps;
     
    105105
    106106        // Update category counts to include children.
    107107        if ( $hierarchical ) {
    108                 foreach ( $categories as $k => $category ) {
     108                foreach ( (array) $categories as $k => $category ) {
    109109                        $progeny = $category->category_count;
    110110                        if ( $children = _get_cat_children($category->cat_ID, $categories) ) {
    111                                 foreach ( $children as $child )
     111                                foreach ( (array) $children as $child )
    112112                                        $progeny += $child->category_count;
    113113                        }
    114114                        if ( !$progeny && $hide_empty )
     
    161161        $category_paths = '/' . trim($category_path, '/');
    162162        $leaf_path  = sanitize_title(basename($category_paths));
    163163        $category_paths = explode('/', $category_paths);
    164         foreach($category_paths as $pathdir)
     164        foreach( (array) $category_paths as $pathdir)
    165165                $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    166166
    167167        $categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'");
     
    169169        if ( empty($categories) )
    170170                return NULL;
    171171
    172         foreach ($categories as $category) {
     172        foreach ( (array) $categories as $category) {
    173173                $path = '/' . $leaf_path;
    174174                $curcategory = $category;
    175175                while ( ($curcategory->category_parent != 0) && ($curcategory->category_parent != $curcategory->cat_ID) ) {
     
    218218                return array();
    219219
    220220        $category_list = array();
    221         foreach ( $categories as $category ) {
     221        foreach ( (array) $categories as $category ) {
    222222                if ( $category->cat_ID == $category_id )
    223223                        continue;
    224224
  • 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;
     
    471471        function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
    472472                //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
    473473                $feedregex2 = '';
    474                 foreach ($this->feeds as $feed_name) {
     474                foreach ( (array) $this->feeds as $feed_name) {
    475475                        $feedregex2 .= $feed_name . '|';
    476476                }
    477477                $feedregex2 = '(' . trim($feedregex2, '|') .  ')/?$';
     
    486486                //build up an array of endpoint regexes to append => queries to append
    487487                if ($endpoints) {
    488488                        $ep_query_append = array ();
    489                         foreach ($this->endpoints as $endpoint) {
     489                        foreach ( (array) $this->endpoints as $endpoint) {
    490490                                //match everything after the endpoint name, but allow for nothing to appear there
    491491                                $epmatch = $endpoint[1] . '(/(.*))?/?$';
    492492                                //this will be appended on to the rest of the query for each dir
     
    600600                               
    601601                                //do endpoints
    602602                                if ($endpoints) {
    603                                         foreach ($ep_query_append as $regex => $ep) {
     603                                        foreach ( (array) $ep_query_append as $regex => $ep) {
    604604                                                //add the endpoints on if the mask fits
    605605                                                if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
    606606                                                        $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
     
    640640                                        $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
    641641                                       
    642642                                        //do endpoints for attachments
    643                                         if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
     643                                        if ($endpoint) { foreach ( (array) $ep_query_append as $regex => $ep) {
    644644                                                if ($ep[0] & EP_ATTACHMENT) {
    645645                                                        $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
    646646                                                        $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
     
    678678                        } //if($num_toks)
    679679                        //add the rules for this dir to the accumulating $post_rewrite
    680680                        $post_rewrite = array_merge($rewrite, $post_rewrite);
    681                 } //foreach ($dir)
     681                } //foreach ( (array) $dir)
    682682                return $post_rewrite; //the finished rules. phew!
    683683        }
    684684
     
    769769                $rules .= "RewriteBase $home_root\n";
    770770               
    771771                //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
    772                 foreach ($this->non_wp_rules as $match => $query) {
     772                foreach ( (array) $this->non_wp_rules as $match => $query) {
    773773                        // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    774774                        $match = str_replace('.+?', '.+', $match);
    775775
     
    790790                                "RewriteCond %{REQUEST_FILENAME} -d\n" .
    791791                                "RewriteRule ^.*$ - [S=$num_rules]\n";
    792792
    793                         foreach ($rewrite as $match => $query) {
     793                        foreach ( (array) $rewrite as $match => $query) {
    794794                                // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    795795                                $match = str_replace('.+?', '.+', $match);
    796796
  • wp-includes/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/post.php

     
    2929        $children = $wpdb->get_results($query);
    3030
    3131        if ( $children ) {
    32                 foreach ( $children as $key => $child ) {
     32                foreach ( (array) $children as $key => $child ) {
    3333                        $post_cache[$child->ID] =& $children[$key];
    3434                        $kids[$child->ID] =& $children[$key];
    3535                }
     
    4040        if ( $output == OBJECT ) {
    4141                return $kids;
    4242        } elseif ( $output == ARRAY_A ) {
    43                 foreach ( $kids as $kid )
     43                foreach ( (array) $kids as $kid )
    4444                        $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
    4545                return $weeuns;
    4646        } elseif ( $output == ARRAY_N ) {
    47                 foreach ( $kids as $kid )
     47                foreach ( (array) $kids as $kid )
    4848                        $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
    4949                return $babes;
    5050        } else {
     
    173173                $incposts = preg_split('/[\s,]+/',$include);
    174174                $numberposts = count($incposts);  // only the number of posts included
    175175                if ( count($incposts) ) {
    176                         foreach ( $incposts as $incpost ) {
     176                        foreach ( (array) $incposts as $incpost ) {
    177177                                if (empty($inclusions))
    178178                                        $inclusions = ' AND ( ID = ' . intval($incpost) . ' ';
    179179                                else
     
    188188        if ( !empty($exclude) ) {
    189189                $exposts = preg_split('/[\s,]+/',$exclude);
    190190                if ( count($exposts) ) {
    191                         foreach ( $exposts as $expost ) {
     191                        foreach ( (array) $exposts as $expost ) {
    192192                                if (empty($exclusions))
    193193                                        $exclusions = ' AND ( ID <> ' . intval($expost) . ' ';
    194194                                else
     
    261261                $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
    262262AND meta_key = '$key' AND meta_value = '$value'");
    263263                $cache_key = $post_meta_cache['$post_id'][$key];
    264                 if ($cache_key) foreach ( $cache_key as $index => $data )
     264                if ($cache_key) foreach ( (array) $cache_key as $index => $data )
    265265                        if ( $data == $value )
    266266                                unset($post_meta_cache['$post_id'][$key][$index]);
    267267        }
     
    286286
    287287        $values = array();
    288288        if ( $metalist ) {
    289                 foreach ($metalist as $metarow) {
     289                foreach ( (array) $metalist as $metarow) {
    290290                        $values[] = $metarow[0];
    291291                }
    292292        }
     
    325325meta_key = '$key' AND post_id = '$post_id'");
    326326                $cache_key = $post_meta_cache['$post_id'][$key];
    327327                if ( !empty($cache_key) )
    328                         foreach ($cache_key as $index => $data)
     328                        foreach ( (array) $cache_key as $index => $data)
    329329                                $post_meta_cache['$post_id'][$key][$index] = $original_value;
    330330        } else {
    331331                $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
    332332meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
    333333                $cache_key = $post_meta_cache['$post_id'][$key];
    334334                if ( !empty($cache_key) )
    335                         foreach ($cache_key as $index => $data)
     335                        foreach ( (array) $cache_key as $index => $data)
    336336                                if ( $data == $original_prev )
    337337                                        $post_meta_cache['$post_id'][$key][$index] = $original_value;
    338338        }
     
    353353        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) ) {
    354354                // Change from flat structure to hierarchical:
    355355                $post_meta_cache = array();
    356                 foreach ( $meta_list as $metarow ) {
     356                foreach ( (array) $meta_list as $metarow ) {
    357357                        $mpid = $metarow['post_id'];
    358358                        $mkey = $metarow['meta_key'];
    359359                        $mval = $metarow['meta_value'];
     
    404404        if ( 'publish' == $post->post_status && 'post' == $post->post_type ) {
    405405                $categories = wp_get_post_categories($post->ID);
    406406                if( is_array( $categories ) ) {
    407                         foreach ( $categories as $cat_id ) {
     407                        foreach ( (array) $categories as $cat_id ) {
    408408                                $wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'");
    409409                                wp_cache_delete($cat_id, 'category');
    410410                        }
     
    782782        $delete_cats = array_diff($old_categories,$post_categories);
    783783
    784784        if ($delete_cats) {
    785                 foreach ($delete_cats as $del) {
     785                foreach ( (array) $delete_cats as $del) {
    786786                        $wpdb->query("
    787787                                DELETE FROM $wpdb->post2cat
    788788                                WHERE category_id = $del
     
    795795        $add_cats = array_diff($post_categories, $old_categories);
    796796
    797797        if ($add_cats) {
    798                 foreach ($add_cats as $new_cat) {
     798                foreach ( (array) $add_cats as $new_cat) {
    799799                        if ( !empty($new_cat) )
    800800                                $wpdb->query("
    801801                                        INSERT INTO $wpdb->post2cat (post_id, category_id)
     
    805805
    806806        // Update category counts.
    807807        $all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
    808         foreach ( $all_affected_cats as $cat_id ) {
     808        foreach ( (array) $all_affected_cats as $cat_id ) {
    809809                $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'");
    810810                $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
    811811                wp_cache_delete($cat_id, 'category');
     
    834834        if ( !is_array( $custom_fields ) )
    835835                return $pung;
    836836
    837         foreach ( $custom_fields as $key => $val ) {
     837        foreach ( (array) $custom_fields as $key => $val ) {
    838838                if ( 'enclosure' != $key || !is_array( $val ) )
    839839                        continue;
    840                 foreach( $val as $enc ) {
     840                foreach( (array) $val as $enc ) {
    841841                        $enclosure = split( "\n", $enc );
    842842                        $pung[] = trim( $enclosure[ 0 ] );
    843843                }
     
    882882                }
    883883
    884884                $trackback_urls = explode(',', $tb_list);
    885                 foreach($trackback_urls as $tb_url) {
     885                foreach( (array) $trackback_urls as $tb_url) {
    886886                    $tb_url = trim($tb_url);
    887887                    trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
    888888                }
     
    958958        $page_paths = '/' . trim($page_path, '/');
    959959        $leaf_path  = sanitize_title(basename($page_paths));
    960960        $page_paths = explode('/', $page_paths);
    961         foreach($page_paths as $pathdir)
     961        foreach( (array) $page_paths as $pathdir)
    962962                $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    963963
    964964        $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'");
     
    966966        if ( empty($pages) )
    967967                return NULL;
    968968
    969         foreach ($pages as $page) {
     969        foreach ( (array) $pages as $page) {
    970970                $path = '/' . $leaf_path;
    971971                $curpage = $page;
    972972                while ($curpage->post_parent != 0) {
     
    988988                $pages = &$page_cache;
    989989
    990990        $page_list = array();
    991         foreach ( $pages as $page ) {
     991        foreach ( (array) $pages as $page ) {
    992992                if ( $page->post_parent == $page_id ) {
    993993                        $page_list[] = $page;
    994994                        if ( $children = get_page_children($page->ID, $pages) )
     
    10021002//immediately follow their parents
    10031003function get_page_hierarchy($posts, $parent = 0) {
    10041004        $result = array ( );
    1005         if ($posts) { foreach ($posts as $post) {
     1005        if ($posts) { foreach ( (array) $posts as $post) {
    10061006                if ($post->post_parent == $parent) {
    10071007                        $result[$post->ID] = $post->post_name;
    10081008                        $children = get_page_hierarchy($posts, $post->ID);
     
    10491049                $meta_value = '';
    10501050                $incpages = preg_split('/[\s,]+/',$include);
    10511051                if ( count($incpages) ) {
    1052                         foreach ( $incpages as $incpage ) {
     1052                        foreach ( (array) $incpages as $incpage ) {
    10531053                                if (empty($inclusions))
    10541054                                        $inclusions = ' AND ( ID = ' . intval($incpage) . ' ';
    10551055                                else
     
    10641064        if ( !empty($exclude) ) {
    10651065                $expages = preg_split('/[\s,]+/',$exclude);
    10661066                if ( count($expages) ) {
    1067                         foreach ( $expages as $expage ) {
     1067                        foreach ( (array) $expages as $expage ) {
    10681068                                if (empty($exclusions))
    10691069                                        $exclusions = ' AND ( ID <> ' . intval($expage) . ' ';
    10701070                                else
     
    10801080                $post_authors = preg_split('/[\s,]+/',$authors);
    10811081               
    10821082                if ( count($post_authors) ) {
    1083                         foreach ( $post_authors as $post_author ) {
     1083                        foreach ( (array) $post_authors as $post_author ) {
    10841084                                //Do we have an author id or an author login?
    10851085                                if ( 0 == intval($post_author) ) {
    10861086                                        $post_author = get_userdatabylogin($post_author);
     
    11361136
    11371137        if ($posts) {
    11381138
    1139                 foreach ($posts as $id => $post) {
     1139                foreach ( (array) $posts as $id => $post) {
    11401140
    11411141                        // URL => page name
    11421142                        $uri = get_page_uri($id);
    11431143                        $attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$id'");
    11441144                        if ( $attachments ) {
    1145                                 foreach ( $attachments as $attachment ) {
     1145                                foreach ( (array) $attachments as $attachment ) {
    11461146                                        $attach_uri = get_page_uri($attachment->ID);
    11471147                                        $page_attachment_uris[$attach_uri] = $attachment->ID;
    11481148                                }
  • wp-includes/general-template.php

     
    332332                $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);
    333333                if ( $arcresults ) {
    334334                        $afterafter = $after;
    335                         foreach ( $arcresults as $arcresult ) {
     335                        foreach ( (array) $arcresults as $arcresult ) {
    336336                                $url    = get_month_link($arcresult->year,      $arcresult->month);
    337337                                $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year);
    338338                                if ( $show_post_count )
     
    344344         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts WHERE post_type ='post' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit);
    345345                if ($arcresults) {
    346346            $afterafter = $after;
    347             foreach ($arcresults as $arcresult) {
     347            foreach ( (array) $arcresults as $arcresult) {
    348348                            $url = get_year_link($arcresult->year);
    349349                $text = sprintf('%d', $arcresult->year);
    350350                                if ($show_post_count)
     
    356356                $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit);
    357357                if ( $arcresults ) {
    358358                        $afterafter = $after;
    359                         foreach ( $arcresults as $arcresult ) {
     359                        foreach ( (array) $arcresults as $arcresult ) {
    360360                                $url    = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    361361                                $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    362362                                $text = mysql2date($archive_day_date_format, $date);
     
    371371                $arc_w_last = '';
    372372                $afterafter = $after;
    373373                if ( $arcresults ) {
    374                                 foreach ( $arcresults as $arcresult ) {
     374                                foreach ( (array) $arcresults as $arcresult ) {
    375375                                        if ( $arcresult->week != $arc_w_last ) {
    376376                                                $arc_year = $arcresult->yr;
    377377                                                $arc_w_last = $arcresult->week;
     
    390390                ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC ";
    391391                $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY $orderby $limit");
    392392                if ( $arcresults ) {
    393                         foreach ( $arcresults as $arcresult ) {
     393                        foreach ( (array) $arcresults as $arcresult ) {
    394394                                if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
    395395                                        $url  = get_permalink($arcresult);
    396396                                        $arc_title = $arcresult->post_title;
     
    480480                $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
    481481        }
    482482
    483         foreach ( $myweek as $wd ) {
     483        foreach ( (array) $myweek as $wd ) {
    484484                $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
    485485                echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
    486486        }
     
    524524                AND post_type = 'post' AND post_status = 'publish'
    525525                AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    526526        if ( $dayswithposts ) {
    527                 foreach ( $dayswithposts as $daywith ) {
     527                foreach ( (array) $dayswithposts as $daywith ) {
    528528                        $daywithpost[] = $daywith[0];
    529529                }
    530530        } else {
     
    547547                ."AND post_type = 'post' AND post_status = 'publish'"
    548548        );
    549549        if ( $ak_post_titles ) {
    550                 foreach ( $ak_post_titles as $ak_post_title ) {
     550                foreach ( (array) $ak_post_titles as $ak_post_title ) {
    551551                                if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
    552552                                        $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
    553553                                if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
     
    595595function allowed_tags() {
    596596        global $allowedtags;
    597597        $allowed = '';
    598         foreach ( $allowedtags as $tag => $attributes ) {
     598        foreach ( (array) $allowedtags as $tag => $attributes ) {
    599599                $allowed .= '<'.$tag;
    600600                if ( 0 < count($attributes) ) {
    601                         foreach ( $attributes as $attribute => $limits ) {
     601                        foreach ( (array) $attributes as $attribute => $limits ) {
    602602                                $allowed .= ' '.$attribute.'=""';
    603603                        }
    604604                }
  • 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);
     
    4848                $returnData = array();
    4949                $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
    5050
    51                 foreach($dataArr as $dstr) {
     51                foreach( (array) $dataArr as $dstr) {
    5252                        $matches = array();
    5353
    5454                        // Skip this line.
     
    7878                $returnData = array();
    7979                $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
    8080
    81                 foreach($dataArr as $dstr) {
     81                foreach( (array) $dataArr as $dstr) {
    8282                        $matches = array();
    8383
    8484                        // 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

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

     
    2828
    2929                $this->role_objects = array();
    3030                $this->role_names =  array();
    31                 foreach ($this->roles as $role => $data) {
     31                foreach ( (array) $this->roles as $role => $data) {
    3232                        $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']);
    3333                        $this->role_names[$role] = $this->roles[$role]['name'];
    3434                }
     
    207207        }
    208208
    209209        function set_role($role) {
    210                 foreach($this->roles as $oldrole)
     210                foreach( (array) $this->roles as $oldrole)
    211211                        unset($this->caps[$oldrole]);
    212212                if ( !empty($role) ) {
    213213                        $this->caps[$role] = true;
     
    265265                $caps = call_user_func_array('map_meta_cap', $args);
    266266                // Must have ALL requested caps
    267267                $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
    268                 foreach ($caps as $cap) {
     268                foreach ( (array) $caps as $cap) {
    269269                        //echo "Checking cap $cap<br/>";
    270270                        if(empty($capabilities[$cap]) || !$capabilities[$cap])
    271271                                return false;
  • wp-includes/classes.php

     
    8585
    8686                        // Look for matches.
    8787                        $request_match = $request;
    88                         foreach ($rewrite as $match => $query) {
     88                        foreach ( (array) $rewrite as $match => $query) {
    8989                                // If the requesting file is the anchor of the match, prepend it
    9090                                // to the path info.
    9191                                if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) {
     
    150150                                $this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
    151151                }
    152152
    153                 foreach ($this->private_query_vars as $var) {
     153                foreach ( (array) $this->private_query_vars as $var) {
    154154                        if (isset($this->extra_query_vars[$var]))
    155155                                $this->query_vars[$var] = $this->extra_query_vars[$var];
    156156                        elseif (isset($GLOBALS[$var]) && '' != $GLOBALS[$var])
     
    227227        function register_globals() {
    228228                global $wp_query;
    229229                // Extract updated query vars back into global namespace.
    230                 foreach ($wp_query->query_vars as $key => $value) {
     230                foreach ( (array) $wp_query->query_vars as $key => $value) {
    231231                        $GLOBALS[$key] = $value;
    232232                }
    233233
     
    314314                // Return all messages if no code specified.
    315315                if ( empty($code) ) {
    316316                        $all_messages = array();
    317                         foreach ( $this->errors as $code => $messages )
     317                        foreach ( (array) $this->errors as $code => $messages )
    318318                                $all_messages = array_merge($all_messages, $messages);
    319319
    320320                        return $all_messages;
     
    390390       
    391391                $flat = ($to_depth == -1) ? true : false;
    392392       
    393                 foreach ( $elements as $element ) {
     393                foreach ( (array) $elements as $element ) {
    394394                        // If flat, start and end the element and skip the level checks.
    395395                        if ( $flat) {
    396396                                // Start the element.
     
    671671
    672672                $response = '';
    673673                if ( is_wp_error($data) )
    674                         foreach ( $data->get_error_codes() as $code )
     674                        foreach ( (array) $data->get_error_codes() as $code )
    675675                                $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>";
    676676                else
    677677                        $response = "<response_data><![CDATA[$data]]></response_data>";
    678678
    679679                $s = '';
    680680                if ( (array) $supplemental )
    681                         foreach ( $supplemental as $k => $v )
     681                        foreach ( (array) $supplemental as $k => $v )
    682682                                $s .= "<$k><![CDATA[$v]]></$k>";
    683683
    684684                if ( false === $action )
     
    699699        function send() {
    700700                header('Content-type: text/xml');
    701701                echo "<?xml version='1.0' standalone='yes'?><wp_ajax>";
    702                 foreach ( $this->responses as $response )
     702                foreach ( (array) $this->responses as $response )
    703703                        echo $response;
    704704                echo '</wp_ajax>';
    705705                die();
  • 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

     
    6767        $key = md5(serialize($args));
    6868        if ( empty($crons) )
    6969                return false;
    70         foreach ( $crons as $timestamp => $cron ) {
     70        foreach ( (array) $crons as $timestamp => $cron ) {
    7171                if ( isset( $cron[$hook][$key] ) )
    7272                        return $timestamp;
    7373        }
     
    106106                return;
    107107
    108108        $schedules = wp_get_schedules();
    109         foreach ( $crons as $timestamp => $cronhooks ) {
     109        foreach ( (array) $crons as $timestamp => $cronhooks ) {
    110110                if ( $timestamp > time() ) break;
    111                 foreach ( $cronhooks as $hook => $args ) {
     111                foreach ( (array) $cronhooks as $hook => $args ) {
    112112                        if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
    113113                                continue;
    114114                        spawn_cron();
     
    130130        $key = md5(serialize($args));
    131131        if ( empty($crons) )
    132132                return false;
    133         foreach ( $crons as $timestamp => $cron ) {
     133        foreach ( (array) $crons as $timestamp => $cron ) {
    134134                if ( isset( $cron[$hook][$key] ) )
    135135                        return $cron[$hook][$key]['schedule'];
    136136        }
     
    165165
    166166        $new_cron = array();
    167167
    168         foreach ($cron as $timestamp => $hooks) {
    169                 foreach ( $hooks as $hook => $args ) {
     168        foreach ( (array) $cron as $timestamp => $hooks) {
     169                foreach ( (array) $hooks as $hook => $args ) {
    170170                        $key = md5(serialize($args['args']));
    171171                        $new_cron[$timestamp][$hook][$key] = $args;
    172172                }
  • wp-includes/theme.php

     
    129129
    130130        sort($theme_files);
    131131
    132         foreach($theme_files as $theme_file) {
     132        foreach( (array) $theme_files as $theme_file) {
    133133                if ( ! is_readable("$theme_root/$theme_file") ) {
    134134                        $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
    135135                        continue;
     
    222222        // Resolve theme dependencies.
    223223        $theme_names = array_keys($themes);
    224224
    225         foreach ($theme_names as $theme_name) {
     225        foreach ( (array) $theme_names as $theme_name) {
    226226                $themes[$theme_name]['Parent Theme'] = '';
    227227                if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
    228                         foreach ($theme_names as $parent_theme_name) {
     228                        foreach ( (array) $theme_names as $parent_theme_name) {
    229229                                if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
    230230                                        $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
    231231                                        break;
     
    256256        $current_theme = 'WordPress Default';
    257257
    258258        if ( $themes ) {
    259                 foreach ($theme_names as $theme_name) {
     259                foreach ( (array) $theme_names as $theme_name) {
    260260                        if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
    261261                                        $themes[$theme_name]['Template'] == $current_template ) {
    262262                                $current_theme = $themes[$theme_name]['Name'];
  • 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
     
    225225        do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
    226226
    227227        if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) {
    228                 foreach ($chars[1] as $char) {
     228                foreach ( (array) $chars[1] as $char) {
    229229                        // If it's an encoded char in the normal ASCII set, reject
    230230                        if ( 38 == $char )
    231231                                continue; // Unless it's &
     
    239239                return false; // If moderation keys are empty
    240240        $words = explode("\n", $mod_keys );
    241241
    242         foreach ($words as $word) {
     242        foreach ( (array) $words as $word) {
    243243                $word = trim($word);
    244244
    245245                // Skip empty lines
     
    439439        $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    440440
    441441        // Escape data pulled from DB.
    442         foreach ($comment as $key => $value)
     442        foreach ( (array) $comment as $key => $value)
    443443                $comment[$key] = $wpdb->escape($value);
    444444
    445445        // Merge old and new fields with new fields overwriting old ones.
     
    594594        // Do Trackbacks
    595595        $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
    596596        if ( is_array($trackbacks) ) {
    597                 foreach ( $trackbacks as $trackback ) {
     597                foreach ( (array) $trackbacks as $trackback ) {
    598598                        do_trackbacks($trackback->ID);
    599599                }
    600600        }
     
    628628        $post_title = apply_filters('the_title', $post->post_title);
    629629        $post_title = strip_tags($post_title);
    630630
    631         if ($to_ping) : foreach ($to_ping as $tb_ping) :
     631        if ($to_ping) : foreach ( (array) $to_ping as $tb_ping) :
    632632                $tb_ping = trim($tb_ping);
    633633                if ( !in_array($tb_ping, $pinged) ) {
    634634                        trackback($tb_ping, $post_title, $excerpt, $post_id);
     
    645645        $services = trim($services);
    646646        if ( '' != $services ) {
    647647                $services = explode("\n", $services);
    648                 foreach ($services as $service) {
     648                foreach ( (array) $services as $service) {
    649649                        weblog_ping($service);
    650650                }
    651651        }
     
    689689        // http://dummy-weblog.org/post.php
    690690        // We don't wanna ping first and second types, even if they have a valid <link/>
    691691
    692         foreach($post_links_temp[0] as $link_test) :
     692        foreach( (array) $post_links_temp[0] as $link_test) :
    693693                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
    694694                                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
    695695                        $test = parse_url($link_test);
     
    702702
    703703        do_action_ref_array('pre_ping',  array(&$post_links, &$pung));
    704704
    705         foreach ($post_links as $pagelinkedto){
     705        foreach ( (array) $post_links as $pagelinkedto){
    706706                debug_fwrite($log, "Processing -- $pagelinkedto\n");
    707707                $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
    708708
  • wp-includes/pluggable.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;
     
    242242if ( !function_exists('check_ajax_referer') ) :
    243243function check_ajax_referer() {
    244244        $cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
    245         foreach ( $cookie as $tasty ) {
     245        foreach ( (array) $cookie as $tasty ) {
    246246                if ( false !== strpos($tasty, USER_COOKIE) )
    247247                        $user = substr(strstr($tasty, '='), 1);
    248248                if ( false !== strpos($tasty, PASS_COOKIE) )
  • wp-includes/feed.php

     
    131131function get_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>";
     
    155155                while( list( $key, $val ) = each( $custom_fields ) ) {
    156156                        if( $key == 'enclosure' ) {
    157157                                if (is_array($val)) {
    158                                         foreach($val as $enc) {
     158                                        foreach( (array) $val as $enc) {
    159159                                                $enclosure = split( "\n", $enc );
    160160                                                print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
    161161                                        }
  • 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;
     
    405405{
    406406        $outarray = array ();
    407407
    408         foreach ($inarray as $inkey => $inval) {
     408        foreach ( (array) $inarray as $inkey => $inval) {
    409409                $outkey = strtolower($inkey);
    410410                $outarray[$outkey] = array ();
    411411
    412                 foreach ($inval as $inkey2 => $inval2) {
     412                foreach ( (array) $inval as $inkey2 => $inval2) {
    413413                        $outkey2 = strtolower($inkey2);
    414414                        $outarray[$outkey][$outkey2] = $inval2;
    415415                } # foreach $inval
     
    460460        $string2 = strtolower($string2);
    461461
    462462        $allowed = false;
    463         foreach ($allowed_protocols as $one_protocol)
     463        foreach ( (array) $allowed_protocols as $one_protocol)
    464464                if (strtolower($one_protocol) == $string2) {
    465465                        $allowed = true;
    466466                        break;
  • 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/rss.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/functions.php

     
    206206        }
    207207        $wpdb->show_errors();
    208208
    209         foreach ($options as $option) {
     209        foreach ( (array) $options as $option) {
    210210                // "When trying to design a foolproof system,
    211211                //  never underestimate the ingenuity of the fools :)" -- Dougal
    212212                if ( 'siteurl' == $option->option_name )
     
    387387        debug_fwrite($log, 'Post contents:');
    388388        debug_fwrite($log, $content."\n");
    389389
    390         foreach($post_links_temp[0] as $link_test) :
     390        foreach( (array) $post_links_temp[0] as $link_test) :
    391391                if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
    392392                        $test = parse_url($link_test);
    393393                        if ( isset($test['query']) )
     
    397397                endif;
    398398        endforeach;
    399399
    400         foreach ($post_links as $url) :
     400        foreach ( (array) $post_links as $url) :
    401401                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%')") ) {
    402402                        if ( $headers = wp_get_http_headers( $url) ) {
    403403                                $len = (int) $headers['content-length'];
     
    515515        if ( empty($dogs) )
    516516                return;
    517517
    518         foreach ($dogs as $catt)
     518        foreach ( (array) $dogs as $catt)
    519519                $category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
    520520}
    521521
     
    541541        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) ) {
    542542                // Change from flat structure to hierarchical:
    543543                $post_meta_cache = array();
    544                 foreach ($meta_list as $metarow) {
     544                foreach ( (array) $meta_list as $metarow) {
    545545                        $mpid = $metarow['post_id'];
    546546                        $mkey = $metarow['meta_key'];
    547547                        $mval = $metarow['meta_value'];
     
    623623                $qs[func_get_arg(0)] = func_get_arg(1);
    624624        }
    625625
    626         foreach($qs as $k => $v) {
     626        foreach( (array) $qs as $k => $v) {
    627627                if ( $v != '' ) {
    628628                        if ( $ret != '' )
    629629                                $ret .= '&';
     
    658658function add_magic_quotes($array) {
    659659        global $wpdb;
    660660
    661         foreach ($array as $k => $v) {
     661        foreach ( (array) $array as $k => $v) {
    662662                if ( is_array($v) ) {
    663663                        $array[$k] = add_magic_quotes($v);
    664664                } else {
     
    990990        $type = false;
    991991        $ext = false;
    992992
    993         foreach ($mimes as $ext_preg => $mime_match) {
     993        foreach ( (array) $mimes as $ext_preg => $mime_match) {
    994994                $ext_preg = '!\.(' . $ext_preg . ')$!i';
    995995                if ( preg_match($ext_preg, $filename, $ext_matches) ) {
    996996                        $type = $mime_match;
  • wp-includes/script-loader.php

     
    8888                if ( ! $handles = (array) $handles )
    8989                        return array();
    9090                $return = array();
    91                 foreach ( $handles as $handle ) {
     91                foreach ( (array) $handles as $handle ) {
    9292                        $handle = explode('?', $handle);
    9393                        if ( isset($handle[1]) )
    9494                                $this->args[$handle[0]] = $handle[1];
  • wp-includes/vars.php

     
    8686
    8787
    8888// generates smilies' search & replace arrays
    89 foreach($wpsmiliestrans as $smiley => $img) {
     89foreach( (array) $wpsmiliestrans as $smiley => $img) {
    9090        $wp_smiliessearch[] = $smiley;
    9191        $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
    9292        $wp_smiliesreplace[] = " <img src='" . get_option('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
  • wp-includes/user.php

     
    9494                        return '';
    9595        }
    9696
    97         foreach ($metas as $index => $meta) {
     97        foreach ( (array) $metas as $index => $meta) {
    9898                @ $value = unserialize($meta->meta_value);
    9999                if ( $value === FALSE )
    100100                        $value = $meta->meta_value;
  • wp-includes/category-template.php

     
    77        $chain = '';
    88
    99        $cat_ids = get_all_category_ids();
    10         foreach ( $cat_ids as $cat_id ) {
     10        foreach ( (array) $cat_ids as $cat_id ) {
    1111                if ( $cat_id == $id)
    1212                        continue;
    1313
     
    9292        $thelist = '';
    9393        if ( '' == $separator ) {
    9494                $thelist .= '<ul class="post-categories">';
    95                 foreach ( $categories as $category ) {
     95                foreach ( (array) $categories as $category ) {
    9696                        $thelist .= "\n\t<li>";
    9797                        switch ( strtolower($parents) ) {
    9898                                case 'multiple':
     
    114114                $thelist .= '</ul>';
    115115        } else {
    116116                $i = 0;
    117                 foreach ( $categories as $category ) {
     117                foreach ( (array) $categories as $category ) {
    118118                        if ( 0 < $i )
    119119                                $thelist .= $separator . ' ';
    120120                        switch ( strtolower($parents) ) {
  • 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_categories($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_categories($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_categories($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_categories(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 ) ) {
     
    12761276                }
    12771277
    12781278                $pingbacks = array();
    1279                 foreach($comments as $comment) {
     1279                foreach( (array) $comments as $comment) {
    12801280                        if ( 'pingback' == $comment->comment_type )
    12811281                                $pingbacks[] = $comment->comment_author_url;
    12821282                }
  • wp-mail.php

     
    2828        $bodysignal = 0;
    2929        $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
    3030                                         'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
    31         foreach ($message as $line) :
     31        foreach ( (array) $message as $line) :
    3232                if (strlen($line) < 3) $bodysignal = 1;
    3333
    3434                if ($bodysignal) {
  • 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-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">
     
    3939
    4040<?php if ($comments) { ?>
    4141<ol id="commentlist">
    42 <?php foreach ($comments as $comment) { ?>
     42<?php foreach ( (array) $comments as $comment) { ?>
    4343        <li id="comment-<?php comment_ID() ?>">
    4444        <?php comment_text() ?>
    4545        <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/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">
     
    3939
    4040<?php if ($comments) { ?>
    4141<ol id="commentlist">
    42 <?php foreach ($comments as $comment) { ?>
     42<?php foreach ( (array) $comments as $comment) { ?>
    4343        <li id="comment-<?php comment_ID() ?>">
    4444        <?php comment_text() ?>
    4545        <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-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}
     
    190190if ( get_option('active_plugins') ) {
    191191        $current_plugins = get_option('active_plugins');
    192192        if ( is_array($current_plugins) ) {
    193                 foreach ($current_plugins as $plugin) {
     193                foreach ( (array) $current_plugins as $plugin) {
    194194                        if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
    195195                                include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
    196196                }
  • wp-cron.php

     
    1010$keys = array_keys($crons);
    1111if (!is_array($crons) || $keys[0] > time())
    1212        return;
    13 foreach ($crons as $timestamp => $cronhooks) {
     13foreach ( (array) $crons as $timestamp => $cronhooks) {
    1414        if ($timestamp > time()) break;
    15         foreach ($cronhooks as $hook => $keys) {
    16                 foreach ($keys as $key => $args) {
     15        foreach ( (array) $cronhooks as $hook => $keys) {
     16                foreach ( (array) $keys as $key => $args) {
    1717                        do_action_ref_array($hook, $args['args']);
    1818                        $schedule = $args['schedule'];
    1919                        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/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

     
    132132
    133133        $userids = $_POST['users'];
    134134        $update = 'promote';
    135         foreach($userids as $id) {
     135        foreach( (array) $userids as $id) {
    136136                if ( ! current_user_can('edit_user', $id) )
    137137                        wp_die(__('You can&#8217;t edit that user.'));
    138138                // The new role of the current user must also have edit_users caps
     
    274274        $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']);
    275275
    276276        // Make the user objects
    277         foreach ( $wp_user_search->get_results() as $userid ) {
     277        foreach ( (array) $wp_user_search->get_results() as $userid ) {
    278278                $tmp_user = new WP_User($userid);
    279279                $roles = $tmp_user->roles;
    280280                $role = array_shift($roles);
     
    319319        <div class="error">
    320320                <ul>
    321321                <?php
    322                         foreach ( $errors->get_error_messages() as $message )
     322                        foreach ( (array) $errors->get_error_messages() as $message )
    323323                                echo "<li>$message</li>";
    324324                ?>
    325325                </ul>
     
    348348                <div class="error">
    349349                        <ul>
    350350                        <?php
    351                                 foreach ( $wp_user_search->search_errors->get_error_messages() as $message )
     351                                foreach ( (array) $wp_user_search->search_errors->get_error_messages() as $message )
    352352                                        echo "<li>$message</li>";
    353353                        ?>
    354354                        </ul>
     
    372372<?php wp_nonce_field('bulk-users') ?>
    373373<table class="widefat">
    374374<?php
    375 foreach($roleclasses as $role => $roleclass) {
     375foreach( (array) $roleclasses as $role => $roleclass) {
    376376        ksort($roleclass);
    377377?>
    378378
     
    491491<?php if ( is_wp_error( $add_user_errors ) ) : ?>
    492492        <div class="error">
    493493                <?php
    494                         foreach ( $add_user_errors->get_error_messages() as $message )
     494                        foreach ( (array) $add_user_errors->get_error_messages() as $message )
    495495                                echo "<p>$message</p>";
    496496                ?>
    497497        </div>
  • 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-comment-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" style="text-align: center">' .  __('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

     
    111111                die('-1');
    112112        $names = explode(',', $_POST['newcat']);
    113113        $x = new WP_Ajax_Response();
    114         foreach ( $names as $cat_name ) {
     114        foreach ( (array) $names as $cat_name ) {
    115115                $cat_name = trim($cat_name);
    116116                if ( !$category_nicename = sanitize_title($cat_name) )
    117117                        die('0');
     
    204204        if ( !$user_id = add_user() )
    205205                die('0');
    206206        elseif ( is_wp_error( $user_id ) ) {
    207                 foreach( $user_id->get_error_messages() as $message )
     207                foreach( (array) $user_id->get_error_messages() as $message )
    208208                        echo "<p>$message<p>";
    209209                exit;
    210210        }
  • 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

     
    8484                <?php _e('Select theme to edit:') ?>
    8585                <select name="theme" id="theme">
    8686        <?php
    87                 foreach ($themes as $a_theme) {
     87                foreach ( (array) $themes as $a_theme) {
    8888                $theme_name = $a_theme['Name'];
    8989                if ($theme_name == $theme) $selected = " selected='selected'";
    9090                else $selected = '';
     
    112112if ($allowed_files) :
    113113?>
    114114  <ul>
    115 <?php foreach($allowed_files as $allowed_file) : ?>
     115<?php foreach( (array) $allowed_files as $allowed_file) : ?>
    116116                 <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>
    117117<?php endforeach; ?>
    118118  </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

     
    9393<h3><?php _e('Recent'); ?></h3>
    9494<?php
    9595echo '<ol>';
    96 foreach ($recents as $recent) :
     96foreach ( (array) $recents as $recent) :
    9797        echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>";
    9898endforeach;
    9999echo '</ol>';
     
    102102<h3><?php _e('Common'); ?></h3>
    103103        <?php $common_files = array('index.php', '.htaccess', 'my-hacks.php');
    104104 $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php');
    105  foreach ($old_files as $old_file) {
     105 foreach ( (array) $old_files as $old_file) {
    106106         if (file_exists(ABSPATH . $old_file))
    107107                 $common_files[] = $old_file;
    108108 } ?>
    109109  <ul>
    110          <?php foreach ($common_files as $common_file) : ?>
     110         <?php foreach ( (array) $common_files as $common_file) : ?>
    111111          <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li>
    112112         <?php endforeach; ?>
    113113  </ul>
  • wp-admin/admin-functions.php

     
    123123
    124124        $i = 0;
    125125        $search = "# id=(\"|')p(\d+)\\1#i";
    126         foreach ( $anchor_matches[0] as $anchor ) {
     126        foreach ( (array) $anchor_matches[0] as $anchor ) {
    127127                if ( 0 == preg_match($search, $anchor, $id_matches) )
    128128                        continue;
    129129
     
    233233
    234234        // Meta Stuff
    235235        if ($_POST['meta']) {
    236                 foreach ($_POST['meta'] as $key => $value)
     236                foreach ( (array) $_POST['meta'] as $key => $value)
    237237                        update_meta($key, $value['key'], $value['value']);
    238238        }
    239239
    240240        if ($_POST['deletemeta']) {
    241                 foreach ($_POST['deletemeta'] as $key => $value)
     241                foreach ( (array) $_POST['deletemeta'] as $key => $value)
    242242                        delete_meta($key);
    243243        }
    244244
     
    374374function wp_dropdown_roles( $default = false ) {
    375375        global $wp_roles;
    376376        $r = '';
    377         foreach($wp_roles->role_names as $role => $name)
     377        foreach( (array) $wp_roles->role_names as $role => $name)
    378378                if ( $default == $role ) // Make default first in list
    379379                        $p = "\n\t<option selected='selected' value='$role'>$name</option>";
    380380                else
     
    639639        $result = array ();
    640640
    641641        if (is_array($cats)) {
    642                 foreach ($cats as $cat) {
     642                foreach ( (array) $cats as $cat) {
    643643                        $result[$cat]['children'] = get_nested_categories($default, $cat);
    644644                        $result[$cat]['cat_ID'] = $cat;
    645645                        $result[$cat]['checked'] = in_array($cat, $checked_categories);
     
    653653}
    654654
    655655function write_nested_categories($categories) {
    656         foreach ($categories as $category) {
     656        foreach ( (array) $categories as $category) {
    657657                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";
    658658
    659659                if ( $category['children'] ) {
     
    695695        $result = array ();
    696696
    697697        if (is_array($cats)) {
    698                 foreach ($cats as $cat) {
     698                foreach ( (array) $cats as $cat) {
    699699                        $result[$cat]['children'] = get_nested_link_categories($default, $cat);
    700700                        $result[$cat]['cat_ID'] = $cat;
    701701                        $result[$cat]['checked'] = in_array($cat, $checked_categories);
     
    718718                $categories = get_categories('hide_empty=0');
    719719
    720720        if ($categories) {
    721                 foreach ($categories as $category) {
     721                foreach ( (array) $categories as $category) {
    722722                        if ($category->category_parent == $parent) {
    723723                                echo "\t" . _cat_row( $category, $level );
    724724                                cat_rows($category->cat_ID, $level +1, $categories);
     
    767767        if (! $pages)
    768768                return false;
    769769
    770         foreach ($pages as $post) {
     770        foreach ( (array) $pages as $post) {
    771771                setup_postdata($post);
    772772                if ( $hierarchy && ($post->post_parent != $parent) )
    773773                        continue;
     
    832832                $categories = get_categories('hide_empty=0');
    833833
    834834        if ($categories) {
    835                 foreach ($categories as $category) {
     835                foreach ( (array) $categories as $category) {
    836836                        if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
    837837                                $pad = str_repeat('&#8211; ', $level);
    838838                                $category->cat_name = wp_specialchars($category->cat_name);
     
    973973        </thead>
    974974<?php
    975975        $r ="\n\t<tbody id='the-list'>";
    976         foreach ($meta as $entry) {
     976        foreach ( (array) $meta as $entry) {
    977977                ++ $count;
    978978                if ($count % 2)
    979979                        $style = 'alternate';
     
    10321032<option value="#NONE#"><?php _e('- Select -'); ?></option>
    10331033<?php
    10341034
    1035         foreach ($keys as $key) {
     1035        foreach ( (array) $keys as $key) {
    10361036                $key = wp_specialchars($key, 1);
    10371037                echo "\n\t<option value='$key'>$key</option>";
    10381038        }
     
    11591159                $foundit = false;
    11601160                if ($markerdata) {
    11611161                        $state = true;
    1162                         foreach ($markerdata as $n => $markerline) {
     1162                        foreach ( (array) $markerdata as $n => $markerline) {
    11631163                                if (strstr($markerline, "# BEGIN {$marker}"))
    11641164                                        $state = false;
    11651165                                if ($state) {
     
    11711171                                if (strstr($markerline, "# END {$marker}")) {
    11721172                                        fwrite($f, "# BEGIN {$marker}\n");
    11731173                                        if (is_array($insertion))
    1174                                                 foreach ($insertion as $insertline)
     1174                                                foreach ( (array) $insertion as $insertline)
    11751175                                                        fwrite($f, "{$insertline}\n");
    11761176                                        fwrite($f, "# END {$marker}\n");
    11771177                                        $state = true;
     
    11811181                }
    11821182                if (!$foundit) {
    11831183                        fwrite($f, "# BEGIN {$marker}\n");
    1184                         foreach ($insertion as $insertline)
     1184                        foreach ( (array) $insertion as $insertline)
    11851185                                fwrite($f, "{$insertline}\n");
    11861186                        fwrite($f, "# END {$marker}\n");
    11871187                }
     
    12051205        if ($markerdata = explode("\n", implode('', file($filename))));
    12061206        {
    12071207                $state = false;
    1208                 foreach ($markerdata as $markerline) {
     1208                foreach ( (array) $markerdata as $markerline) {
    12091209                        if (strstr($markerline, "# END {$marker}"))
    12101210                                $state = false;
    12111211                        if ($state)
     
    12641264        $page_templates = array ();
    12651265
    12661266        if (is_array($templates)) {
    1267                 foreach ($templates as $template) {
     1267                foreach ( (array) $templates as $template) {
    12681268                        $template_data = implode('', file(ABSPATH.$template));
    12691269                        preg_match("|Template Name:(.*)|i", $template_data, $name);
    12701270                        preg_match("|Description:(.*)|i", $template_data, $description);
     
    12971297        $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");
    12981298
    12991299        if ($items) {
    1300                 foreach ($items as $item) {
     1300                foreach ( (array) $items as $item) {
    13011301                        // A page cannot be it's own parent.
    13021302                        if (!empty ($post_ID)) {
    13031303                                if ($item->ID == $post_ID) {
     
    13551355        }
    13561356
    13571357        if (isset ($submenu[$parent])) {
    1358                 foreach ($submenu[$parent] as $submenu_array) {
     1358                foreach ( (array) $submenu[$parent] as $submenu_array) {
    13591359                        if ($submenu_array[2] == $pagenow) {
    13601360                                if (current_user_can($submenu_array[1]))
    13611361                                        return true;
     
    13651365                }
    13661366        }
    13671367
    1368         foreach ($menu as $menu_array) {
     1368        foreach ( (array) $menu as $menu_array) {
    13691369                if ($menu_array[2] == $parent) {
    13701370                        if (current_user_can($menu_array[1]))
    13711371                                return true;
     
    13921392
    13931393        $parent = $parent1 = get_admin_page_parent();
    13941394        if (empty ($parent)) {
    1395                 foreach ($menu as $menu_array) {
     1395                foreach ( (array) $menu as $menu_array) {
    13961396                        if (isset ($menu_array[3])) {
    13971397                                if ($menu_array[2] == $pagenow) {
    13981398                                        $title = $menu_array[3];
     
    14061406                }
    14071407        } else {
    14081408                foreach (array_keys($submenu) as $parent) {
    1409                         foreach ($submenu[$parent] as $submenu_array) {
     1409                        foreach ( (array) $submenu[$parent] as $submenu_array) {
    14101410                                if (isset ($submenu_array[3])) {
    14111411                                        if ($submenu_array[2] == $pagenow) {
    14121412                                                $title = $submenu_array[3];
     
    14421442        }
    14431443
    14441444        if ($pagenow == 'admin.php' && isset ($plugin_page)) {
    1445                 foreach ($menu as $parent_menu) {
     1445                foreach ( (array) $menu as $parent_menu) {
    14461446                        if ($parent_menu[2] == $plugin_page) {
    14471447                                $parent_file = $plugin_page;
    14481448                                if ( isset($_wp_real_parent_file[$parent_file]) )
     
    14661466        }
    14671467
    14681468        foreach (array_keys($submenu) as $parent) {
    1469                 foreach ($submenu[$parent] as $submenu_array) {
     1469                foreach ( (array) $submenu[$parent] as $submenu_array) {
    14701470                        if ( isset($_wp_real_parent_file[$parent]) )
    14711471                                $parent = $_wp_real_parent_file[$parent];
    14721472                        if ($submenu_array[2] == $pagenow) {
     
    15231523        // parent file someone is trying to link back to the parent manually.  In
    15241524        // this case, don't automatically add a link back to avoid duplication.
    15251525        if (!isset ($submenu[$parent]) && $file != $parent  ) {
    1526                 foreach ($menu as $parent_menu) {
     1526                foreach ( (array) $menu as $parent_menu) {
    15271527                        if ( $parent_menu[2] == $parent && current_user_can($parent_menu[1]) ) {
    15281528                                $submenu[$parent][] = $parent_menu;
    15291529                        }
     
    17111711
    17121712        sort($plugin_files);
    17131713
    1714         foreach ($plugin_files as $plugin_file) {
     1714        foreach ( (array) $plugin_files as $plugin_file) {
    17151715                if ( !is_readable("$plugin_root/$plugin_file"))
    17161716                        continue;
    17171717
  • wp-admin/edit-page-form.php

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

     
    99
    1010$comment = array();
    1111if (isset($_POST["comment"])) {
    12         foreach ($_POST["comment"] as $k => $v) {
     12        foreach ( (array) $_POST["comment"] as $k => $v) {
    1313                $comment[intval($k)] = $v;
    1414        }
    1515}
     
    2828        $item_approved = 0;
    2929        $item_spam = 0;
    3030
    31         foreach($comment as $key => $value) {
     31        foreach( (array) $comment as $key => $value) {
    3232        if ($feelinglucky && 'later' == $value)
    3333                $value = 'delete';
    3434            switch($value) {
     
    123123    <ol id="the-comment-list" class="commentlist">
    124124<?php
    125125$i = 0;
    126     foreach($comments as $comment) {
     126    foreach( (array) $comments as $comment) {
    127127        ++$i;
    128128        $comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
    129129        $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
  • wp-admin/index.php

     
    2424<ul>
    2525<?php
    2626$rss->items = array_slice($rss->items, 0, 10);
    27 foreach ($rss->items as $item ) {
     27foreach ( (array) $rss->items as $item ) {
    2828?>
    2929        <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wp_specialchars($item['title']); ?></a></li>
    3030<?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>";
     
    135135<h3><?php _e('WordPress Development News'); ?></h3>
    136136<?php
    137137$rss->items = array_slice($rss->items, 0, 3);
    138 foreach ($rss->items as $item ) {
     138foreach ( (array) $rss->items as $item ) {
    139139?>
    140140<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>
    141141<p><?php echo $item['description']; ?></p>
     
    154154<ul>
    155155<?php
    156156$rss->items = array_slice($rss->items, 0, 20);
    157 foreach ($rss->items as $item ) {
     157foreach ( (array) $rss->items as $item ) {
    158158?>
    159159<li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li>
    160160<?php
  • wp-admin/admin-db.php

     
    189189        // Only set posts and links to the default category if they're not in another category already.
    190190        $default_cat = get_option('default_category');
    191191        $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
    192         if ( is_array($posts) ) foreach ($posts as $post_id) {
     192        if ( is_array($posts) ) foreach ( (array) $posts as $post_id) {
    193193                $cats = wp_get_post_categories($post_id);
    194194                if ( 1 == count($cats) )
    195195                        $cats = array($default_cat);
     
    200200
    201201        $default_link_cat = get_option('default_link_category');
    202202        $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
    203         if ( is_array($links) ) foreach ($links as $link_id) {
     203        if ( is_array($links) ) foreach ( (array) $links as $link_id) {
    204204                $cats = wp_get_link_cats($link_id);
    205205                if ( 1 == count($cats) )
    206206                        $cats = array($default_link_cat);
     
    224224
    225225function wp_create_categories($categories, $post_id = '') {
    226226        $cat_ids = array ();
    227         foreach ($categories as $category) {
     227        foreach ( (array) $categories as $category) {
    228228                if ($id = category_exists($category))
    229229                        $cat_ids[] = $id;
    230230                else
     
    256256                $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
    257257
    258258                if ($post_ids) {
    259                         foreach ($post_ids as $post_id)
     259                        foreach ( (array) $post_ids as $post_id)
    260260                                wp_delete_post($post_id);
    261261                }
    262262
     
    402402       
    403403        $categories = wp_get_link_cats($link_id);
    404404        if( is_array( $categories ) ) {
    405                 foreach ( $categories as $category ) {
     405                foreach ( (array) $categories as $category ) {
    406406                        $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
    407407                        wp_cache_delete($category, 'category');
    408408                }
     
    452452        $delete_cats = array_diff($old_categories,$link_categories);
    453453
    454454        if ($delete_cats) {
    455                 foreach ($delete_cats as $del) {
     455                foreach ( (array) $delete_cats as $del) {
    456456                        $wpdb->query("
    457457                                DELETE FROM $wpdb->link2cat
    458458                                WHERE category_id = $del
     
    465465        $add_cats = array_diff($link_categories, $old_categories);
    466466
    467467        if ($add_cats) {
    468                 foreach ($add_cats as $new_cat) {
     468                foreach ( (array) $add_cats as $new_cat) {
    469469                        $wpdb->query("
    470470                                INSERT INTO $wpdb->link2cat (link_id, category_id)
    471471                                VALUES ($link_ID, $new_cat)");
     
    474474       
    475475        // Update category counts.
    476476        $all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
    477         foreach ( $all_affected_cats as $cat_id ) {
     477        foreach ( (array) $all_affected_cats as $cat_id ) {
    478478                $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'");
    479479                $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
    480480                wp_cache_delete($cat_id, 'category');
  • wp-admin/upload.php

     
    4343        exit;
    4444}
    4545
    46 foreach ( $wp_upload_tabs as $t => $tab_array ) {
     46foreach ( (array) $wp_upload_tabs as $t => $tab_array ) {
    4747        if ( !current_user_can( $tab_array[1] ) ) {
    4848                unset($wp_upload_tabs[$t]);
    4949                if ( $tab == $t )
     
    5454include_once('admin-header.php');
    5555
    5656echo "<ul id='upload-menu'>\n";
    57 foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check
     57foreach ( (array) $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check
    5858        $class = 'upload-tab';
    5959        $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') );
    6060        if ( isset($tab_array[4]) && is_array($tab_array[4]) )
  • 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 />'.sprintf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br />');
    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                                wp_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                        wp_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/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/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/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 = str_replace(array('<![CDATA[', ']]>'), '', $wpdb->escape( trim($post_title[1]) ));
    4242
     
    6464                        }
    6565
    6666                        $cat_index = 0;
    67                         foreach ($categories as $category) {
     67                        foreach ( (array) $categories as $category) {
    6868                                $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
    6969                                $cat_index++;
    7070                        }
     
    9999        function import_posts() {
    100100                echo '<ol>';
    101101
    102                 foreach ($this->posts as $post) {
     102                foreach ( (array) $this->posts as $post) {
    103103                        echo "<li>".__('Importing post...');
    104104
    105105                        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 />'.sprintf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br />');
    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>" . wp_specialchars($pinged_url) . "</li>";
    4343        }
    4444        $pings .= '</ul>';
     
    124124<div class="dbx-content">
    125125<select name="post_author_override" id="post_author_override">
    126126<?php
    127 foreach ($authors as $o) :
     127foreach ( (array) $authors as $o) :
    128128$o = get_userdata( $o->ID );
    129129if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
    130130else $selected = '';
  • wp-admin/menu.php

     
    6666$submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
    6767
    6868// Create list of page plugin hook names.
    69 foreach ($menu as $menu_page) {
     69foreach ( (array) $menu as $menu_page) {
    7070        $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
    7171}
    7272
    7373$_wp_submenu_nopriv = array();
    7474$_wp_menu_nopriv = array();
    7575// Loop over submenus and remove pages for which the user does not have privs.
    76 foreach ($submenu as $parent => $sub) {
    77         foreach ($sub as $index => $data) {
     76foreach ( (array) $submenu as $parent => $sub) {
     77        foreach ( (array) $sub as $index => $data) {
    7878                if ( ! current_user_can($data[1]) ) {
    7979                        unset($submenu[$parent][$index]);
    8080                        $_wp_submenu_nopriv[$parent][$data[2]] = true;
     
    8888// Loop over the top-level menu.
    8989// Menus for which the original parent is not acessible due to lack of privs will have the next
    9090// submenu in line be assigned as the new menu parent.
    91 foreach ( $menu as $id => $data ) {
     91foreach ( (array) $menu as $id => $data ) {
    9292        if ( empty($submenu[$data[2]]) )
    9393                continue;
    9494        $subs = $submenu[$data[2]];
     
    101101                $_wp_real_parent_file[$old_parent] = $new_parent;
    102102                $menu[$id][2] = $new_parent;
    103103               
    104                 foreach ($submenu[$old_parent] as $index => $data) {
     104                foreach ( (array) $submenu[$old_parent] as $index => $data) {
    105105                        $submenu[$new_parent][$index] = $submenu[$old_parent][$index];
    106106                        unset($submenu[$old_parent][$index]);
    107107                }
     
    114114
    115115// Remove menus that have no accessible submenus and require privs that the user does not have.
    116116// Run re-parent loop again.
    117 foreach ( $menu as $id => $data ) {
     117foreach ( (array) $menu as $id => $data ) {
    118118        // If submenu is empty...
    119119        if ( empty($submenu[$data[2]]) ) {
    120120                // And user doesn't have privs, remove menu.
  • 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 . PLUGINDIR . '/' . $check_plugin)) {
    4646                        $current = get_option('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);
     
    145145        <thead>
    146146        <tr>
    147147
    148 <?php foreach($posts_columns as $column_display_name) { ?>
     148<?php foreach( (array) $posts_columns as $column_display_name) { ?>
    149149        <th scope="col"><?php echo $column_display_name; ?></th>
    150150<?php } ?>
    151151
     
    155155<?php
    156156if ($posts) {
    157157$bgcolor = '';
    158 foreach ($posts as $post) { start_wp();
     158foreach ( (array) $posts as $post) { start_wp();
    159159add_filter('the_title','wp_specialchars');
    160160$class = ('alternate' == $class) ? '' : 'alternate';
    161161?>
     
    163163
    164164<?php
    165165
    166 foreach($posts_columns as $column_name=>$column_display_name) {
     166foreach( (array) $posts_columns as $column_name=>$column_display_name) {
    167167
    168168        switch($column_name) {
    169169
     
    262262<ol id="the-comment-list" class="commentlist">
    263263<?php
    264264$i = 0;
    265 foreach ($comments as $comment) {
     265foreach ( (array) $comments as $comment) {
    266266
    267267                ++$i; $class = '';
    268268                $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
  • wp-admin/options.php

     
    7979        check_admin_referer('update-options');
    8080
    8181        if (!$_POST['page_options']) {
    82                 foreach ($_POST as $key => $value) {
     82                foreach ( (array) $_POST as $key => $value) {
    8383                        $options[] = $key;
    8484                }
    8585        } else {
     
    8787        }
    8888
    8989        if ($options) {
    90                 foreach ($options as $option) {
     90                foreach ( (array) $options as $option) {
    9191                        $option = trim($option);
    9292                        $value = trim(stripslashes($_POST[$option]));
    9393                        $value = sanitize_option($option, $value);
     
    113113<?php
    114114$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
    115115
    116 foreach ($options as $option) :
     116foreach ( (array) $options as $option) :
    117117        $value = wp_specialchars($option->option_value, 'single');
    118118        echo "
    119119<tr>
  • wp-admin/link.php

     
    2727                }
    2828
    2929                $deleted = 0;
    30                 foreach ($linkcheck as $link_id) {
     30                foreach ( (array) $linkcheck as $link_id) {
    3131                        $link_id = (int) $link_id;
    3232                       
    3333                        if ( wp_delete_link($link_id) )
  • wp-admin/profile.php

     
    125125      <th scope="row"><?php _e('Additional Capabilities:') ?></th>
    126126      <td><?php
    127127                        $output = '';
    128                         foreach($profileuser->caps as $cap => $value) {
     128                        foreach( (array) $profileuser->caps as $cap => $value) {
    129129                                if(!$wp_roles->is_role($cap)) {
    130130                                        if($output != '') $output .= ', ';
    131131                                        $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>
     
    9595echo '<select name="role">';
    9696$role_list = '';
    9797$user_has_role = false;
    98 foreach($wp_roles->role_names as $role => $name) {
     98foreach( (array) $wp_roles->role_names as $role => $name) {
    9999        if ( $profileuser->has_cap($role) ) {
    100100                $selected = ' selected="selected"';
    101101                $user_has_role = true;
     
    194194      <th scope="row"><?php _e('Additional Capabilities:') ?></th>
    195195      <td><?php
    196196                        $output = '';
    197                         foreach($profileuser->caps as $cap => $value) {
     197                        foreach( (array) $profileuser->caps as $cap => $value) {
    198198                                if(!$wp_roles->is_role($cap)) {
    199199                                        if($output != '') $output .= ', ';
    200200                                        $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

     
    119119        $cat_id = '';
    120120$links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0");
    121121if ($links)
    122         foreach ($links as $link) {
     122        foreach ( (array) $links as $link) {
    123123                $link->link_name = wp_specialchars($link->link_name);
    124124                $link->link_description = wp_specialchars($link->link_description);
    125125                $link->link_url = wp_specialchars($link->link_url);
     
    147147        <?php
    148148
    149149                $cat_names = array();
    150                 foreach ($link->link_category as $category) {
     150                foreach ( (array) $link->link_category as $category) {
    151151                        $cat_name = get_the_category_by_ID($category);
    152152                        $cat_name = wp_specialchars($cat_name);
    153153                        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='".wptexturize(strip_tags($data[1]))."'>{$data[0]}</a>";
    4040
  • wp-admin/options-writing.php

     
    3535<td><select name="default_category" id="default_category">
    3636<?php
    3737$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    38 foreach ($categories as $category) :
     38foreach ( (array) $categories as $category) :
    3939if ($category->cat_ID == get_option('default_category')) $selected = " selected='selected'";
    4040else $selected = '';
    4141echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     
    4747<th scope="row"><?php _e('Default bookmark category:') ?></th>
    4848<td><select name="default_link_category" id="default_link_category">
    4949<?php
    50 foreach ($categories as $category) :
     50foreach ( (array) $categories as $category) :
    5151if ($category->cat_ID == get_option('default_link_category')) $selected = " selected='selected'";
    5252else $selected = '';
    5353echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     
    8484<td><select name="default_email_category" id="default_email_category">
    8585<?php
    8686//Alreay have $categories from default_category
    87 foreach ($categories as $category) :
     87foreach ( (array) $categories as $category) :
    8888if ($category->cat_ID == get_option('default_email_category')) $selected = " selected='selected'";
    8989else $selected = '';
    9090echo "\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

     
    7676if ($plugin_files) :
    7777?>
    7878  <ul>
    79 <?php foreach($plugin_files as $plugin_file) : ?>
     79<?php foreach( (array) $plugin_files as $plugin_file) : ?>
    8080                 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
    8181<?php endforeach; ?>
    8282  </ul>
  • 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
  • wp-admin/upgrade-schema.php

     
    234234
    235235        // Delete unused options
    236236        $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');
    237         foreach ($unusedoptions as $option) :
     237        foreach ( (array) $unusedoptions as $option) :
    238238                delete_option($option);
    239239        endforeach;
    240240
    241241        // Set up a few options not to load by default
    242242        $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
    243         foreach ($fatoptions as $fatoption) :
     243        foreach ( (array) $fatoptions as $fatoption) :
    244244                $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
    245245        endforeach;
    246246}
     
    341341
    342342function populate_roles_210() {
    343343        $roles = array('administrator', 'editor');
    344         foreach ($roles as $role) {
     344        foreach ( (array) $roles as $role) {
    345345                $role = get_role($role);
    346346                if ( empty($role) )
    347347                        continue;