Ticket #2784: cast_to_array.diff
| File cast_to_array.diff, 153.1 KB (added by , 20 years ago) |
|---|
-
wp-rss.php
21 21 <language><?php echo get_option('rss_language'); ?></language> 22 22 <?php do_action('rss_head'); ?> 23 23 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(); ?> 25 25 <item> 26 26 <title><?php the_title_rss() ?></title> 27 27 <?php if (get_settings('rss_use_excerpt')) { ?> -
wp-includes/class-snoopy.php
812 812 reset($this->cookies); 813 813 if ( count($this->cookies) > 0 ) { 814 814 $cookie_headers .= 'Cookie: '; 815 foreach ( $this->cookies as $cookieKey => $cookieVal ) {815 foreach ( (array) $this->cookies as $cookieKey => $cookieVal ) { 816 816 $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; 817 817 } 818 818 $headers .= substr($cookie_headers,0,-2) . "\r\n"; … … 976 976 reset($this->cookies); 977 977 if ( count($this->cookies) > 0 ) { 978 978 $cookie_str = 'Cookie: '; 979 foreach ( $this->cookies as $cookieKey => $cookieVal ) {979 foreach ( (array) $this->cookies as $cookieKey => $cookieVal ) { 980 980 $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; 981 981 } 982 982 $headers[] = substr($cookie_str,0,-2); -
wp-includes/template-functions-general.php
329 329 $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); 330 330 if ( $arcresults ) { 331 331 $afterafter = $after; 332 foreach ( $arcresults as $arcresult ) {332 foreach ( (array) $arcresults as $arcresult ) { 333 333 $url = get_month_link($arcresult->year, $arcresult->month); 334 334 if ( $show_post_count ) { 335 335 $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year); … … 343 343 } elseif ( 'daily' == $type ) { 344 344 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 345 345 if ( $arcresults ) { 346 foreach ( $arcresults as $arcresult ) {346 foreach ( (array) $arcresults as $arcresult ) { 347 347 $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); 348 348 $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth); 349 349 $text = mysql2date($archive_day_date_format, $date); … … 355 355 $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 356 356 $arc_w_last = ''; 357 357 if ( $arcresults ) { 358 foreach ( $arcresults as $arcresult ) {358 foreach ( (array) $arcresults as $arcresult ) { 359 359 if ( $arcresult->week != $arc_w_last ) { 360 360 $arc_year = $arcresult->yr; 361 361 $arc_w_last = $arcresult->week; … … 372 372 ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC "; 373 373 $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY $orderby $limit"); 374 374 if ( $arcresults ) { 375 foreach ( $arcresults as $arcresult ) {375 foreach ( (array) $arcresults as $arcresult ) { 376 376 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { 377 377 $url = get_permalink($arcresult); 378 378 $arc_title = $arcresult->post_title; … … 462 462 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); 463 463 } 464 464 465 foreach ( $myweek as $wd ) {465 foreach ( (array) $myweek as $wd ) { 466 466 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 467 467 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 468 468 } … … 506 506 AND post_type = 'post' AND post_status = 'publish' 507 507 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); 508 508 if ( $dayswithposts ) { 509 foreach ( $dayswithposts as $daywith ) {509 foreach ( (array) $dayswithposts as $daywith ) { 510 510 $daywithpost[] = $daywith[0]; 511 511 } 512 512 } else { … … 529 529 ."AND post_type = 'post' AND post_status = 'publish'" 530 530 ); 531 531 if ( $ak_post_titles ) { 532 foreach ( $ak_post_titles as $ak_post_title ) {532 foreach ( (array) $ak_post_titles as $ak_post_title ) { 533 533 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) 534 534 $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; 535 535 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one … … 577 577 function allowed_tags() { 578 578 global $allowedtags; 579 579 $allowed = ''; 580 foreach ( $allowedtags as $tag => $attributes ) {580 foreach ( (array) $allowedtags as $tag => $attributes ) { 581 581 $allowed .= '<'.$tag; 582 582 if ( 0 < count($attributes) ) { 583 foreach ( $attributes as $attribute => $limits ) {583 foreach ( (array) $attributes as $attribute => $limits ) { 584 584 $allowed .= ' '.$attribute.'=""'; 585 585 } 586 586 } -
wp-includes/template-functions-category.php
59 59 $thelist = ''; 60 60 if ( '' == $separator ) { 61 61 $thelist .= '<ul class="post-categories">'; 62 foreach ( $categories as $category ) {62 foreach ( (array) $categories as $category ) { 63 63 $thelist .= "\n\t<li>"; 64 64 switch ( strtolower($parents) ) { 65 65 case 'multiple': … … 81 81 $thelist .= '</ul>'; 82 82 } else { 83 83 $i = 0; 84 foreach ( $categories as $category ) {84 foreach ( (array) $categories as $category ) { 85 85 if ( 0 < $i ) 86 86 $thelist .= $separator . ' '; 87 87 switch ( strtolower($parents) ) { … … 140 140 return ''; 141 141 142 142 $cat_ids = get_all_category_ids(); 143 foreach ( $cat_ids as $cat_id ) {143 foreach ( (array) $cat_ids as $cat_id ) { 144 144 if ( $cat_id == $id) 145 145 continue; 146 146 … … 266 266 return array(); 267 267 268 268 $category_list = array(); 269 foreach ( $categories as $category ) {269 foreach ( (array) $categories as $category ) { 270 270 if ( $category->category_parent == $category_id ) { 271 271 $category_list[] = $category; 272 272 if ( $children = _get_cat_children($category->cat_ID, $categories) ) … … 298 298 $exclude = ''; 299 299 $incategories = preg_split('/[\s,]+/',$include); 300 300 if ( count($incategories) ) { 301 foreach ( $incategories as $incat ) {301 foreach ( (array) $incategories as $incat ) { 302 302 if (empty($inclusions)) 303 303 $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' '; 304 304 else … … 314 314 if ( !empty($exclude) ) { 315 315 $excategories = preg_split('/[\s,]+/',$exclude); 316 316 if ( count($excategories) ) { 317 foreach ( $excategories as $excat ) {317 foreach ( (array) $excategories as $excat ) { 318 318 if (empty($exclusions)) 319 319 $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' '; 320 320 else … … 346 346 $stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories 347 347 WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id"); 348 348 global $cat_stamps; 349 foreach ( $stamps as $stamp)349 foreach ( (array) $stamps as $stamp) 350 350 $cat_stamps[$stamp->category_id] = $stamp->ts; 351 351 function stamp_cat($cat) { 352 352 global $cat_stamps; -
wp-includes/locale.php
32 32 $this->weekday_initial[__('Friday')] = __('F_Friday_initial'); 33 33 $this->weekday_initial[__('Saturday')] = __('S_Saturday_initial'); 34 34 35 foreach ( $this->weekday_initial as $weekday_ => $weekday_initial_) {35 foreach ( (array) $this->weekday_initial as $weekday_ => $weekday_initial_) { 36 36 $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_); 37 37 } 38 38 … … 74 74 $this->month_abbrev[__('November')] = __('Nov_November_abbreviation'); 75 75 $this->month_abbrev[__('December')] = __('Dec_December_abbreviation'); 76 76 77 foreach ( $this->month_abbrev as $month_ => $month_abbrev_) {77 foreach ( (array) $this->month_abbrev as $month_ => $month_abbrev_) { 78 78 $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_); 79 79 } 80 80 -
wp-includes/cache.php
188 188 if ('category' == $group) { 189 189 $this->cache['category'] = array (); 190 190 if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) { 191 foreach ( $dogs as $catt)191 foreach ( (array) $dogs as $catt) 192 192 $this->cache['category'][$catt->cat_ID] = $catt; 193 193 } 194 194 } else … … 202 202 if ( ! $options ) 203 203 return; 204 204 205 foreach ( $options as $option) {205 foreach ( (array) $options as $option) { 206 206 $this->cache['options'][$option->option_name] = $option->option_value; 207 207 } 208 208 } … … 258 258 } 259 259 260 260 $stack = array_reverse($stack); // Last added dirs are deepest 261 foreach( $stack as $dir) {261 foreach( (array) $stack as $dir) { 262 262 if ( $dir != $top_dir) 263 263 @ rmdir($dir); 264 264 } … … 326 326 327 327 // Loop over dirty objects and save them. 328 328 $errors = 0; 329 foreach ( $this->dirty_objects as $group => $ids) {329 foreach ( (array) $this->dirty_objects as $group => $ids) { 330 330 $group_dir = $this->make_group_dir($group, $dir_perms); 331 331 332 332 $ids = array_unique($ids); 333 foreach ( $ids as $id) {333 foreach ( (array) $ids as $id) { 334 334 $cache_file = $group_dir.$this->hash($id).'.php'; 335 335 336 336 // Remove the cache file if the key is not set. … … 376 376 echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br/>"; 377 377 echo "</p>"; 378 378 379 foreach ( $this->cache as $group => $cache) {379 foreach ( (array) $this->cache as $group => $cache) { 380 380 echo "<p>"; 381 381 echo "<strong>Group:</strong> $group<br/>"; 382 382 echo "<strong>Cache:</strong>"; -
wp-includes/template-functions-post.php
207 207 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) ) { 208 208 // Change from flat structure to hierarchical: 209 209 $post_meta_cache = array(); 210 foreach ( $meta_list as $metarow ) {210 foreach ( (array) $meta_list as $metarow ) { 211 211 $mpid = $metarow['post_id']; 212 212 $mkey = $metarow['meta_key']; 213 213 $mval = $metarow['meta_value']; … … 261 261 262 262 if ( $keys = get_post_custom_keys() ) { 263 263 echo "<ul class='post-meta'>\n"; 264 foreach ( $keys as $key ) {264 foreach ( (array) $keys as $key ) { 265 265 $keyt = trim($key); 266 266 if ( '_' == $keyt{0} ) 267 267 continue; … … 297 297 $pages = &$page_cache; 298 298 299 299 $page_list = array(); 300 foreach ( $pages as $page ) {300 foreach ( (array) $pages as $page ) { 301 301 if ( $page->post_parent == $page_id ) { 302 302 $page_list[] = $page; 303 303 if ( $children = get_page_children($page->ID, $pages) ) … … 329 329 $meta_value = ''; 330 330 $incpages = preg_split('/[\s,]+/',$include); 331 331 if ( count($incpages) ) { 332 foreach ( $incpages as $incpage ) {332 foreach ( (array) $incpages as $incpage ) { 333 333 if (empty($inclusions)) 334 334 $inclusions = ' AND ( ID = ' . intval($incpage) . ' '; 335 335 else … … 344 344 if ( !empty($exclude) ) { 345 345 $expages = preg_split('/[\s,]+/',$exclude); 346 346 if ( count($expages) ) { 347 foreach ( $expages as $expage ) {347 foreach ( (array) $expages as $expage ) { 348 348 if (empty($exclusions)) 349 349 $exclusions = ' AND ( ID <> ' . intval($expage) . ' '; 350 350 else … … 497 497 498 498 $types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime)); 499 499 $exts = array('jpg', 'gif', 'png'); 500 foreach ( $types as $type) {501 foreach ( $exts as $ext) {500 foreach ( (array) $types as $type) { 501 foreach ( (array) $exts as $ext) { 502 502 $src_file = "$icon_dir/$type.$ext"; 503 503 if ( file_exists($src_file) ) { 504 504 $src = "$icon_dir_uri/$type.$ext"; -
wp-includes/query.php
709 709 $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) "; 710 710 $cat_array = preg_split('/[,\s]+/', $q['cat']); 711 711 $in_cats = $out_cats = ''; 712 foreach ( $cat_array as $cat ) {712 foreach ( (array) $cat_array as $cat ) { 713 713 $cat = intval($cat); 714 714 $in = strstr($cat, '-') ? false : true; 715 715 $cat = trim($cat, '-'); … … 740 740 $cat_paths = '/' . trim(urldecode($q['category_name']), '/'); 741 741 $q['category_name'] = sanitize_title(basename($cat_paths)); 742 742 $cat_paths = explode('/', $cat_paths); 743 foreach( $cat_paths as $pathdir)743 foreach( (array) $cat_paths as $pathdir) 744 744 $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 745 745 746 746 //if we don't match the entire hierarchy fallback on just matching the nicename -
wp-includes/template-functions-bookmarks.php
91 91 92 92 $output = ''; 93 93 94 foreach ( $results as $row) {94 foreach ( (array) $results as $row) { 95 95 if (!isset($row->recently_updated)) $row->recently_updated = false; 96 96 $output .= $before; 97 97 if ($show_updated && $row->recently_updated) { … … 244 244 245 245 // Display each category 246 246 if ($cats) { 247 foreach ( $cats as $cat) {247 foreach ( (array) $cats as $cat) { 248 248 // Handle each category. 249 249 250 250 // Display the category name … … 300 300 $category_name = ''; 301 301 $inclinks = preg_split('/[\s,]+/',$include); 302 302 if ( count($inclinks) ) { 303 foreach ( $inclinks as $inclink ) {303 foreach ( (array) $inclinks as $inclink ) { 304 304 if (empty($inclusions)) 305 305 $inclusions = ' AND ( link_id = ' . intval($inclink) . ' '; 306 306 else … … 315 315 if ( !empty($exclude) ) { 316 316 $exlinks = preg_split('/[\s,]+/',$exclude); 317 317 if ( count($exlinks) ) { 318 foreach ( $exlinks as $exlink ) {318 foreach ( (array) $exlinks as $exlink ) { 319 319 if (empty($exclusions)) 320 320 $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' '; 321 321 else … … 336 336 if ( !empty($category) ) { 337 337 $incategories = preg_split('/[\s,]+/',$category); 338 338 if ( count($incategories) ) { 339 foreach ( $incategories as $incat ) {339 foreach ( (array) $incategories as $incat ) { 340 340 if (empty($category_query)) 341 341 $category_query = ' AND ( category_id = ' . intval($incat) . ' '; 342 342 else -
wp-includes/wp-db.php
253 253 } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { 254 254 if ( $this->last_result ) { 255 255 $i = 0; 256 foreach( $this->last_result as $row ) {256 foreach( (array) $this->last_result as $row ) { 257 257 $new_array[$i] = (array) $row; 258 258 if ( $output == ARRAY_N ) { 259 259 $new_array[$i] = array_values($new_array[$i]); … … 276 276 if ( $this->col_info ) { 277 277 if ( $col_offset == -1 ) { 278 278 $i = 0; 279 foreach( $this->col_info as $col ) {279 foreach( (array) $this->col_info as $col ) { 280 280 $new_array[$i] = $col->{$info_type}; 281 281 $i++; 282 282 } -
wp-includes/rewrite.php
119 119 120 120 // Look for matches. 121 121 $request_match = $request; 122 foreach ( $rewrite as $match => $query) {122 foreach ( (array) $rewrite as $match => $query) { 123 123 // If the requesting file is the anchor of the match, prepend it 124 124 // to the path info. 125 125 if ( (! empty($url)) && (strpos($match, $url) === 0) ) { … … 265 265 $rewrite_rules = array(); 266 266 $page_structure = $this->get_page_permastruct(); 267 267 if( is_array( $attachment_uris ) ) { 268 foreach ( $attachment_uris as $uri => $pagename) {268 foreach ( (array) $attachment_uris as $uri => $pagename) { 269 269 $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment='); 270 270 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES)); 271 271 } 272 272 } 273 273 if( is_array( $uris ) ) { 274 foreach ( $uris as $uri => $pagename) {274 foreach ( (array) $uris as $uri => $pagename) { 275 275 $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename='); 276 276 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES)); 277 277 } … … 296 296 $this->date_structure = ''; 297 297 $date_endian = ''; 298 298 299 foreach ( $endians as $endian) {299 foreach ( (array) $endians as $endian) { 300 300 if (false !== strpos($this->permalink_structure, $endian)) { 301 301 $date_endian= $endian; 302 302 break; … … 311 311 $front = $this->front; 312 312 preg_match_all('/%.+?%/', $this->permalink_structure, $tokens); 313 313 $tok_index = 1; 314 foreach ( $tokens[0] as $token) {314 foreach ( (array) $tokens[0] as $token) { 315 315 if ( ($token == '%post_id%') && ($tok_index <= 3) ) { 316 316 $front = $front . 'date/'; 317 317 break; … … 470 470 function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) { 471 471 //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/? 472 472 $feedregex2 = ''; 473 foreach ( $this->feeds as $feed_name) {473 foreach ( (array) $this->feeds as $feed_name) { 474 474 $feedregex2 .= $feed_name . '|'; 475 475 } 476 476 $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$'; … … 485 485 //build up an array of endpoint regexes to append => queries to append 486 486 if ($endpoints) { 487 487 $ep_query_append = array (); 488 foreach ( $this->endpoints as $endpoint) {488 foreach ( (array) $this->endpoints as $endpoint) { 489 489 //match everything after the endpoint name, but allow for nothing to appear there 490 490 $epmatch = $endpoint[1] . '(/(.*))?/?$'; 491 491 //this will be appended on to the rest of the query for each dir … … 599 599 600 600 //do endpoints 601 601 if ($endpoints) { 602 foreach ( $ep_query_append as $regex => $ep) {602 foreach ( (array) $ep_query_append as $regex => $ep) { 603 603 //add the endpoints on if the mask fits 604 604 if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) { 605 605 $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); … … 639 639 $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); 640 640 641 641 //do endpoints for attachments 642 if ($endpoint) { foreach ( $ep_query_append as $regex => $ep) {642 if ($endpoint) { foreach ( (array) $ep_query_append as $regex => $ep) { 643 643 if ($ep[0] & EP_ATTACHMENT) { 644 644 $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2); 645 645 $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2); … … 677 677 } //if($num_toks) 678 678 //add the rules for this dir to the accumulating $post_rewrite 679 679 $post_rewrite = array_merge($rewrite, $post_rewrite); 680 } //foreach ( $dir)680 } //foreach ( (array) $dir) 681 681 return $post_rewrite; //the finished rules. phew! 682 682 } 683 683 … … 768 768 $rules .= "RewriteBase $home_root\n"; 769 769 770 770 //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all) 771 foreach ( $this->non_wp_rules as $match => $query) {771 foreach ( (array) $this->non_wp_rules as $match => $query) { 772 772 // Apache 1.3 does not support the reluctant (non-greedy) modifier. 773 773 $match = str_replace('.+?', '.+', $match); 774 774 … … 789 789 "RewriteCond %{REQUEST_FILENAME} -d\n" . 790 790 "RewriteRule ^.*$ - [S=$num_rules]\n"; 791 791 792 foreach ( $rewrite as $match => $query) {792 foreach ( (array) $rewrite as $match => $query) { 793 793 // Apache 1.3 does not support the reluctant (non-greedy) modifier. 794 794 $match = str_replace('.+?', '.+', $match); 795 795 -
wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php
34 34 function checkWords($wordArray) { 35 35 if ($fh = fopen($this->tmpfile, "w")) { 36 36 fwrite($fh, "!\n"); 37 foreach( $wordArray as $key => $value)37 foreach( (array) $wordArray as $key => $value) 38 38 fwrite($fh, "^" . $value . "\n"); 39 39 40 40 fclose($fh); … … 47 47 $returnData = array(); 48 48 $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); 49 49 50 foreach( $dataArr as $dstr) {50 foreach( (array) $dataArr as $dstr) { 51 51 $matches = array(); 52 52 53 53 // Skip this line. … … 76 76 $returnData = array(); 77 77 $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); 78 78 79 foreach( $dataArr as $dstr) {79 foreach( (array) $dataArr as $dstr) { 80 80 $matches = array(); 81 81 82 82 // Skip this line. -
wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php
61 61 $querystring = ''; 62 62 if (is_array($data)) { 63 63 // Change data in to postable data 64 foreach ( $data as $key => $val) {64 foreach ( (array) $data as $key => $val) { 65 65 if (is_array($val)) { 66 foreach ( $val as $val2) {66 foreach ( (array) $val as $val2) { 67 67 $querystring .= urlencode($key).'='.urlencode($val2).'&'; 68 68 } 69 69 } else { … … 165 165 if (!is_array($cookies)) { 166 166 $cookies = array($cookies); 167 167 } 168 foreach ( $cookies as $cookie) {168 foreach ( (array) $cookies as $cookie) { 169 169 if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) { 170 170 $this->cookies[$m[1]] = $m[2]; 171 171 } … … 212 212 // Cookies 213 213 if ($this->cookies) { 214 214 $cookie = 'Cookie: '; 215 foreach ( $this->cookies as $key => $value) {215 foreach ( (array) $this->cookies as $key => $value) { 216 216 $cookie .= "$key=$value; "; 217 217 } 218 218 $headers[] = $cookie; -
wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php
39 39 } 40 40 41 41 $wordError = array(); 42 foreach( $wordArray as $word) {42 foreach( (array) $wordArray as $word) { 43 43 if(!pspell_check($this->plink, trim($word))) 44 44 $wordError[] = $word; 45 45 } -
wp-includes/js/tinymce/tiny_mce_gzip.php
169 169 170 170 // Load all plugins and their language packs 171 171 $plugins = explode(",", $plugins); 172 foreach ( $plugins as $plugin) {172 foreach ( (array) $plugins as $plugin) { 173 173 $pluginFile = realpath("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"); 174 174 /* WP $languageFile = realpath("plugins/" . $plugin . "/langs/" . $lang . ".js"); WP */ 175 175 -
wp-includes/functions-compat.php
90 90 $keys = array_keys($input); 91 91 $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; 92 92 93 foreach ( $keys as $key) {93 foreach ( (array) $keys as $key) { 94 94 $output[$casefunc($key)] = $input[$key]; 95 95 } 96 96 -
wp-includes/capabilities.php
22 22 23 23 $this->role_objects = array(); 24 24 $this->role_names = array(); 25 foreach ( $this->roles as $role => $data) {25 foreach ( (array) $this->roles as $role => $data) { 26 26 $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']); 27 27 $this->role_names[$role] = $this->roles[$role]['name']; 28 28 } … … 174 174 175 175 //Build $allcaps from role caps, overlay user's $caps 176 176 $this->allcaps = array(); 177 foreach( $this->roles as $role) {177 foreach( (array) $this->roles as $role) { 178 178 $role = $wp_roles->get_role($role); 179 179 $this->allcaps = array_merge($this->allcaps, $role->capabilities); 180 180 } … … 197 197 } 198 198 199 199 function set_role($role) { 200 foreach( $this->roles as $oldrole)200 foreach( (array) $this->roles as $oldrole) 201 201 unset($this->caps[$oldrole]); 202 202 $this->caps[$role] = true; 203 203 $this->roles = array($role => true); … … 251 251 $caps = call_user_func_array('map_meta_cap', $args); 252 252 // Must have ALL requested caps 253 253 $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args); 254 foreach ( $caps as $cap) {254 foreach ( (array) $caps as $cap) { 255 255 //echo "Checking cap $cap<br/>"; 256 256 if(empty($capabilities[$cap]) || !$capabilities[$cap]) 257 257 return false; -
wp-includes/functions-post.php
528 528 $delete_cats = array_diff($old_categories,$post_categories); 529 529 530 530 if ($delete_cats) { 531 foreach ( $delete_cats as $del) {531 foreach ( (array) $delete_cats as $del) { 532 532 $wpdb->query(" 533 533 DELETE FROM $wpdb->post2cat 534 534 WHERE category_id = $del … … 541 541 $add_cats = array_diff($post_categories, $old_categories); 542 542 543 543 if ($add_cats) { 544 foreach ( $add_cats as $new_cat) {544 foreach ( (array) $add_cats as $new_cat) { 545 545 $wpdb->query(" 546 546 INSERT INTO $wpdb->post2cat (post_id, category_id) 547 547 VALUES ($post_ID, $new_cat)"); … … 550 550 551 551 // Update category counts. 552 552 $all_affected_cats = array_unique(array_merge($post_categories, $old_categories)); 553 foreach ( $all_affected_cats as $cat_id ) {553 foreach ( (array) $all_affected_cats as $cat_id ) { 554 554 $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'"); 555 555 $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'"); 556 556 wp_cache_delete($cat_id, 'category'); … … 572 572 if ( 'publish' == $post->post_status && 'post' == $post->post_type ) { 573 573 $categories = wp_get_post_cats('', $post->ID); 574 574 if( is_array( $categories ) ) { 575 foreach ( $categories as $cat_id ) {575 foreach ( (array) $categories as $cat_id ) { 576 576 $wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'"); 577 577 wp_cache_delete($cat_id, 'category'); 578 578 } … … 663 663 } 664 664 665 665 $trackback_urls = explode(',', $tb_list); 666 foreach( $trackback_urls as $tb_url) {666 foreach( (array) $trackback_urls as $tb_url) { 667 667 $tb_url = trim($tb_url); 668 668 trackback($tb_url, stripslashes($post_title), $excerpt, $post_id); 669 669 } … … 676 676 do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); 677 677 678 678 if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) { 679 foreach ( $chars[1] as $char) {679 foreach ( (array) $chars[1] as $char) { 680 680 // If it's an encoded char in the normal ASCII set, reject 681 681 if ( 38 == $char ) 682 682 continue; // Unless it's & … … 690 690 return false; // If moderation keys are empty 691 691 $words = explode("\n", $mod_keys ); 692 692 693 foreach ( $words as $word) {693 foreach ( (array) $words as $word) { 694 694 $word = trim($word); 695 695 696 696 // Skip empty lines … … 752 752 $post_title = apply_filters('the_title', $post->post_title); 753 753 $post_title = strip_tags($post_title); 754 754 755 if ($to_ping) : foreach ( $to_ping as $tb_ping) :755 if ($to_ping) : foreach ( (array) $to_ping as $tb_ping) : 756 756 $tb_ping = trim($tb_ping); 757 757 if ( !in_array($tb_ping, $pinged) ) { 758 758 trackback($tb_ping, $post_title, $excerpt, $post_id); … … 779 779 if ( !is_array( $custom_fields ) ) 780 780 return $pung; 781 781 782 foreach ( $custom_fields as $key => $val ) {782 foreach ( (array) $custom_fields as $key => $val ) { 783 783 if ( 'enclosure' != $key || !is_array( $val ) ) 784 784 continue; 785 foreach( $val as $enc ) {785 foreach( (array) $val as $enc ) { 786 786 $enclosure = split( "\n", $enc ); 787 787 $pung[] = trim( $enclosure[ 0 ] ); 788 788 } … … 815 815 //immediately follow their parents 816 816 function get_page_hierarchy($posts, $parent = 0) { 817 817 $result = array ( ); 818 if ($posts) { foreach ( $posts as $post) {818 if ($posts) { foreach ( (array) $posts as $post) { 819 819 if ($post->post_parent == $parent) { 820 820 $result[$post->ID] = $post->post_name; 821 821 $children = get_page_hierarchy($posts, $post->ID); … … 838 838 839 839 if ($posts) { 840 840 841 foreach ( $posts as $id => $post) {841 foreach ( (array) $posts as $id => $post) { 842 842 843 843 // URI => page name 844 844 $uri = get_page_uri($id); 845 845 $attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$id'"); 846 846 if ( $attachments ) { 847 foreach ( $attachments as $attachment ) {847 foreach ( (array) $attachments as $attachment ) { 848 848 $attach_uri = get_page_uri($attachment->ID); 849 849 $page_attachment_uris[$attach_uri] = $attachment->ID; 850 850 } … … 1030 1030 // Do Trackbacks 1031 1031 $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); 1032 1032 if ( is_array($trackbacks) ) { 1033 foreach ( $trackbacks as $trackback ) {1033 foreach ( (array) $trackbacks as $trackback ) { 1034 1034 do_trackbacks($trackback->ID); 1035 1035 } 1036 1036 } -
wp-includes/classes.php
20 20 $cnt = 0; 21 21 $id_list = explode( ',', $id_list ); 22 22 23 foreach ( $id_list as $comment ) {23 foreach ( (array) $id_list as $comment ) { 24 24 if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) { 25 25 $cnt++; 26 26 } … … 33 33 function find_spam() { 34 34 $in_queue = 0; 35 35 36 foreach( $this->comment_list as $comment ) {36 foreach( (array) $this->comment_list as $comment ) { 37 37 if( $comment->approved == 1 ) { 38 foreach( $this->spam_words as $word ) {38 foreach( (array) $this->spam_words as $word ) { 39 39 $word = trim($word); 40 40 if ( empty( $word ) ) 41 41 continue; … … 149 149 150 150 // Look for matches. 151 151 $request_match = $request; 152 foreach ( $rewrite as $match => $query) {152 foreach ( (array) $rewrite as $match => $query) { 153 153 // If the requesting file is the anchor of the match, prepend it 154 154 // to the path info. 155 155 if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) { … … 279 279 } 280 280 } 281 281 282 foreach ( $this->private_query_vars as $wpvar) {282 foreach ( (array) $this->private_query_vars as $wpvar) { 283 283 if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar] && ! isset($this->extra_query_vars[$wpvar]) ) { 284 284 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; 285 285 $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]); … … 292 292 function register_globals() { 293 293 global $wp_query; 294 294 // Extract updated query vars back into global namespace. 295 foreach ( $wp_query->query_vars as $key => $value) {295 foreach ( (array) $wp_query->query_vars as $key => $value) { 296 296 $GLOBALS[$key] = $value; 297 297 } 298 298 … … 373 373 // Return all messages if no code specified. 374 374 if ( empty($code) ) { 375 375 $all_messages = array(); 376 foreach ( $this->errors as $code => $messages )376 foreach ( (array) $this->errors as $code => $messages ) 377 377 $all_messages = array_merge($all_messages, $messages); 378 378 379 379 return $all_messages; … … 431 431 432 432 $flat = ($to_depth == -1) ? true : false; 433 433 434 foreach ( $elements as $element ) {434 foreach ( (array) $elements as $element ) { 435 435 // If flat, start and end the element and skip the level checks. 436 436 if ( $flat) { 437 437 // Start the element. -
wp-includes/template-functions-links.php
264 264 $sql_exclude_cats = ''; 265 265 if ( !empty($excluded_categories) ) { 266 266 $blah = explode(' and ', $excluded_categories); 267 foreach ( $blah as $category ) {267 foreach ( (array) $blah as $category ) { 268 268 $category = intval($category); 269 269 $sql_cat_ids = " OR pc.category_ID = '$category'"; 270 270 } … … 297 297 $sql_exclude_cats = ''; 298 298 if ( !empty($excluded_categories) ) { 299 299 $blah = explode(' and ', $excluded_categories); 300 foreach ( $blah as $category ) {300 foreach ( (array) $blah as $category ) { 301 301 $category = intval($category); 302 302 $sql_cat_ids = " OR pc.category_ID = '$category'"; 303 303 } -
wp-includes/deprecated.php
206 206 $cat_id = -1; 207 207 $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'"); 208 208 if ($results) { 209 foreach ( $results as $result) {209 foreach ( (array) $results as $result) { 210 210 $cat_id = $result->cat_ID; 211 211 } 212 212 } … … 246 246 ** 247 247 ** Use this like: 248 248 ** $links = get_linkobjectsbyname('fred'); 249 ** foreach ( $links as $link) {249 ** foreach ( (array) $links as $link) { 250 250 ** echo '<li>'.$link->link_name.'</li>'; 251 251 ** } 252 252 **/ … … 257 257 //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); 258 258 // TODO: Fix me. 259 259 if ($results) { 260 foreach ( $results as $result) {260 foreach ( (array) $results as $result) { 261 261 $cat_id = $result->cat_id; 262 262 } 263 263 } … … 280 280 ** Use this like: 281 281 ** $links = get_linkobjects(1); 282 282 ** if ($links) { 283 ** foreach ( $links as $link) {283 ** foreach ( (array) $links as $link) { 284 284 ** echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>'; 285 285 ** } 286 286 ** } … … 326 326 327 327 $results = $wpdb->get_results($sql); 328 328 if ($results) { 329 foreach ( $results as $result) {329 foreach ( (array) $results as $result) { 330 330 $result->link_url = $result->link_url; 331 331 $result->link_name = $result->link_name; 332 332 $result->link_description = $result->link_description; -
wp-includes/cron.php
58 58 $crons = get_option( 'cron' ); 59 59 if ( empty($crons) ) 60 60 return false; 61 foreach ( $crons as $timestamp => $cron )61 foreach ( (array) $crons as $timestamp => $cron ) 62 62 if ( isset( $cron[$hook] ) ) 63 63 return $timestamp; 64 64 return false; … … 85 85 return; 86 86 87 87 $schedules = wp_get_schedules(); 88 foreach ( $crons as $timestamp => $cronhooks ) {88 foreach ( (array) $crons as $timestamp => $cronhooks ) { 89 89 if ( $timestamp > time() ) break; 90 foreach ( $cronhooks as $hook => $args ) {90 foreach ( (array) $cronhooks as $hook => $args ) { 91 91 if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) ) 92 92 continue; 93 93 spawn_cron(); -
wp-includes/comment.php
12 12 if ( !empty($mod_keys) ) { 13 13 $words = explode("\n", $mod_keys ); 14 14 15 foreach ( $words as $word) {15 foreach ( (array) $words as $word) { 16 16 $word = trim($word); 17 17 18 18 // Skip empty lines … … 348 348 $comment = get_comment($commentarr['comment_ID'], ARRAY_A); 349 349 350 350 // Escape data pulled from DB. 351 foreach ( $comment as $key => $value)351 foreach ( (array) $comment as $key => $value) 352 352 $comment[$key] = $wpdb->escape($value); 353 353 354 354 // Merge old and new fields with new fields overwriting old ones. … … 418 418 // http://dummy-weblog.org/post.php 419 419 // We don't wanna ping first and second types, even if they have a valid <link/> 420 420 421 foreach( $post_links_temp[0] as $link_test) :421 foreach( (array) $post_links_temp[0] as $link_test) : 422 422 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 423 423 && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. 424 424 $test = parse_url($link_test); … … 431 431 432 432 do_action('pre_ping', array(&$post_links, &$pung)); 433 433 434 foreach ( $post_links as $pagelinkedto){434 foreach ( (array) $post_links as $pagelinkedto){ 435 435 debug_fwrite($log, "Processing -- $pagelinkedto\n"); 436 436 $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); 437 437 -
wp-includes/theme.php
120 120 121 121 sort($theme_files); 122 122 123 foreach( $theme_files as $theme_file) {123 foreach( (array) $theme_files as $theme_file) { 124 124 if ( ! is_readable("$theme_root/$theme_file") ) { 125 125 $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.')); 126 126 continue; … … 213 213 // Resolve theme dependencies. 214 214 $theme_names = array_keys($themes); 215 215 216 foreach ( $theme_names as $theme_name) {216 foreach ( (array) $theme_names as $theme_name) { 217 217 $themes[$theme_name]['Parent Theme'] = ''; 218 218 if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) { 219 foreach ( $theme_names as $parent_theme_name) {219 foreach ( (array) $theme_names as $parent_theme_name) { 220 220 if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) { 221 221 $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name']; 222 222 break; … … 247 247 $current_theme = 'WordPress Default'; 248 248 249 249 if ( $themes ) { 250 foreach ( $theme_names as $theme_name) {250 foreach ( (array) $theme_names as $theme_name) { 251 251 if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet && 252 252 $themes[$theme_name]['Template'] == $current_template ) { 253 253 $current_theme = $themes[$theme_name]['Name']; -
wp-includes/class-IXR.php
18 18 $this->type = $type; 19 19 if ($type == 'struct') { 20 20 /* 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) { 22 22 $this->data[$key] = new IXR_Value($value); 23 23 } 24 24 } … … 78 78 break; 79 79 case 'array': 80 80 $return = '<array><data>'."\n"; 81 foreach ( $this->data as $item) {81 foreach ( (array) $this->data as $item) { 82 82 $return .= ' <value>'.$item->getXml()."</value>\n"; 83 83 } 84 84 $return .= '</data></array>'; … … 86 86 break; 87 87 case 'struct': 88 88 $return = '<struct>'."\n"; 89 foreach ( $this->data as $name => $value) {89 foreach ( (array) $this->data as $name => $value) { 90 90 $name = htmlspecialchars($name); 91 91 $return .= " <member><name>$name</name><value>"; 92 92 $return .= $value->getXml()."</value></member>\n"; … … 104 104 function isStruct($array) { 105 105 /* Nasty function to check if an array is a struct or not */ 106 106 $expected = 0; 107 foreach ( $array as $key => $value) {107 foreach ( (array) $array as $key => $value) { 108 108 if ((string)$key != (string)$expected) { 109 109 return true; 110 110 } … … 397 397 function multiCall($methodcalls) { 398 398 // See http://www.xmlrpc.com/discuss/msgReader$1208 399 399 $return = array(); 400 foreach ( $methodcalls as $call) {400 foreach ( (array) $methodcalls as $call) { 401 401 $method = $call['methodName']; 402 402 $params = $call['params']; 403 403 if ($method == 'system.multicall') { … … 432 432 <params> 433 433 434 434 EOD; 435 foreach ( $this->args as $arg) {435 foreach ( (array) $this->args as $arg) { 436 436 $this->xml .= '<param><value>'; 437 437 $v = new IXR_Value($arg); 438 438 $this->xml .= $v->getXml(); … … 754 754 // We should be returning an array of types 755 755 $types = $this->signatures[$method]; 756 756 $return = array(); 757 foreach ( $types as $type) {757 foreach ( (array) $types as $type) { 758 758 switch ($type) { 759 759 case 'string': 760 760 $return[] = 'string'; -
wp-includes/kses.php
154 154 155 155 $attr2 = ''; 156 156 157 foreach ( $attrarr as $arreach) {157 foreach ( (array) $attrarr as $arreach) { 158 158 if (!@ isset ($allowed_html[strtolower($element)][strtolower($arreach['name'])])) 159 159 continue; # the attribute is not allowed 160 160 … … 169 169 else { 170 170 # there are some checks 171 171 $ok = true; 172 foreach ( $current as $currkey => $currval)172 foreach ( (array) $current as $currkey => $currval) 173 173 if (!wp_kses_check_attr_val($arreach['value'], $arreach['vless'], $currkey, $currval)) { 174 174 $ok = false; 175 175 break; … … 404 404 { 405 405 $outarray = array (); 406 406 407 foreach ( $inarray as $inkey => $inval) {407 foreach ( (array) $inarray as $inkey => $inval) { 408 408 $outkey = strtolower($inkey); 409 409 $outarray[$outkey] = array (); 410 410 411 foreach ( $inval as $inkey2 => $inval2) {411 foreach ( (array) $inval as $inkey2 => $inval2) { 412 412 $outkey2 = strtolower($inkey2); 413 413 $outarray[$outkey][$outkey2] = $inval2; 414 414 } # foreach $inval … … 457 457 $string2 = strtolower($string2); 458 458 459 459 $allowed = false; 460 foreach ( $allowed_protocols as $one_protocol)460 foreach ( (array) $allowed_protocols as $one_protocol) 461 461 if (strtolower($one_protocol) == $string2) { 462 462 $allowed = true; 463 463 break; -
wp-includes/functions.php
254 254 } 255 255 $wpdb->show_errors(); 256 256 257 foreach ( $options as $option) {257 foreach ( (array) $options as $option) { 258 258 // "When trying to design a foolproof system, 259 259 // never underestimate the ingenuity of the fools :)" -- Dougal 260 260 if ( 'siteurl' == $option->option_name ) … … 383 383 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' 384 384 AND meta_key = '$key' AND meta_value = '$value'"); 385 385 $cache_key = $post_meta_cache['$post_id'][$key]; 386 if ($cache_key) foreach ( $cache_key as $index => $data )386 if ($cache_key) foreach ( (array) $cache_key as $index => $data ) 387 387 if ( $data == $value ) 388 388 unset($post_meta_cache['$post_id'][$key][$index]); 389 389 } … … 408 408 409 409 $values = array(); 410 410 if ( $metalist ) { 411 foreach ( $metalist as $metarow) {411 foreach ( (array) $metalist as $metarow) { 412 412 $values[] = $metarow[0]; 413 413 } 414 414 } … … 447 447 meta_key = '$key' AND post_id = '$post_id'"); 448 448 $cache_key = $post_meta_cache['$post_id'][$key]; 449 449 if ( !empty($cache_key) ) 450 foreach ( $cache_key as $index => $data)450 foreach ( (array) $cache_key as $index => $data) 451 451 $post_meta_cache['$post_id'][$key][$index] = $original_value; 452 452 } else { 453 453 $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE 454 454 meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'"); 455 455 $cache_key = $post_meta_cache['$post_id'][$key]; 456 456 if ( !empty($cache_key) ) 457 foreach ( $cache_key as $index => $data)457 foreach ( (array) $cache_key as $index => $data) 458 458 if ( $data == $original_prev ) 459 459 $post_meta_cache['$post_id'][$key][$index] = $original_value; 460 460 } … … 527 527 $children = $wpdb->get_results($query); 528 528 529 529 if ( $children ) { 530 foreach ( $children as $key => $child ) {530 foreach ( (array) $children as $key => $child ) { 531 531 $post_cache[$child->ID] =& $children[$key]; 532 532 $kids[$child->ID] =& $children[$key]; 533 533 } … … 538 538 if ( $output == OBJECT ) { 539 539 return $kids; 540 540 } elseif ( $output == ARRAY_A ) { 541 foreach ( $kids as $kid )541 foreach ( (array) $kids as $kid ) 542 542 $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]); 543 543 return $weeuns; 544 544 } elseif ( $output == ARRAY_N ) { 545 foreach ( $kids as $kid )545 foreach ( (array) $kids as $kid ) 546 546 $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID])); 547 547 return $babes; 548 548 } else { … … 558 558 $page_paths = '/' . trim($page_path, '/'); 559 559 $leaf_path = sanitize_title(basename($page_paths)); 560 560 $page_paths = explode('/', $page_paths); 561 foreach( $page_paths as $pathdir)561 foreach( (array) $page_paths as $pathdir) 562 562 $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 563 563 564 564 $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'"); … … 566 566 if ( empty($pages) ) 567 567 return NULL; 568 568 569 foreach ( $pages as $page) {569 foreach ( (array) $pages as $page) { 570 570 $path = '/' . $leaf_path; 571 571 $curpage = $page; 572 572 while ($curpage->post_parent != 0) { … … 634 634 $category_paths = '/' . trim($category_path, '/'); 635 635 $leaf_path = sanitize_title(basename($category_paths)); 636 636 $category_paths = explode('/', $category_paths); 637 foreach( $category_paths as $pathdir)637 foreach( (array) $category_paths as $pathdir) 638 638 $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 639 639 640 640 $categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'"); … … 642 642 if ( empty($categories) ) 643 643 return NULL; 644 644 645 foreach ( $categories as $category) {645 foreach ( (array) $categories as $category) { 646 646 $path = '/' . $leaf_path; 647 647 $curcategory = $category; 648 648 while ($curcategory->category_parent != 0) { … … 763 763 $services = trim($services); 764 764 if ( '' != $services ) { 765 765 $services = explode("\n", $services); 766 foreach ( $services as $service) {766 foreach ( (array) $services as $service) { 767 767 weblog_ping($service); 768 768 } 769 769 } … … 907 907 debug_fwrite($log, 'Post contents:'); 908 908 debug_fwrite($log, $content."\n"); 909 909 910 foreach( $post_links_temp[0] as $link_test) :910 foreach( (array) $post_links_temp[0] as $link_test) : 911 911 if ( !in_array($link_test, $pung) ) : // If we haven't pung it already 912 912 $test = parse_url($link_test); 913 913 if ( isset($test['query']) ) … … 917 917 endif; 918 918 endforeach; 919 919 920 foreach ( $post_links as $url) :920 foreach ( (array) $post_links as $url) : 921 921 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%')") ) { 922 922 if ( $headers = wp_get_http_headers( $url) ) { 923 923 $len = (int) $headers['content-length']; … … 1044 1044 function merge_filters($tag) { 1045 1045 global $wp_filter; 1046 1046 if ( isset($wp_filter['all']) ) { 1047 foreach ( $wp_filter['all'] as $priority => $functions) {1047 foreach ( (array) $wp_filter['all'] as $priority => $functions) { 1048 1048 if ( isset($wp_filter[$tag][$priority]) ) 1049 1049 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]); 1050 1050 else … … 1067 1067 if ( !isset($wp_filter[$tag]) ) { 1068 1068 return $string; 1069 1069 } 1070 foreach ( $wp_filter[$tag] as $priority => $functions) {1070 foreach ( (array) $wp_filter[$tag] as $priority => $functions) { 1071 1071 if ( !is_null($functions) ) { 1072 foreach( $functions as $function) {1072 foreach( (array) $functions as $function) { 1073 1073 1074 1074 $all_args = array_merge(array($string), $args); 1075 1075 $function_name = $function['function']; … … 1096 1096 1097 1097 // check that we don't already have the same filter at the same priority 1098 1098 if ( isset($wp_filter[$tag]["$priority"]) ) { 1099 foreach( $wp_filter[$tag]["$priority"] as $filter) {1099 foreach( (array) $wp_filter[$tag]["$priority"] as $filter) { 1100 1100 // uncomment if we want to match function AND accepted_args 1101 1101 // if ( $filter == array($function, $accepted_args) ) { 1102 1102 if ( $filter['function'] == $function_to_add ) { … … 1115 1115 1116 1116 // rebuild the list of filters 1117 1117 if ( isset($wp_filter[$tag]["$priority"]) ) { 1118 foreach( $wp_filter[$tag]["$priority"] as $filter) {1118 foreach( (array) $wp_filter[$tag]["$priority"] as $filter) { 1119 1119 if ( $filter['function'] != $function_to_remove ) { 1120 1120 $new_function_list[] = $filter; 1121 1121 } … … 1140 1140 if ( !isset($wp_filter[$tag]) ) { 1141 1141 return; 1142 1142 } 1143 foreach ( $wp_filter[$tag] as $priority => $functions) {1143 foreach ( (array) $wp_filter[$tag] as $priority => $functions) { 1144 1144 if ( !is_null($functions) ) { 1145 foreach( $functions as $function) {1145 foreach( (array) $functions as $function) { 1146 1146 1147 1147 $function_name = $function['function']; 1148 1148 $accepted_args = $function['accepted_args']; … … 1213 1213 $incposts = preg_split('/[\s,]+/',$include); 1214 1214 $numberposts = count($incposts); // only the number of posts included 1215 1215 if ( count($incposts) ) { 1216 foreach ( $incposts as $incpost ) {1216 foreach ( (array) $incposts as $incpost ) { 1217 1217 if (empty($inclusions)) 1218 1218 $inclusions = ' AND ( ID = ' . intval($incpost) . ' '; 1219 1219 else … … 1228 1228 if ( !empty($exclude) ) { 1229 1229 $exposts = preg_split('/[\s,]+/',$exclude); 1230 1230 if ( count($exposts) ) { 1231 foreach ( $exposts as $expost ) {1231 foreach ( (array) $exposts as $expost ) { 1232 1232 if (empty($exclusions)) 1233 1233 $exclusions = ' AND ( ID <> ' . intval($expost) . ' '; 1234 1234 else … … 1306 1306 if ( empty($dogs) ) 1307 1307 return; 1308 1308 1309 foreach ( $dogs as $catt)1309 foreach ( (array) $dogs as $catt) 1310 1310 $category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id); 1311 1311 } 1312 1312 … … 1332 1332 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) ) { 1333 1333 // Change from flat structure to hierarchical: 1334 1334 $post_meta_cache = array(); 1335 foreach ( $meta_list as $metarow) {1335 foreach ( (array) $meta_list as $metarow) { 1336 1336 $mpid = $metarow['post_id']; 1337 1337 $mkey = $metarow['meta_key']; 1338 1338 $mval = $metarow['meta_value']; … … 1411 1411 $qs[func_get_arg(0)] = func_get_arg(1); 1412 1412 } 1413 1413 1414 foreach( $qs as $k => $v) {1414 foreach( (array) $qs as $k => $v) { 1415 1415 if ( $v != '' ) { 1416 1416 if ( $ret != '' ) 1417 1417 $ret .= '&'; … … 1429 1429 function add_magic_quotes($array) { 1430 1430 global $wpdb; 1431 1431 1432 foreach ( $array as $k => $v) {1432 foreach ( (array) $array as $k => $v) { 1433 1433 if ( is_array($v) ) { 1434 1434 $array[$k] = add_magic_quotes($v); 1435 1435 } else { … … 1511 1511 return ''; 1512 1512 } 1513 1513 1514 foreach ( $metas as $index => $meta) {1514 foreach ( (array) $metas as $index => $meta) { 1515 1515 @ $value = unserialize($meta->meta_value); 1516 1516 if ( $value === FALSE ) 1517 1517 $value = $meta->meta_value; -
wp-includes/pluggable-functions.php
77 77 $wpdb->show_errors(); 78 78 79 79 if ($metavalues) { 80 foreach ( $metavalues as $meta ) {80 foreach ( (array) $metavalues as $meta ) { 81 81 @ $value = unserialize($meta->meta_value); 82 82 if ($value === FALSE) 83 83 $value = $meta->meta_value; … … 130 130 $wpdb->show_errors(); 131 131 132 132 if ($metavalues) { 133 foreach ( $metavalues as $meta ) {133 foreach ( (array) $metavalues as $meta ) { 134 134 @ $value = unserialize($meta->meta_value); 135 135 if ($value === FALSE) 136 136 $value = $meta->meta_value; … … 265 265 if ( !function_exists('check_ajax_referer') ) : 266 266 function check_ajax_referer() { 267 267 $cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie 268 foreach ( $cookie as $tasty ) {268 foreach ( (array) $cookie as $tasty ) { 269 269 if ( false !== strpos($tasty, USER_COOKIE) ) 270 270 $user = substr(strstr($tasty, '='), 1); 271 271 if ( false !== strpos($tasty, PASS_COOKIE) ) -
wp-includes/script-loader.php
84 84 if ( ! $handles = (array) $handles ) 85 85 return array(); 86 86 $return = array(); 87 foreach ( $handles as $handle ) {87 foreach ( (array) $handles as $handle ) { 88 88 $handle = explode('?', $handle); 89 89 if ( isset($handle[1]) ) 90 90 $this->args[$handle[0]] = $handle[1]; -
wp-includes/feed-functions.php
131 131 function the_category_rss($type = 'rss') { 132 132 $categories = get_the_category(); 133 133 $the_list = ''; 134 foreach ( $categories as $category) {134 foreach ( (array) $categories as $category) { 135 135 $category->cat_name = convert_chars($category->cat_name); 136 136 if ('rdf' == $type) { 137 137 $the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>"; … … 151 151 while( list( $key, $val ) = each( $custom_fields ) ) { 152 152 if( $key == 'enclosure' ) { 153 153 if (is_array($val)) { 154 foreach( $val as $enc) {154 foreach( (array) $val as $enc) { 155 155 $enclosure = split( "\n", $enc ); 156 156 print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n"; 157 157 } -
wp-includes/vars.php
92 92 93 93 94 94 // generates smilies' search & replace arrays 95 foreach( $wpsmiliestrans as $smiley => $img) {95 foreach( (array) $wpsmiliestrans as $smiley => $img) { 96 96 $wp_smiliessearch[] = $smiley; 97 97 $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES); 98 98 $wp_smiliesreplace[] = " <img src='" . get_settings('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> "; -
wp-includes/rss-functions.php
524 524 if ( $rss and !$rss->ERROR) { 525 525 526 526 // find Etag, and Last-Modified 527 foreach( $resp->headers as $h) {527 foreach( (array) $resp->headers as $h) { 528 528 // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" 529 529 if (strpos($h, ": ")) { 530 530 list($field, $val) = explode(": ", $h, 2); … … 823 823 if ( $rss ) { 824 824 echo "<ul>"; 825 825 $rss->items = array_slice($rss->items, 0, $num_items); 826 foreach ( $rss->items as $item ) {826 foreach ( (array) $rss->items as $item ) { 827 827 echo "<li>\n"; 828 828 echo "<a href='$item[link]' title='$item[description]'>"; 829 829 echo htmlentities($item['title']); … … 841 841 $rss = fetch_rss($url); 842 842 if ( $rss ) { 843 843 $rss->items = array_slice($rss->items, 0, $num_items); 844 foreach ( $rss->items as $item ) {844 foreach ( (array) $rss->items as $item ) { 845 845 echo "<li>\n"; 846 846 echo "<a href='$item[link]' title='$item[description]'>"; 847 847 echo htmlentities($item['title']); -
wp-includes/template-functions-author.php
179 179 $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; 180 180 $authors = $wpdb->get_results($query); 181 181 182 foreach ( $authors as $author ) {182 foreach ( (array) $authors as $author ) { 183 183 $author = get_userdata( $author->ID ); 184 184 $posts = get_usernumposts($author->ID); 185 185 $name = $author->nickname; -
xmlrpc.php
157 157 function escape(&$array) { 158 158 global $wpdb; 159 159 160 foreach ( $array as $k => $v) {160 foreach ( (array) $array as $k => $v) { 161 161 if (is_array($v)) { 162 162 $this->escape($array[$k]); 163 163 } else if (is_object($v)) { … … 282 282 return $this->error; 283 283 } 284 284 285 foreach ( $posts_list as $entry) {285 foreach ( (array) $posts_list as $entry) { 286 286 287 287 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); 288 288 $categories = implode(',', wp_get_post_cats(1, $entry['ID'])); … … 573 573 $post_category = array(); 574 574 575 575 if (is_array($catnames)) { 576 foreach ( $catnames as $cat) {576 foreach ( (array) $catnames as $cat) { 577 577 $post_category[] = get_cat_ID($cat); 578 578 } 579 579 } … … 625 625 $post_category = array(); 626 626 627 627 if (is_array($catnames)) { 628 foreach ( $catnames as $cat) {628 foreach ( (array) $catnames as $cat) { 629 629 $post_category[] = get_cat_ID($cat); 630 630 } 631 631 } … … 696 696 697 697 $categories = array(); 698 698 $catids = wp_get_post_cats('', $post_ID); 699 foreach( $catids as $catid) {699 foreach( (array) $catids as $catid) { 700 700 $categories[] = get_cat_name($catid); 701 701 } 702 702 … … 751 751 return $this->error; 752 752 } 753 753 754 foreach ( $posts_list as $entry) {754 foreach ( (array) $posts_list as $entry) { 755 755 756 756 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); 757 757 $categories = array(); 758 758 $catids = wp_get_post_cats('', $entry['ID']); 759 foreach( $catids as $catid) {759 foreach( (array) $catids as $catid) { 760 760 $categories[] = get_cat_name($catid); 761 761 } 762 762 … … 813 813 814 814 // FIXME: can we avoid using direct SQL there? 815 815 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) { 817 817 $struct['categoryId'] = $cat['cat_ID']; 818 818 $struct['description'] = $cat['cat_name']; 819 819 $struct['categoryName'] = $cat['cat_name']; … … 891 891 return $this->error; 892 892 } 893 893 894 foreach ( $posts_list as $entry) {894 foreach ( (array) $posts_list as $entry) { 895 895 896 896 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); 897 897 … … 932 932 933 933 // FIXME: can we avoid using direct SQL there? 934 934 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) { 936 936 $struct['categoryId'] = $cat['cat_ID']; 937 937 $struct['categoryName'] = $cat['cat_name']; 938 938 … … 961 961 $catids = wp_get_post_cats('', intval($post_ID)); 962 962 // first listed category will be the primary category 963 963 $isPrimary = true; 964 foreach( $catids as $catid) {964 foreach( (array) $catids as $catid) { 965 965 $categories[] = array( 966 966 'categoryName' => get_cat_name($catid), 967 967 'categoryId' => $catid, … … 992 992 if ( !current_user_can('edit_post', $post_ID) ) 993 993 return new IXR_Error(401, 'Sorry, you can not edit this post.'); 994 994 995 foreach( $categories as $cat) {995 foreach( (array) $categories as $cat) { 996 996 $catids[] = $cat['categoryId']; 997 997 } 998 998 … … 1006 1006 function mt_supportedMethods($args) { 1007 1007 1008 1008 $supported_methods = array(); 1009 foreach( $this->methods as $key=>$value) {1009 foreach( (array) $this->methods as $key=>$value) { 1010 1010 $supported_methods[] = $key; 1011 1011 } 1012 1012 … … 1041 1041 } 1042 1042 1043 1043 $trackback_pings = array(); 1044 foreach( $comments as $comment) {1044 foreach( (array) $comments as $comment) { 1045 1045 if ( 'trackback' == $comment->comment_type ) { 1046 1046 $content = $comment->comment_content; 1047 1047 $title = substr($content, 8, (strpos($content, '</strong>') - 8)); … … 1205 1205 $link = preg_replace( $sem_regexp_pb, $sem_regexp_fix, $pagelinkedfrom ); 1206 1206 1207 1207 $finished = false; 1208 foreach ( $p as $para ) {1208 foreach ( (array) $p as $para ) { 1209 1209 if ( $finished ) 1210 1210 continue; 1211 1211 if ( strstr( $para, $pagelinkedto ) ) { … … 1274 1274 } 1275 1275 1276 1276 $pingbacks = array(); 1277 foreach( $comments as $comment) {1277 foreach( (array) $comments as $comment) { 1278 1278 if ( 'pingback' == $comment->comment_type ) 1279 1279 $pingbacks[] = $comment->comment_author_url; 1280 1280 } -
wp-mail.php
30 30 $bodysignal = 0; 31 31 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 32 32 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); 33 foreach ( $message as $line) :33 foreach ( (array) $message as $line) : 34 34 if (strlen($line) < 3) $bodysignal = 1; 35 35 36 36 if ($bodysignal) { -
wp-content/plugins/wp-db-backup.php
81 81 <script type="text/javascript"><!--\\ 82 82 '; 83 83 if($this->backup_errors) { 84 foreach( $this->backup_errors as $error) {84 foreach( (array) $this->backup_errors as $error) { 85 85 echo "window.parent.addError('$error');\n"; 86 86 } 87 87 } … … 198 198 $core_tables = $_POST['core_tables']; 199 199 $tables = array_merge($core_tables, $also_backup); 200 200 $step_count = 1; 201 foreach ( $tables as $table) {201 foreach ( (array) $tables as $table) { 202 202 $rec_count = $wpdb->get_var("SELECT count(*) FROM {$table}"); 203 203 $rec_segments = ceil($rec_count / ROWS_PER_SEGMENT); 204 204 $table_count = 0; … … 279 279 if($this->fp) $this->close($this->fp); 280 280 281 281 if($this->backup_errors) { 282 foreach( $this->backup_errors as $error) {282 foreach( (array) $this->backup_errors as $error) { 283 283 echo "window.parent.addError('$error');\n"; 284 284 } 285 285 } … … 472 472 473 473 if(($segment == 'none') || ($segment >= 0)) { 474 474 $ints = array(); 475 foreach ( $table_structure as $struct) {475 foreach ( (array) $table_structure as $struct) { 476 476 if ( (0 === strpos($struct->Type, 'tinyint')) || 477 477 (0 === strpos(strtolower($struct->Type), 'smallint')) || 478 478 (0 === strpos(strtolower($struct->Type), 'mediumint')) || … … 510 510 $search = array("\x00", "\x0a", "\x0d", "\x1a"); 511 511 $replace = array('\0', '\n', '\r', '\Z'); 512 512 if($table_data) { 513 foreach ( $table_data as $row) {513 foreach ( (array) $table_data as $row) { 514 514 $values = array(); 515 foreach ( $row as $key => $value) {515 foreach ( (array) $row as $key => $value) { 516 516 if ($ints[strtolower($key)]) { 517 517 $values[] = $value; 518 518 } else { … … 588 588 else 589 589 $tables = $core_tables; 590 590 591 foreach ( $tables as $table) {591 foreach ( (array) $tables as $table) { 592 592 // Increase script execution time-limit to 15 min for every table. 593 593 if ( !ini_get('safe_mode')) @set_time_limit(15*60); 594 594 // Create the SQL statements … … 702 702 703 703 if (count($this->backup_errors)) { 704 704 $feedback .= '<div class="updated error">' . __('The following errors were reported:') . "<pre>"; 705 foreach( $this->backup_errors as $error) {705 foreach( (array) $this->backup_errors as $error) { 706 706 $feedback .= "{$error}\n"; //Errors are already localized 707 707 } 708 708 $feedback .= "</pre></div>"; … … 763 763 echo '<form method="post">'; 764 764 echo '<table align="center" cellspacing="5" cellpadding="5"><tr><td width="50%" align="left" class="alternate" valign="top">'; 765 765 echo __('These core WordPress tables will always be backed up:') . '<br /><ul>'; 766 foreach ( $wp_backup_default_tables as $table) {766 foreach ( (array) $wp_backup_default_tables as $table) { 767 767 echo "<li><input type='hidden' name='core_tables[]' value='$table' />$table</li>"; 768 768 } 769 769 echo '</ul></td><td width="50%" align="left" valign="top">'; 770 770 if (count($other_tables) > 0) { 771 771 echo __('You may choose to include any of the following tables:') . ' <br />'; 772 foreach ( $other_tables as $table) {772 foreach ( (array) $other_tables as $table) { 773 773 echo "<label style=\"display:block;\"><input type='checkbox' name='other_tables[]' value='{$table}' /> {$table}</label>"; 774 774 } 775 775 } … … 784 784 // Check DB dize. 785 785 $table_status = $wpdb->get_results("SHOW TABLE STATUS FROM " . $this->backquote(DB_NAME)); 786 786 $core_size = $db_size = 0; 787 foreach( $table_status as $table) {787 foreach( (array) $table_status as $table) { 788 788 $table_size = $table->Data_length - $table->Data_free; 789 789 if(in_array($table->Name, $wp_backup_default_tables)) { 790 790 $core_size += $table_size; … … 816 816 echo __('Schedule: '); 817 817 $wp_cron_backup_schedule = get_option('wp_cron_backup_schedule'); 818 818 $schedule = array(0 => __('None'), 1 => __('Daily')); 819 foreach ( $schedule as $value => $name) {819 foreach ( (array) $schedule as $value => $name) { 820 820 echo ' <input type="radio" name="cron_schedule"'; 821 821 if ($wp_cron_backup_schedule == $value) { 822 822 echo ' checked="checked" '; … … 836 836 } 837 837 if (count($other_tables) > 0) { 838 838 echo '<tr><td colspan="2" align="left">' . __('Tables to include:') . '<br />'; 839 foreach ( $other_tables as $table) {839 foreach ( (array) $other_tables as $table) { 840 840 echo '<input type="checkbox" '; 841 841 if (in_array($table, $cron_tables)) { 842 842 echo 'checked=checked '; -
wp-content/themes/classic/comments.php
11 11 <?php if ( $comments ) : ?> 12 12 <ol id="commentlist"> 13 13 14 <?php foreach ( $comments as $comment) : ?>14 <?php foreach ( (array) $comments as $comment) : ?> 15 15 <li id="comment-<?php comment_ID() ?>"> 16 16 <?php comment_text() ?> 17 17 <p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?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
1 1 <?php 2 2 /* Don't remove these lines. */ 3 3 add_filter('comment_text', 'popuplinks'); 4 foreach ( $posts as $post) { start_wp();4 foreach ( (array) $posts as $post) { start_wp(); 5 5 ?> 6 6 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 7 7 <html xmlns="http://www.w3.org/1999/xhtml"> … … 40 40 41 41 <?php if ($comments) { ?> 42 42 <ol id="commentlist"> 43 <?php foreach ( $comments as $comment) { ?>43 <?php foreach ( (array) $comments as $comment) { ?> 44 44 <li id="comment-<?php comment_ID() ?>"> 45 45 <?php comment_text() ?> 46 46 <p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p> -
wp-content/themes/default/footer.php
14 14 <!-- Gorgeous design by Michael Heilemann - http://binarybonsai.com/kubrick/ --> 15 15 <?php /* "Just what do you think you're doing Dave?" */ ?> 16 16 17 <!-- 18 <?php print_r($wpdb->queries); ?> 19 --> 17 20 <?php wp_footer(); ?> 18 21 </body> 19 22 </html> -
wp-content/themes/default/images/header-img.php
9 9 // Assign and validate the color values 10 10 $default = false; 11 11 $vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2')); 12 foreach ( $vars as $var => $subvars ) {12 foreach ( (array) $vars as $var => $subvars ) { 13 13 if ( isset($_GET[$var]) ) { 14 foreach ( $subvars as $index => $subvar ) {14 foreach ( (array) $subvars as $index => $subvar ) { 15 15 $length = strlen($_GET[$var]) / 3; 16 16 $v = substr($_GET[$var], $index * $length, $length); 17 17 if ( $length == 1 ) $v = '' . $v . $v; -
wp-content/themes/default/comments.php
24 24 25 25 <ol class="commentlist"> 26 26 27 <?php foreach ( $comments as $comment) : ?>27 <?php foreach ( (array) $comments as $comment) : ?> 28 28 29 29 <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>"> 30 30 <cite><?php comment_author_link() ?></cite> Says: -
wp-content/themes/default/comments-popup.php
1 1 <?php 2 2 /* Don't remove these lines. */ 3 3 add_filter('comment_text', 'popuplinks'); 4 foreach ( $posts as $post) { start_wp();4 foreach ( (array) $posts as $post) { start_wp(); 5 5 ?> 6 6 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 7 7 <html xmlns="http://www.w3.org/1999/xhtml"> … … 40 40 41 41 <?php if ($comments) { ?> 42 42 <ol id="commentlist"> 43 <?php foreach ( $comments as $comment) { ?>43 <?php foreach ( (array) $comments as $comment) { ?> 44 44 <li id="comment-<?php comment_ID() ?>"> 45 45 <?php comment_text() ?> 46 46 <p><cite><?php comment_type('Comment', 'Trackback', 'Pingback'); ?> by <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p> -
wp-register.php
104 104 <div class="error"> 105 105 <p> 106 106 <?php 107 foreach( $errors as $error) echo "$error<br />";107 foreach( (array) $errors as $error) echo "$error<br />"; 108 108 ?> 109 109 </p> 110 110 </div> -
wp-links-opml.php
36 36 $prev_cat_id = 0; 37 37 $results = $wpdb->get_results($sql); 38 38 if ($results) { 39 foreach ( $results as $result) {39 foreach ( (array) $results as $result) { 40 40 if ($result->link_category != $prev_cat_id) { // new category 41 41 if ($prev_cat_id != 0) { // not first time 42 42 ?> -
wp-rss2.php
27 27 <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator> 28 28 <language><?php echo get_option('rss_language'); ?></language> 29 29 <?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(); ?> 31 31 <item> 32 32 <title><?php the_title_rss() ?></title> 33 33 <link><?php permalink_single_rss() ?></link> -
wp-commentsrss2.php
45 45 } 46 46 // this line is WordPress' motor, do not delete it. 47 47 if ($comments) { 48 foreach ( $comments as $comment) {48 foreach ( (array) $comments as $comment) { 49 49 $GLOBALS['comment'] =& $comment; 50 50 // Some plugins may need to know the metadata 51 51 // associated with this comment's post: -
wp-atom.php
23 23 <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright> 24 24 <generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator> 25 25 <?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(); ?> 27 27 <entry> 28 28 <author> 29 29 <name><?php the_author() ?></name> -
wp-settings.php
11 11 $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix'); 12 12 13 13 $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 ) 15 15 if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) 16 16 unset($GLOBALS[$k]); 17 17 } … … 173 173 if ( get_settings('active_plugins') ) { 174 174 $current_plugins = get_settings('active_plugins'); 175 175 if ( is_array($current_plugins) ) { 176 foreach ( $current_plugins as $plugin) {176 foreach ( (array) $current_plugins as $plugin) { 177 177 if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin)) 178 178 include_once(ABSPATH . 'wp-content/plugins/' . $plugin); 179 179 } -
wp-cron.php
9 9 $crons = get_option('cron'); 10 10 if (!is_array($crons) || array_shift(array_keys($crons)) > time()) 11 11 return; 12 foreach ( $crons as $timestamp => $cronhooks) {12 foreach ( (array) $crons as $timestamp => $cronhooks) { 13 13 if ($timestamp > time()) break; 14 foreach( $cronhooks as $hook => $args) {14 foreach( (array) $cronhooks as $hook => $args) { 15 15 do_action($hook, $args['args']); 16 16 $schedule = $args['schedule']; 17 17 if($schedule != false) { -
wp-admin/menu-header.php
5 5 6 6 get_admin_page_parent(); 7 7 8 foreach ( $menu as $item) {8 foreach ( (array) $menu as $item) { 9 9 $class = ''; 10 10 11 11 // 0 = name, 1 = capability, 2 = file … … 28 28 ?> 29 29 <ul id="submenu"> 30 30 <?php 31 foreach ( $submenu["$parent_file"] as $item) :31 foreach ( (array) $submenu["$parent_file"] as $item) : 32 32 if ( !current_user_can($item[1]) ) 33 33 continue; 34 34 -
wp-admin/inline-uploading.php
198 198 var filename = new Array(); 199 199 var icon = new Array(); 200 200 "; 201 foreach ( $attachments as $key => $attachment ) {201 foreach ( (array) $attachments as $key => $attachment ) { 202 202 $ID = $attachment['ID']; 203 203 $href = get_attachment_link($ID); 204 204 $meta = get_post_meta($ID, '_wp_attachment_metadata', true); -
wp-admin/update-links.php
35 35 36 36 $returns = explode("\n", $body); 37 37 38 foreach ( $returns as $return) :38 foreach ( (array) $returns as $return) : 39 39 $time = $wpdb->escape( substr($return, 0, 19) ); 40 40 $uri = $wpdb->escape( preg_replace('/(.*?) | (.*?)/', '$2', $return) ); 41 41 $wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'"); -
wp-admin/users.php
22 22 23 23 $userids = $_POST['users']; 24 24 $update = 'promote'; 25 foreach( $userids as $id) {25 foreach( (array) $userids as $id) { 26 26 // The new role of the current user must also have edit_users caps 27 27 if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) { 28 28 $update = 'err_admin_role'; … … 51 51 $userids = $_POST['users']; 52 52 53 53 $update = 'del'; 54 foreach ( $userids as $id) {54 foreach ( (array) $userids as $id) { 55 55 if($id == $current_user->id) { 56 56 $update = 'err_admin_del'; 57 57 continue; … … 93 93 <ul> 94 94 <?php 95 95 $go_delete = false; 96 foreach ( $userids as $id) {96 foreach ( (array) $userids as $id) { 97 97 $user = new WP_User($id); 98 98 if ($id == $current_user->id) { 99 99 echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; … … 104 104 } 105 105 $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login"); 106 106 $user_dropdown = '<select name="reassign_user">'; 107 foreach ( $all_logins as $login) {107 foreach ( (array) $all_logins as $login) { 108 108 if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) ) { 109 109 $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>"; 110 110 } … … 149 149 150 150 $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;"); 151 151 152 foreach( $userids as $userid) {152 foreach( (array) $userids as $userid) { 153 153 $tmp_user = new WP_User($userid); 154 154 $roles = $tmp_user->roles; 155 155 $role = array_shift($roles); … … 194 194 <div class="error"> 195 195 <ul> 196 196 <?php 197 foreach ( $errors->get_error_messages() as $message )197 foreach ( (array) $errors->get_error_messages() as $message ) 198 198 echo "<li>$message</li>"; 199 199 ?> 200 200 </ul> … … 209 209 <h2><?php _e('User List by Role'); ?></h2> 210 210 <table class="widefat"> 211 211 <?php 212 foreach( $roleclasses as $role => $roleclass) {212 foreach( (array) $roleclasses as $role => $roleclass) { 213 213 ksort($roleclass); 214 214 ?> 215 215 … … 229 229 </thead> 230 230 <tbody id="role-<?php echo $role; ?>"><?php 231 231 $style = ''; 232 foreach ( $roleclass as $user_object) {232 foreach ( (array) $roleclass as $user_object) { 233 233 $style = (' class="alternate"' == $style) ? '' : ' class="alternate"'; 234 234 echo "\n\t" . user_row( $user_object, $style ); 235 235 } -
wp-admin/edit-comments.php
54 54 check_admin_referer('bulk-comments'); 55 55 56 56 $i = 0; 57 foreach ( $_POST['delete_comments'] as $comment) : // Check the permissions on each57 foreach ( (array) $_POST['delete_comments'] as $comment) : // Check the permissions on each 58 58 $comment = (int) $comment; 59 59 $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); 60 60 // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); … … 101 101 102 102 echo "<ol id='the-list' class='commentlist' $start>"; 103 103 $i = 0; 104 foreach ( $comments as $comment) {104 foreach ( (array) $comments as $comment) { 105 105 ++$i; $class = ''; 106 106 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 107 107 $comment_status = wp_get_comment_status($comment->comment_ID); … … 133 133 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p> 134 134 </li> 135 135 136 <?php } // end foreach( $comment) ?>136 <?php } // end foreach( (array) $comment) ?> 137 137 </ol> 138 138 139 139 <div id="ajax-response"></div> … … 163 163 <th scope="col" colspan="3">' . __('Actions') . '</th> 164 164 </tr> 165 165 </thead>'; 166 foreach ( $comments as $comment) {166 foreach ( (array) $comments as $comment) { 167 167 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 168 168 $comment_status = wp_get_comment_status($comment->comment_ID); 169 169 $class = ('alternate' == $class) ? '' : 'alternate'; -
wp-admin/admin-ajax.php
121 121 die('-1'); 122 122 $names = explode(',', $_POST['newcat']); 123 123 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 124 foreach ( $names as $cat_name ) {124 foreach ( (array) $names as $cat_name ) { 125 125 $cat_name = trim($cat_name); 126 126 if ( !$category_nicename = sanitize_title($cat_name) ) 127 127 die('0'); … … 215 215 require_once( ABSPATH . WPINC . '/registration-functions.php'); 216 216 $user_id = add_user(); 217 217 if ( is_wp_error( $user_id ) ) { 218 foreach( $user_id->get_error_messages() as $message )218 foreach( (array) $user_id->get_error_messages() as $message ) 219 219 echo "$message<br />"; 220 220 exit; 221 221 } elseif ( !$user_id ) { -
wp-admin/profile-update.php
12 12 $errors = edit_user($user_ID); 13 13 14 14 if ( is_wp_error( $errors ) ) { 15 foreach( $errors->get_error_messages() as $message )15 foreach( (array) $errors->get_error_messages() as $message ) 16 16 echo "$message<br />"; 17 17 exit; 18 18 } -
wp-admin/install-helper.php
10 10 */ 11 11 function maybe_create_table($table_name, $create_ddl) { 12 12 global $wpdb; 13 foreach ( $wpdb->get_col("SHOW TABLES",0) as $table ) {13 foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) { 14 14 if ($table == $table_name) { 15 15 return true; 16 16 } … … 18 18 //didn't find it try to create it. 19 19 $q = $wpdb->query($create_ddl); 20 20 // 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 ) { 22 22 if ($table == $table_name) { 23 23 return true; 24 24 } … … 34 34 */ 35 35 function maybe_add_column($table_name, $column_name, $create_ddl) { 36 36 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 ) { 38 38 if ($debug) echo("checking $column == $column_name<br />"); 39 39 if ($column == $column_name) { 40 40 return true; … … 43 43 //didn't find it try to create it. 44 44 $q = $wpdb->query($create_ddl); 45 45 // 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 ) { 47 47 if ($column == $column_name) { 48 48 return true; 49 49 } … … 60 60 */ 61 61 function maybe_drop_column($table_name, $column_name, $drop_ddl) { 62 62 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 ) { 64 64 if ($column == $column_name) { 65 65 //found it try to drop it. 66 66 $q = $wpdb->query($drop_ddl); 67 67 // 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 ) { 69 69 if ($column == $column_name) { 70 70 return false; 71 71 } … … 96 96 $diffs = 0; 97 97 $results = $wpdb->get_results("DESC $table_name"); 98 98 99 foreach ( $results as $row ) {99 foreach ( (array) $results as $row ) { 100 100 if ($debug > 1) print_r($row); 101 101 if ($row->Field == $col_name) { 102 102 // got our column, check the params -
wp-admin/theme-editor.php
93 93 <?php _e('Select theme to edit:') ?> 94 94 <select name="theme" id="theme"> 95 95 <?php 96 foreach ( $themes as $a_theme) {96 foreach ( (array) $themes as $a_theme) { 97 97 $theme_name = $a_theme['Name']; 98 98 if ($theme_name == $theme) $selected = " selected='selected'"; 99 99 else $selected = ''; … … 121 121 if ($allowed_files) : 122 122 ?> 123 123 <ul> 124 <?php foreach( $allowed_files as $allowed_file) : ?>124 <?php foreach( (array) $allowed_files as $allowed_file) : ?> 125 125 <li><a href="theme-editor.php?file=<?php echo "$allowed_file"; ?>&theme=<?php echo urlencode($theme) ?>"><?php echo get_file_description($allowed_file); ?></a></li> 126 126 <?php endforeach; ?> 127 127 </ul> -
wp-admin/upgrade-functions.php
187 187 // Get the title and ID of every post, post_name to check if it already has a value 188 188 $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''"); 189 189 if ($posts) { 190 foreach( $posts as $post) {190 foreach( (array) $posts as $post) { 191 191 if ('' == $post->post_name) { 192 192 $newtitle = sanitize_title($post->post_title); 193 193 $wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'"); … … 196 196 } 197 197 198 198 $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) { 200 200 if ('' == $category->category_nicename) { 201 201 $newtitle = sanitize_title($category->cat_name); 202 202 $wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'"); … … 210 210 211 211 $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat"); 212 212 if ($done_ids) : 213 foreach ( $done_ids as $done_id) :213 foreach ( (array) $done_ids as $done_id) : 214 214 $done_posts[] = $done_id->post_id; 215 215 endforeach; 216 216 $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; … … 220 220 221 221 $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); 222 222 if ($allposts) : 223 foreach ( $allposts as $post) {223 foreach ( (array) $allposts as $post) { 224 224 // Check to see if it's already been imported 225 225 $cat = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post->ID AND category_id = $post->post_category"); 226 226 if (!$cat && 0 != $post->post_category) { // If there's no result … … 254 254 255 255 // Set user_nicename. 256 256 $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users"); 257 foreach ( $users as $user) {257 foreach ( (array) $users as $user) { 258 258 if ('' == $user->user_nicename) { 259 259 $newname = sanitize_title($user->user_nickname); 260 260 $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'"); … … 262 262 } 263 263 264 264 $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); 265 foreach ( $users as $row) {265 foreach ( (array) $users as $row) { 266 266 if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { 267 267 $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\''); 268 268 } … … 311 311 // Remove extraneous backslashes. 312 312 $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts"); 313 313 if ($posts) { 314 foreach( $posts as $post) {314 foreach( (array) $posts as $post) { 315 315 $post_content = addslashes(deslash($post->post_content)); 316 316 $post_title = addslashes(deslash($post->post_title)); 317 317 $post_excerpt = addslashes(deslash($post->post_excerpt)); … … 327 327 // Remove extraneous backslashes. 328 328 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments"); 329 329 if ($comments) { 330 foreach( $comments as $comment) {330 foreach( (array) $comments as $comment) { 331 331 $comment_content = addslashes(deslash($comment->comment_content)); 332 332 $comment_author = addslashes(deslash($comment->comment_author)); 333 333 $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'"); … … 337 337 // Remove extraneous backslashes. 338 338 $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links"); 339 339 if ($links) { 340 foreach( $links as $link) {340 foreach( (array) $links as $link) { 341 341 $link_name = addslashes(deslash($link->link_name)); 342 342 $link_description = addslashes(deslash($link->link_description)); 343 343 $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'"); … … 370 370 371 371 // Some versions have multiple duplicate option_name rows with the same values 372 372 $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 ) { 374 374 if ( 1 != $option->dupes ) { // Could this be done in the query? 375 375 $limit = $option->dupes - 1; 376 376 $dupe_ids = $wpdb->get_col("SELECT option_id FROM $wpdb->options WHERE option_name = '$option->option_name' LIMIT $limit"); … … 388 388 populate_roles_160(); 389 389 390 390 $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); 391 foreach ( $users as $user ) :391 foreach ( (array) $users as $user ) : 392 392 if ( !empty( $user->user_firstname ) ) 393 393 update_usermeta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) ); 394 394 if ( !empty( $user->user_lastname ) ) … … 432 432 endforeach; 433 433 $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' ); 434 434 $wpdb->hide_errors(); 435 foreach ( $old_user_fields as $old )435 foreach ( (array) $old_user_fields as $old ) 436 436 $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); 437 437 $wpdb->show_errors(); 438 438 439 439 if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts 440 440 $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"); 441 foreach ( $categories as $cat_id ) {441 foreach ( (array) $categories as $cat_id ) { 442 442 $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'"); 443 443 $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'"); 444 444 } … … 447 447 // populate comment_count field of posts table 448 448 $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); 449 449 if( is_array( $comments ) ) { 450 foreach ( $comments as $comment) {450 foreach ( (array) $comments as $comment) { 451 451 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" ); 452 452 } 453 453 } … … 456 456 // the mime type in post_type instead of post_mime_type. 457 457 if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) { 458 458 $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) { 460 460 $wpdb->query("UPDATE $wpdb->posts SET post_status = 'attachment', 461 461 post_mime_type = '$object->post_type', 462 462 post_type = '' … … 476 476 // Update status and type. 477 477 $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); 478 478 479 if ( ! empty($posts) ) foreach ( $posts as $post) {479 if ( ! empty($posts) ) foreach ( (array) $posts as $post) { 480 480 $status = $post->post_status; 481 481 $type = 'post'; 482 482 … … 503 503 504 504 $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'"); 505 505 if ( !empty($posts) ) 506 foreach ( $posts as $post )506 foreach ( (array) $posts as $post ) 507 507 wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', $post->ID); 508 508 } 509 509 if ( $wp_current_db_version < 3570 ) { 510 510 // Create categories for link categories if a category with the same 511 511 // name doesn't exist. Create a map of link cat IDs to cat IDs. 512 512 $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) { 514 514 if ( $cat_id = category_exists($link_cat->cat_name) ) { 515 515 $link_cat_id_map[$link_cat->cat_id] = $cat_id; 516 516 $default_link_cat = $cat_id; … … 522 522 523 523 // Associate links to cats. 524 524 $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 ) { 526 526 $link_cat = $link_cat_id_map[$link->link_category]; 527 527 $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'"); 528 528 if (!$cat && 0 != $link->link_category) { … … 537 537 // Count links per category. 538 538 if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) { 539 539 $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"); 540 foreach ( $categories as $cat_id ) {540 foreach ( (array) $categories as $cat_id ) { 541 541 $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'"); 542 542 $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'"); 543 543 } … … 550 550 // General 551 551 function maybe_create_table($table_name, $create_ddl) { 552 552 global $wpdb; 553 foreach ( $wpdb->get_col("SHOW TABLES",0) as $table ) {553 foreach ( (array) $wpdb->get_col("SHOW TABLES",0) as $table ) { 554 554 if ($table == $table_name) { 555 555 return true; 556 556 } … … 558 558 //didn't find it try to create it. 559 559 $q = $wpdb->query($create_ddl); 560 560 // 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 ) { 562 562 if ($table == $table_name) { 563 563 return true; 564 564 } … … 593 593 */ 594 594 function maybe_add_column($table_name, $column_name, $create_ddl) { 595 595 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 ) { 597 597 if ($debug) echo("checking $column == $column_name<br />"); 598 598 if ($column == $column_name) { 599 599 return true; … … 602 602 //didn't find it try to create it. 603 603 $q = $wpdb->query($create_ddl); 604 604 // 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 ) { 606 606 if ($column == $column_name) { 607 607 return true; 608 608 } … … 615 615 function get_alloptions_110() { 616 616 global $wpdb; 617 617 if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) { 618 foreach ( $options as $option) {618 foreach ( (array) $options as $option) { 619 619 // "When trying to design a foolproof system, 620 620 // never underestimate the ingenuity of the fools :)" -- Dougal 621 621 if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value); … … 677 677 $for_update = array(); 678 678 679 679 // Create a tablename index for an array ($cqueries) of queries 680 foreach( $queries as $qry) {680 foreach( (array) $queries as $qry) { 681 681 if(preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) { 682 682 $cqueries[strtolower($matches[1])] = $qry; 683 683 $for_update[$matches[1]] = 'Created table '.$matches[1]; … … 699 699 // Check to see which tables and fields exist 700 700 if($tables = $wpdb->get_col('SHOW TABLES;')) { 701 701 // For every table in the database 702 foreach( $tables as $table) {702 foreach( (array) $tables as $table) { 703 703 // If a table query exists for the database table... 704 704 if( array_key_exists(strtolower($table), $cqueries) ) { 705 705 // Clear the field and index arrays … … 715 715 //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>"; 716 716 717 717 // For every field line specified in the query 718 foreach( $flds as $fld) {718 foreach( (array) $flds as $fld) { 719 719 // Extract the field name 720 720 preg_match("|^([^ ]*)|", trim($fld), $fvals); 721 721 $fieldname = $fvals[1]; … … 746 746 $tablefields = $wpdb->get_results("DESCRIBE {$table};"); 747 747 748 748 // For every field in the table 749 foreach( $tablefields as $tablefield) {749 foreach( (array) $tablefields as $tablefield) { 750 750 // If the table field exists in the field array... 751 751 if(array_key_exists(strtolower($tablefield->Field), $cfields)) { 752 752 // Get the field type from the query … … 781 781 } 782 782 783 783 // For every remaining field specified for the table 784 foreach( $cfields as $fieldname => $fielddef) {784 foreach( (array) $cfields as $fieldname => $fielddef) { 785 785 // Push a query line into $cqueries that adds the field to that table 786 786 $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef"; 787 787 $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname; … … 796 796 unset($index_ary); 797 797 798 798 // For every index in the table 799 foreach( $tableindices as $tableindex) {799 foreach( (array) $tableindices as $tableindex) { 800 800 // Add the index to the index data array 801 801 $keyname = $tableindex->Key_name; 802 802 $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part); … … 804 804 } 805 805 806 806 // 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) { 808 808 // Build a create string to compare to the query 809 809 $index_string = ''; 810 810 if($index_name == 'PRIMARY') { … … 819 819 } 820 820 $index_columns = ''; 821 821 // For each column in the index 822 foreach( $index_data['columns'] as $column_data) {822 foreach( (array) $index_data['columns'] as $column_data) { 823 823 if($index_columns != '') $index_columns .= ','; 824 824 // Add the field to the column list string 825 825 $index_columns .= $column_data['fieldname']; … … 839 839 } 840 840 841 841 // For every remaining index specified for the table 842 foreach( $indices as $index) {842 foreach( (array) $indices as $index) { 843 843 // Push a query line into $cqueries that adds the index to that table 844 844 $cqueries[] = "ALTER TABLE {$table} ADD $index"; 845 845 $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index; … … 856 856 857 857 $allqueries = array_merge($cqueries, $iqueries); 858 858 if($execute) { 859 foreach( $allqueries as $query) {859 foreach( (array) $allqueries as $query) { 860 860 //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n"; 861 861 $wpdb->query($query); 862 862 } … … 870 870 871 871 $alterations = dbDelta($wp_queries); 872 872 echo "<ol>\n"; 873 foreach( $alterations as $alteration) echo "<li>$alteration</li>\n";873 foreach( (array) $alterations as $alteration) echo "<li>$alteration</li>\n"; 874 874 echo "</ol>\n"; 875 875 } 876 876 … … 892 892 // standard WP files are copied. 893 893 $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php'); 894 894 895 foreach ( $files as $oldfile => $newfile) {895 foreach ( (array) $files as $oldfile => $newfile) { 896 896 if ($oldfile == 'index.php') 897 897 $oldpath = $home_path; 898 898 else … … 917 917 if ($lines) { 918 918 $f = fopen("$site_dir/$newfile", 'w'); 919 919 920 foreach ( $lines as $line) {920 foreach ( (array) $lines as $line) { 921 921 if (preg_match('/require.*wp-blog-header/', $line)) 922 922 $line = '//' . $line; 923 923 … … 971 971 if ($stylelines) { 972 972 $f = fopen("$site_dir/style.css", 'w'); 973 973 974 foreach ( $stylelines as $line) {974 foreach ( (array) $stylelines as $line) { 975 975 if (strstr($line, "Theme Name:")) $line = "Theme Name: $theme_name"; 976 976 elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl'); 977 977 elseif (strstr($line, "Description:")) $line = "Description: Your theme"; -
wp-admin/templates.php
107 107 <h3><?php _e('Recent'); ?></h3> 108 108 <?php 109 109 echo '<ol>'; 110 foreach ( $recents as $recent) :110 foreach ( (array) $recents as $recent) : 111 111 echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>"; 112 112 endforeach; 113 113 echo '</ol>'; … … 116 116 <h3><?php _e('Common'); ?></h3> 117 117 <?php $common_files = array('index.php', '.htaccess', 'my-hacks.php'); 118 118 $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php'); 119 foreach ( $old_files as $old_file) {119 foreach ( (array) $old_files as $old_file) { 120 120 if (file_exists(ABSPATH . $old_file)) 121 121 $common_files[] = $old_file; 122 122 } ?> 123 123 <ul> 124 <?php foreach ( $common_files as $common_file) : ?>124 <?php foreach ( (array) $common_files as $common_file) : ?> 125 125 <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li> 126 126 <?php endforeach; ?> 127 127 </ul> -
wp-admin/admin-functions.php
115 115 116 116 $i = 0; 117 117 $search = "# id=(\"|')p(\d+)\\1#i"; 118 foreach ( $anchor_matches[0] as $anchor ) {118 foreach ( (array) $anchor_matches[0] as $anchor ) { 119 119 if ( 0 == preg_match($search, $anchor, $id_matches) ) 120 120 continue; 121 121 … … 225 225 226 226 // Meta Stuff 227 227 if ($_POST['meta']) { 228 foreach ( $_POST['meta'] as $key => $value)228 foreach ( (array) $_POST['meta'] as $key => $value) 229 229 update_meta($key, $value['key'], $value['value']); 230 230 } 231 231 232 232 if ($_POST['deletemeta']) { 233 foreach ( $_POST['deletemeta'] as $key => $value)233 foreach ( (array) $_POST['deletemeta'] as $key => $value) 234 234 delete_meta($key); 235 235 } 236 236 … … 364 364 function wp_dropdown_roles( $default = false ) { 365 365 global $wp_roles; 366 366 $r = ''; 367 foreach( $wp_roles->role_names as $role => $name)367 foreach( (array) $wp_roles->role_names as $role => $name) 368 368 if ( $default == $role ) // Make default first in list 369 369 $p = "\n\t<option selected='selected' value='$role'>$name</option>"; 370 370 else … … 609 609 $result = array (); 610 610 611 611 if (is_array($cats)) { 612 foreach ( $cats as $cat) {612 foreach ( (array) $cats as $cat) { 613 613 $result[$cat]['children'] = get_nested_categories($default, $cat); 614 614 $result[$cat]['cat_ID'] = $cat; 615 615 $result[$cat]['checked'] = in_array($cat, $checked_categories); … … 623 623 } 624 624 625 625 function write_nested_categories($categories) { 626 foreach ( $categories as $category) {626 foreach ( (array) $categories as $category) { 627 627 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"; 628 628 629 629 if ( $category['children'] ) { … … 646 646 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name"); 647 647 648 648 if ($categories) { 649 foreach ( $categories as $category) {649 foreach ( (array) $categories as $category) { 650 650 if ($category->category_parent == $parent) { 651 651 $category->cat_name = wp_specialchars($category->cat_name,'double'); 652 652 $pad = str_repeat('— ', $level); … … 690 690 if (! $pages) 691 691 return false; 692 692 693 foreach ( $pages as $post) {693 foreach ( (array) $pages as $post) { 694 694 setup_postdata($post); 695 695 if ( $hierarchy && ($post->post_parent != $parent) ) 696 696 continue; … … 750 750 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name"); 751 751 } 752 752 if ($categories) { 753 foreach ( $categories as $category) {753 foreach ( (array) $categories as $category) { 754 754 if ($currentcat != $category->cat_ID && $parent == $category->category_parent) { 755 755 $pad = str_repeat('– ', $level); 756 756 $category->cat_name = wp_specialchars($category->cat_name); … … 895 895 </thead> 896 896 <?php 897 897 $r ="\n\t<tbody id='the-list'>"; 898 foreach ( $meta as $entry) {898 foreach ( (array) $meta as $entry) { 899 899 ++ $count; 900 900 if ($count % 2) 901 901 $style = 'alternate'; … … 954 954 <option value="#NONE#"><?php _e('- Select -'); ?></option> 955 955 <?php 956 956 957 foreach ( $keys as $key) {957 foreach ( (array) $keys as $key) { 958 958 echo "\n\t<option value='$key'>$key</option>"; 959 959 } 960 960 ?> … … 1080 1080 $foundit = false; 1081 1081 if ($markerdata) { 1082 1082 $state = true; 1083 foreach ( $markerdata as $n => $markerline) {1083 foreach ( (array) $markerdata as $n => $markerline) { 1084 1084 if (strstr($markerline, "# BEGIN {$marker}")) 1085 1085 $state = false; 1086 1086 if ($state) { … … 1092 1092 if (strstr($markerline, "# END {$marker}")) { 1093 1093 fwrite($f, "# BEGIN {$marker}\n"); 1094 1094 if (is_array($insertion)) 1095 foreach ( $insertion as $insertline)1095 foreach ( (array) $insertion as $insertline) 1096 1096 fwrite($f, "{$insertline}\n"); 1097 1097 fwrite($f, "# END {$marker}\n"); 1098 1098 $state = true; … … 1102 1102 } 1103 1103 if (!$foundit) { 1104 1104 fwrite($f, "# BEGIN {$marker}\n"); 1105 foreach ( $insertion as $insertline)1105 foreach ( (array) $insertion as $insertline) 1106 1106 fwrite($f, "{$insertline}\n"); 1107 1107 fwrite($f, "# END {$marker}\n"); 1108 1108 } … … 1126 1126 if ($markerdata = explode("\n", implode('', file($filename)))); 1127 1127 { 1128 1128 $state = false; 1129 foreach ( $markerdata as $markerline) {1129 foreach ( (array) $markerdata as $markerline) { 1130 1130 if (strstr($markerline, "# END {$marker}")) 1131 1131 $state = false; 1132 1132 if ($state) … … 1248 1248 $page_templates = array (); 1249 1249 1250 1250 if (is_array($templates)) { 1251 foreach ( $templates as $template) {1251 foreach ( (array) $templates as $template) { 1252 1252 $template_data = implode('', file(ABSPATH.$template)); 1253 1253 preg_match("|Template Name:(.*)|i", $template_data, $name); 1254 1254 preg_match("|Description:(.*)|i", $template_data, $description); … … 1281 1281 $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"); 1282 1282 1283 1283 if ($items) { 1284 foreach ( $items as $item) {1284 foreach ( (array) $items as $item) { 1285 1285 // A page cannot be it's own parent. 1286 1286 if (!empty ($post_ID)) { 1287 1287 if ($item->ID == $post_ID) { … … 1317 1317 return true; 1318 1318 1319 1319 if (isset ($submenu[$parent])) { 1320 foreach ( $submenu[$parent] as $submenu_array) {1320 foreach ( (array) $submenu[$parent] as $submenu_array) { 1321 1321 if ($submenu_array[2] == $pagenow) { 1322 1322 if (current_user_can($submenu_array[1])) 1323 1323 return true; … … 1327 1327 } 1328 1328 } 1329 1329 1330 foreach ( $menu as $menu_array) {1330 foreach ( (array) $menu as $menu_array) { 1331 1331 //echo "parent array: " . $menu_array[2]; 1332 1332 if ($menu_array[2] == $parent) { 1333 1333 if (current_user_can($menu_array[1])) … … 1355 1355 1356 1356 $parent = $parent1 = get_admin_page_parent(); 1357 1357 if (empty ($parent)) { 1358 foreach ( $menu as $menu_array) {1358 foreach ( (array) $menu as $menu_array) { 1359 1359 if (isset ($menu_array[3])) { 1360 1360 if ($menu_array[2] == $pagenow) { 1361 1361 $title = $menu_array[3]; … … 1369 1369 } 1370 1370 } else { 1371 1371 foreach (array_keys($submenu) as $parent) { 1372 foreach ( $submenu[$parent] as $submenu_array) {1372 foreach ( (array) $submenu[$parent] as $submenu_array) { 1373 1373 if (isset ($submenu_array[3])) { 1374 1374 if ($submenu_array[2] == $pagenow) { 1375 1375 $title = $submenu_array[3]; … … 1403 1403 } 1404 1404 1405 1405 if ($pagenow == 'admin.php' && isset ($plugin_page)) { 1406 foreach ( $menu as $parent_menu) {1406 foreach ( (array) $menu as $parent_menu) { 1407 1407 if ($parent_menu[2] == $plugin_page) { 1408 1408 $parent_file = $plugin_page; 1409 1409 if ( isset($real_parent_file[$parent_file]) ) … … 1415 1415 } 1416 1416 1417 1417 foreach (array_keys($submenu) as $parent) { 1418 foreach ( $submenu[$parent] as $submenu_array) {1418 foreach ( (array) $submenu[$parent] as $submenu_array) { 1419 1419 if ( isset($real_parent_file[$parent]) ) 1420 1420 $parent = $real_parent_file[$parent]; 1421 1421 if ($submenu_array[2] == $pagenow) { … … 1465 1465 // parent file someone is trying to link back to the parent manually. In 1466 1466 // this case, don't automatically add a link back to avoid duplication. 1467 1467 if (!isset ($submenu[$parent]) && $file != $parent) { 1468 foreach ( $menu as $parent_menu) {1468 foreach ( (array) $menu as $parent_menu) { 1469 1469 if ($parent_menu[2] == $parent) { 1470 1470 $submenu[$parent][] = $parent_menu; 1471 1471 } … … 1654 1654 1655 1655 sort($plugin_files); 1656 1656 1657 foreach ( $plugin_files as $plugin_file) {1657 foreach ( (array) $plugin_files as $plugin_file) { 1658 1658 if ( !is_readable("$plugin_root/$plugin_file")) 1659 1659 continue; 1660 1660 … … 1844 1844 if ( $test_type ) { 1845 1845 $type = false; 1846 1846 $ext = false; 1847 foreach ( $mimes as $ext_preg => $mime_match) {1847 foreach ( (array) $mimes as $ext_preg => $mime_match) { 1848 1848 $ext_preg = '![^.]\.(' . $ext_preg . ')$!i'; 1849 1849 if ( preg_match($ext_preg, $file['name'], $ext_matches) ) { 1850 1850 $type = $mime_match; -
wp-admin/edit-page-form.php
104 104 <div class="dbx-content"> 105 105 <select name="post_author_override" id="post_author_override"> 106 106 <?php 107 foreach ( $authors as $o) :107 foreach ( (array) $authors as $o) : 108 108 $o = get_userdata( $o->ID ); 109 109 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"'; 110 110 else $selected = ''; -
wp-admin/moderation.php
23 23 24 24 $comment = array(); 25 25 if (isset($_POST["comment"])) { 26 foreach ( $_POST["comment"] as $k => $v) {26 foreach ( (array) $_POST["comment"] as $k => $v) { 27 27 $comment[intval($k)] = $v; 28 28 } 29 29 } … … 42 42 $item_approved = 0; 43 43 $item_spam = 0; 44 44 45 foreach( $comment as $key => $value) {45 foreach( (array) $comment as $key => $value) { 46 46 if ($feelinglucky && 'later' == $value) 47 47 $value = 'delete'; 48 48 switch($value) { … … 137 137 <ol id="the-list" class="commentlist"> 138 138 <?php 139 139 $i = 0; 140 foreach( $comments as $comment) {140 foreach( (array) $comments as $comment) { 141 141 ++$i; 142 142 $comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date); 143 143 $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'"); -
wp-admin/index.php
23 23 <ul> 24 24 <?php 25 25 $rss->items = array_slice($rss->items, 0, 10); 26 foreach ( $rss->items as $item ) {26 foreach ( (array) $rss->items as $item ) { 27 27 ?> 28 28 <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wp_specialchars($item['title']); ?></a></li> 29 29 <?php } ?> … … 48 48 <ul> 49 49 <?php 50 50 if ( $comments ) { 51 foreach ( $comments as $comment) {51 foreach ( (array) $comments as $comment) { 52 52 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>'); 53 53 edit_comment_link(__("Edit"), ' <small>(', ')</small>'); 54 54 echo '</li>'; … … 66 66 <h3><?php _e('Posts'); ?> <a href="edit.php" title="<?php _e('More posts...'); ?>">»</a></h3> 67 67 <ul> 68 68 <?php 69 foreach ( $recentposts as $post) {69 foreach ( (array) $recentposts as $post) { 70 70 if ($post->post_title == '') 71 71 $post->post_title = sprintf(__('Post #%s'), $post->ID); 72 72 echo "<li><a href='post.php?action=edit&post=$post->ID'>"; … … 85 85 <h3><?php _e('Scheduled Entries:') ?></h3> 86 86 <ul> 87 87 <?php 88 foreach ( $scheduled as $post) {88 foreach ( (array) $scheduled as $post) { 89 89 if ($post->post_title == '') 90 90 $post->post_title = sprintf(__('Post #%s'), $post->ID); 91 91 echo "<li>" . sprintf(__('%1$s in %2$s'), "<a href='post.php?action=edit&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>"; … … 132 132 <h3><?php _e('WordPress Development Blog'); ?></h3> 133 133 <?php 134 134 $rss->items = array_slice($rss->items, 0, 3); 135 foreach ( $rss->items as $item ) {135 foreach ( (array) $rss->items as $item ) { 136 136 ?> 137 137 <h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> — <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4> 138 138 <p><?php echo $item['description']; ?></p> … … 151 151 <ul> 152 152 <?php 153 153 $rss->items = array_slice($rss->items, 0, 20); 154 foreach ( $rss->items as $item ) {154 foreach ( (array) $rss->items as $item ) { 155 155 ?> 156 156 <li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li> 157 157 <?php -
wp-admin/admin-db.php
186 186 // Only set posts and links to the default category if they're not in another category already. 187 187 $default_cat = get_option('default_category'); 188 188 $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'"); 189 if ( is_array($posts) ) foreach ( $posts as $post_id) {189 if ( is_array($posts) ) foreach ( (array) $posts as $post_id) { 190 190 $cats = wp_get_post_cats('', $post_id); 191 191 if ( 1 == count($cats) ) 192 192 $cats = array($default_cat); … … 197 197 198 198 $default_link_cat = get_option('default_link_category'); 199 199 $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'"); 200 if ( is_array($links) ) foreach ( $links as $link_id) {200 if ( is_array($links) ) foreach ( (array) $links as $link_id) { 201 201 $cats = wp_get_link_cats($link_id); 202 202 if ( 1 == count($cats) ) 203 203 $cats = array($default_link_cat); … … 221 221 222 222 function wp_create_categories($categories, $post_id = '') { 223 223 $cat_ids = array (); 224 foreach ( $categories as $category) {224 foreach ( (array) $categories as $category) { 225 225 if ($id = category_exists($category)) 226 226 $cat_ids[] = $id; 227 227 else … … 253 253 $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); 254 254 255 255 if ($post_ids) { 256 foreach ( $post_ids as $post_id)256 foreach ( (array) $post_ids as $post_id) 257 257 wp_delete_post($post_id); 258 258 } 259 259 … … 384 384 385 385 $categories = wp_get_link_cats($link_id); 386 386 if( is_array( $categories ) ) { 387 foreach ( $categories as $category ) {387 foreach ( (array) $categories as $category ) { 388 388 $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'"); 389 389 wp_cache_delete($category, 'category'); 390 390 } … … 434 434 $delete_cats = array_diff($old_categories,$link_categories); 435 435 436 436 if ($delete_cats) { 437 foreach ( $delete_cats as $del) {437 foreach ( (array) $delete_cats as $del) { 438 438 $wpdb->query(" 439 439 DELETE FROM $wpdb->link2cat 440 440 WHERE category_id = $del … … 447 447 $add_cats = array_diff($link_categories, $old_categories); 448 448 449 449 if ($add_cats) { 450 foreach ( $add_cats as $new_cat) {450 foreach ( (array) $add_cats as $new_cat) { 451 451 $wpdb->query(" 452 452 INSERT INTO $wpdb->link2cat (link_id, category_id) 453 453 VALUES ($link_ID, $new_cat)"); … … 456 456 457 457 // Update category counts. 458 458 $all_affected_cats = array_unique(array_merge($link_categories, $old_categories)); 459 foreach ( $all_affected_cats as $cat_id ) {459 foreach ( (array) $all_affected_cats as $cat_id ) { 460 460 $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'"); 461 461 $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'"); 462 462 wp_cache_delete($cat_id, 'category'); -
wp-admin/import/livejournal.php
36 36 $posts = $posts[1]; 37 37 unset($importdata); 38 38 echo '<ol>'; 39 foreach ( $posts as $post) {39 foreach ( (array) $posts as $post) { 40 40 preg_match('|<subject>(.*?)</subject>|is', $post, $post_title); 41 41 $post_title = $wpdb->escape(trim($post_title[1])); 42 42 if ( empty($post_title) ) { … … 81 81 if ( $comments ) { 82 82 $comment_post_ID = $post_id; 83 83 $num_comments = 0; 84 foreach ( $comments as $comment) {84 foreach ( (array) $comments as $comment) { 85 85 preg_match('|<event>(.*?)</event>|is', $comment, $comment_content); 86 86 $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1])); 87 87 $comment_content = $this->unhtmlentities($comment_content); -
wp-admin/import/dotclear.php
221 221 if(is_array($categories)) 222 222 { 223 223 echo '<p>'.__('Importing Categories...').'<br /><br /></p>'; 224 foreach ( $categories as $category)224 foreach ( (array) $categories as $category) 225 225 { 226 226 $count++; 227 227 extract($category); … … 262 262 if(is_array($users)) 263 263 { 264 264 echo '<p>'.__('Importing Users...').'<br /><br /></p>'; 265 foreach( $users as $user)265 foreach( (array) $users as $user) 266 266 { 267 267 $count++; 268 268 extract($user); … … 312 312 update_usermeta( $ret_id, 'rich_editing', 'false'); 313 313 update_usermeta( $ret_id, 'first_name', csc ($user_prenom)); 314 314 update_usermeta( $ret_id, 'last_name', csc ($user_nom)); 315 }// End foreach( $users as $user)315 }// End foreach( (array) $users as $user) 316 316 317 317 // Store id translation array for future use 318 318 add_option('dcid2wpid',$dcid2wpid); … … 339 339 if(is_array($posts)) 340 340 { 341 341 echo '<p>'.__('Importing Posts...').'<br /><br /></p>'; 342 foreach( $posts as $post)342 foreach( (array) $posts as $post) 343 343 { 344 344 $count++; 345 345 extract($post); … … 430 430 if(is_array($comments)) 431 431 { 432 432 echo '<p>'.__('Importing Comments...').'<br /><br /></p>'; 433 foreach( $comments as $comment)433 foreach( (array) $comments as $comment) 434 434 { 435 435 $count++; 436 436 extract($comment); … … 501 501 if(is_array($links)) 502 502 { 503 503 echo '<p>'.__('Importing Links...').'<br /><br /></p>'; 504 foreach( $links as $link)504 foreach( (array) $links as $link) 505 505 { 506 506 $count++; 507 507 extract($link); -
wp-admin/import/mt.php
36 36 <?php 37 37 38 38 39 foreach ( $users as $user) {39 foreach ( (array) $users as $user) { 40 40 echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>'; 41 41 } 42 42 ?> … … 85 85 function get_mt_authors() { 86 86 $temp = array (); 87 87 $i = -1; 88 foreach ( $this->posts as $post) {88 foreach ( (array) $this->posts as $post) { 89 89 if ('' != trim($post)) { 90 90 ++ $i; 91 91 preg_match("|AUTHOR:(.*)|", $post, $thematch); … … 110 110 $formnames = array (); 111 111 $selectnames = array (); 112 112 113 foreach ( $_POST['user'] as $key => $line) {113 foreach ( (array) $_POST['user'] as $key => $line) { 114 114 $newname = trim(stripslashes($line)); 115 115 if ($newname == '') 116 116 $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. 117 117 array_push($formnames, "$newname"); 118 118 } // $formnames is the array with the form entered names 119 119 120 foreach ( $_POST['userselect'] as $user => $key) {120 foreach ( (array) $_POST['userselect'] as $user => $key) { 121 121 $selected = trim(stripslashes($key)); 122 122 array_push($selectnames, "$selected"); 123 123 } … … 146 146 echo '<ol id="authors">'; 147 147 echo '<form action="?import=mt&step=2&id=' . $this->id . '" method="post">'; 148 148 $j = -1; 149 foreach ( $authors as $author) {149 foreach ( (array) $authors as $author) { 150 150 ++ $j; 151 151 echo '<li>Current author: <strong>'.$author.'</strong><br />'.'Create user <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br /> or map to existing '; 152 152 $this->users_form($j); … … 179 179 global $wpdb; 180 180 $i = -1; 181 181 echo "<div class='wrap'><ol>"; 182 foreach ( $this->posts as $post) {182 foreach ( (array) $this->posts as $post) { 183 183 if ('' != trim($post)) { 184 184 ++ $i; 185 185 unset ($post_categories); … … 215 215 216 216 // Grab the metadata from what's left 217 217 $metadata = explode("\n", $post); 218 foreach ( $metadata as $line) {218 foreach ( (array) $metadata as $line) { 219 219 preg_match("/^(.*?):(.*)/", $line, $token); 220 220 $key = trim($token[1]); 221 221 $value = trim($token[2]); … … 299 299 // Now for comments 300 300 $comments = explode("-----\nCOMMENT:", $comments[0]); 301 301 $num_comments = 0; 302 foreach ( $comments as $comment) {302 foreach ( (array) $comments as $comment) { 303 303 if ('' != trim($comment)) { 304 304 // Author 305 305 preg_match("|AUTHOR:(.*)|", $comment, $comment_author); … … 341 341 $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]); 342 342 $pings = explode("-----\nPING:", $pings[0]); 343 343 $num_pings = 0; 344 foreach ( $pings as $ping) {344 foreach ( (array) $pings as $ping) { 345 345 if ('' != trim($ping)) { 346 346 // 'Author' 347 347 preg_match("|BLOG NAME:(.*)|", $ping, $comment_author); -
wp-admin/import/blogger.php
49 49 50 50 // put the rest of the headers in an array 51 51 $response_header_array = array(); 52 foreach( $response_header_lines as $header_line) {52 foreach( (array) $response_header_lines as $header_line) { 53 53 list($header,$value) = explode(': ', $header_line, 2); 54 54 $response_header_array[$header] .= $value."\n"; 55 55 } 56 56 57 57 $cookie_array = array(); 58 58 $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); } 60 60 61 61 return array("code" => $response_code, "header" => $response_header_array, "cookies" => $cookie_array, "body" => $response_body); 62 62 } … … 118 118 function post_blogger($url, $header = false, $paramary = false, $parse=true) { 119 119 $params = ''; 120 120 if ( is_array($paramary) ) { 121 foreach( $paramary as $key=>$value)121 foreach( (array) $paramary as $key=>$value) 122 122 if($key && $value != '') 123 123 $params.=$key."=".urlencode(stripslashes($value))."&"; 124 124 } … … 149 149 function show_blogs() { 150 150 global $import; 151 151 echo '<h1>' . __('Selecting a Blog') . "</h1>\n<ul>"; 152 foreach ( $this->import['blogs'] as $blog ) {152 foreach ( (array) $this->import['blogs'] as $blog ) { 153 153 if (9 == $blog['nextstep']) $status = "100%"; 154 154 elseif (8 == $blog['nextstep']) $status = "90%"; 155 155 elseif (7 == $blog['nextstep']) $status = "82.5%"; … … 244 244 die(__('No blogs found for this user.')); 245 245 $this->import['blogs'] = array(); 246 246 $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 ) { 248 248 // Define the required Blogger options. 249 249 $blog_opts = array( 250 250 'blog-options-basic' => false, … … 256 256 ); 257 257 258 258 // Build the blog options array template 259 foreach ( $blog_opts as $blog_opt => $modify)259 foreach ( (array) $blog_opts as $blog_opt => $modify) 260 260 $new_opts["$blog_opt"] = array('backup'=>false, 'modify' => $modify, 'error'=>false); 261 261 262 262 $this->import['blogs']["$id"] = array( … … 292 292 function backup_settings() { 293 293 $output.= '<h1>'.__('Backing up Blogger options')."</h1>\n"; 294 294 $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) { 296 296 if ( $blog_opt == $_GET['form'] ) { 297 297 // Save the posted form data 298 298 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup'] = $_POST; … … 366 366 if (! strstr($bloghtml['body'], '<a class="archive"') ) 367 367 die(__('Your Blogger blog did not take the new template or did not respond.')); 368 368 preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives); 369 foreach ( $archives[1] as $archive) {369 foreach ( (array) $archives[1] as $archive) { 370 370 $this->import['blogs'][$_GET['blog']]['archives'][$archive] = false; 371 371 } 372 372 $this->set_next_step(6); … … 379 379 $output = '<h2>'.__('Importing Blogger archives into WordPress').'</h2>'; 380 380 $did_one = false; 381 381 $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 ) { 383 383 $archivename = substr(basename($url),0,7); 384 384 if ( $status || $did_one ) { 385 385 $foo = 'bar'; … … 497 497 } 498 498 if ( count($post_array) ) { 499 499 krsort($post_array); 500 foreach( $post_array as $post) {500 foreach( (array) $post_array as $post) { 501 501 if ( ! $comment_post_ID = $post['ID'] ) 502 502 $comment_post_ID = wp_insert_post($post['post']); 503 503 if ( $post['comments'] ) { 504 foreach ( $post['comments'] as $comment ) {504 foreach ( (array) $post['comments'] as $comment ) { 505 505 $comment['comment_post_ID'] = $comment_post_ID; 506 506 wp_insert_comment($comment); 507 507 } … … 533 533 $this->import['reversed'] = true; 534 534 update_option('import-blogger', $this->import); 535 535 } 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 ) { 537 537 if ( $did_one ) { 538 538 $output .= "<p>$blog_opt</p>\n"; 539 539 } elseif ( $optary['restored'] || ! $optary['modify'] ) { -
wp-admin/import/textpattern.php
163 163 if(is_array($categories)) 164 164 { 165 165 echo '<p>'.__('Importing Categories...').'<br /><br /></p>'; 166 foreach ( $categories as $category)166 foreach ( (array) $categories as $category) 167 167 { 168 168 $count++; 169 169 extract($category); … … 204 204 if(is_array($users)) 205 205 { 206 206 echo '<p>'.__('Importing Users...').'<br /><br /></p>'; 207 foreach( $users as $user)207 foreach( (array) $users as $user) 208 208 { 209 209 $count++; 210 210 extract($user); … … 252 252 253 253 update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] ); 254 254 update_usermeta( $ret_id, 'rich_editing', 'false'); 255 }// End foreach( $users as $user)255 }// End foreach( (array) $users as $user) 256 256 257 257 // Store id translation array for future use 258 258 add_option('txpid2wpid',$txpid2wpid); … … 279 279 if(is_array($posts)) 280 280 { 281 281 echo '<p>'.__('Importing Posts...').'<br /><br /></p>'; 282 foreach( $posts as $post)282 foreach( (array) $posts as $post) 283 283 { 284 284 $count++; 285 285 extract($post); … … 360 360 if(is_array($comments)) 361 361 { 362 362 echo '<p>'.__('Importing Comments...').'<br /><br /></p>'; 363 foreach( $comments as $comment)363 foreach( (array) $comments as $comment) 364 364 { 365 365 $count++; 366 366 extract($comment); … … 428 428 if(is_array($links)) 429 429 { 430 430 echo '<p>'.__('Importing Links...').'<br /><br /></p>'; 431 foreach( $links as $link)431 foreach( (array) $links as $link) 432 432 { 433 433 $count++; 434 434 extract($link); -
wp-admin/import/blogware.php
38 38 $posts = $posts[1]; 39 39 unset($importdata); 40 40 echo '<ol>'; 41 foreach ( $posts as $post) {41 foreach ( (array) $posts as $post) { 42 42 flush(); 43 43 preg_match('|<item type=\"(.*?)\">|is', $post, $post_type); 44 44 $post_type = $post_type[1]; … … 57 57 $categories = $categories[1]; 58 58 59 59 $cat_index = 0; 60 foreach ( $categories as $category) {60 foreach ( (array) $categories as $category) { 61 61 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category)); 62 62 $cat_index++; 63 63 } … … 104 104 if ( $comments ) { 105 105 $comment_post_ID = $post_id; 106 106 $num_comments = 0; 107 foreach ( $comments as $comment) {107 foreach ( (array) $comments as $comment) { 108 108 preg_match('|<body>(.*?)</body>|is', $comment, $comment_content); 109 109 $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1])); 110 110 $comment_content = $this->unhtmlentities($comment_content); -
wp-admin/import/greymatter.php
101 101 chdir($gmpath); 102 102 $userbase = file("gm-authors.cgi"); 103 103 104 foreach( $userbase as $user) {104 foreach( (array) $userbase as $user) { 105 105 $userdata=explode("|", $user); 106 106 107 107 $user_ip="127.0.0.1"; -
wp-admin/import/rss.php
36 36 preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts); 37 37 $this->posts = $this->posts[1]; 38 38 $index = 0; 39 foreach ( $this->posts as $post) {39 foreach ( (array) $this->posts as $post) { 40 40 preg_match('|<title>(.*?)</title>|is', $post, $post_title); 41 41 $post_title = $wpdb->escape(trim($post_title[1])); 42 42 … … 63 63 } 64 64 65 65 $cat_index = 0; 66 foreach ( $categories as $category) {66 foreach ( (array) $categories as $category) { 67 67 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category)); 68 68 $cat_index++; 69 69 } … … 98 98 function import_posts() { 99 99 echo '<ol>'; 100 100 101 foreach ( $this->posts as $post) {101 foreach ( (array) $this->posts as $post) { 102 102 echo "<li>".__('Importing post...'); 103 103 104 104 extract($post); -
wp-admin/import/wordpress.php
41 41 ?><select name="userselect[<?php echo $n; ?>]"> 42 42 <option value="#NONE#">- Select -</option> 43 43 <?php 44 foreach ( $users as $user) {44 foreach ( (array) $users as $user) { 45 45 echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>'; 46 46 } 47 47 ?> … … 88 88 function get_wp_authors() { 89 89 $temp = array (); 90 90 $i = -1; 91 foreach ( $this->posts as $post) {91 foreach ( (array) $this->posts as $post) { 92 92 if ('' != trim($post)) { 93 93 ++ $i; 94 94 $author = $this->get_tag( $post, 'dc:creator' ); … … 112 112 $formnames = array (); 113 113 $selectnames = array (); 114 114 115 foreach ( $_POST['user'] as $key => $line) {115 foreach ( (array) $_POST['user'] as $key => $line) { 116 116 $newname = trim(stripslashes($line)); 117 117 if ($newname == '') 118 118 $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. 119 119 array_push($formnames, "$newname"); 120 120 } // $formnames is the array with the form entered names 121 121 122 foreach ( $_POST['userselect'] as $user => $key) {122 foreach ( (array) $_POST['userselect'] as $user => $key) { 123 123 $selected = trim(stripslashes($key)); 124 124 array_push($selectnames, "$selected"); 125 125 } … … 146 146 echo '<ol id="authors">'; 147 147 echo '<form action="?import=wordpress&step=2&id=' . $this->id . '" method="post">'; 148 148 $j = -1; 149 foreach ( $authors as $author) {149 foreach ( (array) $authors as $author) { 150 150 ++ $j; 151 151 echo '<li>Current author: <strong>'.$author.'</strong><br />'.'Create user <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br /> or map to existing '; 152 152 $this->users_form($j); … … 179 179 global $wpdb; 180 180 $i = -1; 181 181 echo '<ol>'; 182 foreach ( $this->posts as $post) {182 foreach ( (array) $this->posts as $post) { 183 183 184 184 // There are only ever one of these 185 185 $post_title = $this->get_tag( $post, 'title' ); … … 203 203 $categories = $categories[1]; 204 204 205 205 $cat_index = 0; 206 foreach ( $categories as $category) {206 foreach ( (array) $categories as $category) { 207 207 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category)); 208 208 $cat_index++; 209 209 } … … 229 229 preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments); 230 230 $comments = $comments[1]; 231 231 $num_comments = 0; 232 if ( $comments) { foreach ( $comments as $comment) {232 if ( $comments) { foreach ( (array) $comments as $comment) { 233 233 $comment_author = $this->get_tag( $comment, 'wp:comment_author'); 234 234 $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email'); 235 235 $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP'); … … 253 253 // Now for post meta 254 254 preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta); 255 255 $postmeta = $postmeta[1]; 256 if ( $postmeta) { foreach ( $postmeta as $p) {256 if ( $postmeta) { foreach ( (array) $postmeta as $p) { 257 257 $key = $this->get_tag( $p, 'wp:meta_key' ); 258 258 $value = $this->get_tag( $p, 'wp:meta_value' ); 259 259 add_post_meta( $post_id, $key, $value ); -
wp-admin/edit-form-advanced.php
38 38 if ('' != $post->pinged) { 39 39 $pings = '<p>'. __('Already pinged:') . '</p><ul>'; 40 40 $already_pinged = explode("\n", trim($post->pinged)); 41 foreach ( $already_pinged as $pinged_url) {41 foreach ( (array) $already_pinged as $pinged_url) { 42 42 $pings .= "\n\t<li>$pinged_url</li>"; 43 43 } 44 44 $pings .= '</ul>'; … … 120 120 <div class="dbx-content"> 121 121 <select name="post_author_override" id="post_author_override"> 122 122 <?php 123 foreach ( $authors as $o) :123 foreach ( (array) $authors as $o) : 124 124 $o = get_userdata( $o->ID ); 125 125 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"'; 126 126 else $selected = ''; -
wp-admin/menu.php
52 52 $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php'); 53 53 54 54 // Create list of page plugin hook names. 55 foreach ( $menu as $menu_page) {55 foreach ( (array) $menu as $menu_page) { 56 56 $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]); 57 57 } 58 58 59 59 do_action('admin_menu', ''); 60 60 61 61 // Loop over submenus and remove pages for which the user does not have privs. 62 foreach ( $submenu as $parent => $sub) {63 foreach ( $sub as $index => $data) {62 foreach ( (array) $submenu as $parent => $sub) { 63 foreach ( (array) $sub as $index => $data) { 64 64 if ( ! current_user_can($data[1]) ) { 65 65 $menu_nopriv[$data[2]] = true; 66 66 unset($submenu[$parent][$index]); … … 75 75 // Remove menus that have no accessible submenus and require privs that the user does not have. 76 76 // Menus for which the original parent is not acessible due to lack of privs will have the next 77 77 // submenu in line be assigned as the new menu parent. 78 foreach ( $menu as $id => $data ) {78 foreach ( (array) $menu as $id => $data ) { 79 79 // If submenu is empty... 80 80 if ( empty($submenu[$data[2]]) ) { 81 81 // And user doesn't have privs, remove menu. … … 94 94 $real_parent_file[$old_parent] = $new_parent; 95 95 $menu[$id][2] = $new_parent; 96 96 97 foreach ( $submenu[$old_parent] as $index => $data) {97 foreach ( (array) $submenu[$old_parent] as $index => $data) { 98 98 $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; 99 99 unset($submenu[$old_parent][$index]); 100 100 } -
wp-admin/link-import.php
47 47 <?php _e('Category:') ?> <select name="cat_id"> 48 48 <?php 49 49 $categories = get_categories('hide_empty=0'); 50 foreach ( $categories as $category) {50 foreach ( (array) $categories as $category) { 51 51 ?> 52 52 <option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option> 53 53 <?php -
wp-admin/plugins.php
41 41 42 42 // If a plugin file does not exist, remove it from the list of active 43 43 // plugins. 44 foreach ( $check_plugins as $check_plugin) {44 foreach ( (array) $check_plugins as $check_plugin) { 45 45 if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) { 46 46 $current = get_settings('active_plugins'); 47 47 $key = array_search($check_plugin, $current); … … 96 96 97 97 uksort($plugins, 'sort_plugins'); 98 98 99 foreach( $plugins as $plugin_file => $plugin_data) {99 foreach( (array) $plugins as $plugin_file => $plugin_data) { 100 100 $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate'; 101 101 102 102 if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { -
wp-admin/edit.php
18 18 <p><strong><?php _e('Your Drafts:') ?></strong> 19 19 <?php 20 20 $i = 0; 21 foreach ( $drafts as $draft) {21 foreach ( (array) $drafts as $draft) { 22 22 if (0 != $i) 23 23 echo ', '; 24 24 $draft->post_title = stripslashes($draft->post_title); … … 35 35 <p><strong><?php _e('Other’s Drafts:') ?></strong> 36 36 <?php 37 37 $i = 0; 38 foreach ( $other_drafts as $draft) {38 foreach ( (array) $other_drafts as $draft) { 39 39 if (0 != $i) 40 40 echo ', '; 41 41 $draft->post_title = stripslashes($draft->post_title); … … 90 90 <legend><?php _e('Browse Month…') ?></legend> 91 91 <select name='m'> 92 92 <?php 93 foreach ( $arc_result as $arc_row) {93 foreach ( (array) $arc_result as $arc_row) { 94 94 if ( $arc_row->yyear == 0 ) 95 95 continue; 96 96 $arc_row->mmonth = zeroise($arc_row->mmonth, 2); … … 137 137 <thead> 138 138 <tr> 139 139 140 <?php foreach( $posts_columns as $column_display_name) { ?>140 <?php foreach( (array) $posts_columns as $column_display_name) { ?> 141 141 <th scope="col"><?php echo $column_display_name; ?></th> 142 142 <?php } ?> 143 143 … … 147 147 <?php 148 148 if ($posts) { 149 149 $bgcolor = ''; 150 foreach ( $posts as $post) { start_wp();150 foreach ( (array) $posts as $post) { start_wp(); 151 151 add_filter('the_title','wp_specialchars'); 152 152 $class = ('alternate' == $class) ? '' : 'alternate'; 153 153 ?> … … 155 155 156 156 <?php 157 157 158 foreach( $posts_columns as $column_name=>$column_display_name) {158 foreach( (array) $posts_columns as $column_name=>$column_display_name) { 159 159 160 160 switch($column_name) { 161 161 … … 254 254 <ol id="the-list" class="commentlist"> 255 255 <?php 256 256 $i = 0; 257 foreach ( $comments as $comment) {257 foreach ( (array) $comments as $comment) { 258 258 259 259 ++$i; $class = ''; 260 260 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); -
wp-admin/options.php
32 32 check_admin_referer('update-options'); 33 33 34 34 if (!$_POST['page_options']) { 35 foreach ( $_POST as $key => $value) {35 foreach ( (array) $_POST as $key => $value) { 36 36 $options[] = $key; 37 37 } 38 38 } else { … … 47 47 // Options that if not there have 0 value but need to be something like "closed" 48 48 $nonbools = array('default_ping_status', 'default_comment_status'); 49 49 if ($options) { 50 foreach ( $options as $option) {50 foreach ( (array) $options as $option) { 51 51 $option = trim($option); 52 52 $value = trim(stripslashes($_POST[$option])); 53 53 if( in_array($option, $nonbools) && ( $value == '0' || $value == '') ) … … 95 95 <?php 96 96 $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name"); 97 97 98 foreach ( $options as $option) :98 foreach ( (array) $options as $option) : 99 99 $value = wp_specialchars($option->option_value, 'single'); 100 100 echo " 101 101 <tr> -
wp-admin/link.php
42 42 } 43 43 44 44 $deleted = 0; 45 foreach ( $linkcheck as $link_id) {45 foreach ( (array) $linkcheck as $link_id) { 46 46 $link_id = (int) $link_id; 47 47 48 48 if ( wp_delete_link($link_id) ) -
wp-admin/profile.php
122 122 <th scope="row"><?php _e('Additional Capabilities:') ?></th> 123 123 <td><?php 124 124 $output = ''; 125 foreach( $profileuser->caps as $cap => $value) {125 foreach( (array) $profileuser->caps as $cap => $value) { 126 126 if(!$wp_roles->is_role($cap)) { 127 127 if($output != '') $output .= ', '; 128 128 $output .= $value ? $cap : "Denied: {$cap}"; -
wp-admin/user-edit.php
63 63 <div class="error"> 64 64 <ul> 65 65 <?php 66 foreach( $errors->get_error_messages() as $message )66 foreach( (array) $errors->get_error_messages() as $message ) 67 67 echo "<li>$message</li>"; 68 68 ?> 69 69 </ul> … … 90 90 <?php 91 91 // print_r($profileuser); 92 92 echo '<select name="role">'; 93 foreach( $wp_roles->role_names as $role => $name) {93 foreach( (array) $wp_roles->role_names as $role => $name) { 94 94 $selected = ($profileuser->has_cap($role)) ? ' selected="selected"' : ''; 95 95 echo "<option value=\"{$role}\"{$selected}>{$name}</option>"; 96 96 } … … 180 180 <th scope="row"><?php _e('Additional Capabilities:') ?></th> 181 181 <td><?php 182 182 $output = ''; 183 foreach( $profileuser->caps as $cap => $value) {183 foreach( (array) $profileuser->caps as $cap => $value) { 184 184 if(!$wp_roles->is_role($cap)) { 185 185 if($output != '') $output .= ', '; 186 186 $output .= $value ? $cap : "Denied: {$cap}"; -
wp-admin/setup-config.php
154 154 require_once('../wp-includes/wp-db.php'); 155 155 $handle = fopen('../wp-config.php', 'w'); 156 156 157 foreach ( $configFile as $line_num => $line) {157 foreach ( (array) $configFile as $line_num => $line) { 158 158 switch (substr($line,0,16)) { 159 159 case "define('DB_NAME'": 160 160 fwrite($handle, str_replace("wordpress", $dbname, $line)); -
wp-admin/link-manager.php
95 95 <?php $categories = get_categories("hide_empty=1&type=link"); ?> 96 96 <select name="cat_id"> 97 97 <option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option> 98 <?php foreach ( $categories as $cat): ?>98 <?php foreach ( (array) $categories as $cat): ?> 99 99 <option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo wp_specialchars($cat->cat_name); ?> 100 100 </option> 101 101 <?php endforeach; ?> … … 133 133 $cat_id = ''; 134 134 $links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0"); 135 135 if ($links) 136 foreach ( $links as $link) {136 foreach ( (array) $links as $link) { 137 137 $link->link_name = wp_specialchars($link->link_name); 138 138 $link->link_description = wp_specialchars($link->link_description); 139 139 $link->link_url = wp_specialchars($link->link_url); … … 161 161 <?php 162 162 163 163 $cat_names = array(); 164 foreach ( $link->link_category as $category) {164 foreach ( (array) $link->link_category as $category) { 165 165 $cat_name = get_the_category_by_ID($category); 166 166 $cat_name = wp_specialchars($cat_name); 167 167 if ( $cat_id != $category ) -
wp-admin/import.php
34 34 35 35 <?php 36 36 $style = ''; 37 foreach ( $importers as $id => $data) {37 foreach ( (array) $importers as $id => $data) { 38 38 $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate'; 39 39 $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>"; 40 40 -
wp-admin/options-writing.php
34 34 <td><select name="default_category" id="default_category"> 35 35 <?php 36 36 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name"); 37 foreach ( $categories as $category) :37 foreach ( (array) $categories as $category) : 38 38 if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'"; 39 39 else $selected = ''; 40 40 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; … … 46 46 <th scope="row"><?php _e('Default bookmark category:') ?></th> 47 47 <td><select name="default_link_category" id="default_link_category"> 48 48 <?php 49 foreach ( $categories as $category) :49 foreach ( (array) $categories as $category) : 50 50 if ($category->cat_ID == get_settings('default_link_category')) $selected = " selected='selected'"; 51 51 else $selected = ''; 52 52 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; … … 83 83 <td><select name="default_email_category" id="default_email_category"> 84 84 <?php 85 85 //Alreay have $categories from default_category 86 foreach ( $categories as $category) :86 foreach ( (array) $categories as $category) : 87 87 if ($category->cat_ID == get_settings('default_email_category')) $selected = " selected='selected'"; 88 88 else $selected = ''; 89 89 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; -
wp-admin/export.php
48 48 <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator> 49 49 <language><?php echo get_option('rss_language'); ?></language> 50 50 <?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(); ?> 52 52 <item> 53 53 <title><?php the_title_rss() ?></title> 54 54 <link><?php permalink_single_rss() ?></link> … … 71 71 $postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); 72 72 if ( $postmeta ) { 73 73 ?> 74 <?php foreach( $postmeta as $meta ) { ?>74 <?php foreach( (array) $postmeta as $meta ) { ?> 75 75 <wp:postmeta> 76 76 <wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key> 77 77 <wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value> … … 80 80 <?php } ?> 81 81 <?php 82 82 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID"); 83 if ( $comments ) { foreach ( $comments as $c ) { ?>83 if ( $comments ) { foreach ( (array) $comments as $c ) { ?> 84 84 <wp:comment> 85 85 <wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author> 86 86 <wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email> -
wp-admin/plugin-editor.php
89 89 if ($plugin_files) : 90 90 ?> 91 91 <ul> 92 <?php foreach( $plugin_files as $plugin_file) : ?>92 <?php foreach( (array) $plugin_files as $plugin_file) : ?> 93 93 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li> 94 94 <?php endforeach; ?> 95 95 </ul> -
wp-admin/upgrade-schema.php
235 235 236 236 // Delete unused options 237 237 $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog'); 238 foreach ( $unusedoptions as $option) :238 foreach ( (array) $unusedoptions as $option) : 239 239 delete_option($option); 240 240 endforeach; 241 241 242 242 // Set up a few options not to load by default 243 243 $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); 244 foreach ( $fatoptions as $fatoption) :244 foreach ( (array) $fatoptions as $fatoption) : 245 245 $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'"); 246 246 endforeach; 247 247 } … … 342 342 343 343 function populate_roles_210() { 344 344 $roles = array('administrator', 'editor'); 345 foreach ( $roles as $role) {345 foreach ( (array) $roles as $role) { 346 346 $role = get_role($role); 347 347 if ( empty($role) ) 348 348 continue; -
wp-admin/themes.php
58 58 $theme_names = array_keys($themes); 59 59 natcasesort($theme_names); 60 60 61 foreach ( $theme_names as $theme_name) {61 foreach ( (array) $theme_names as $theme_name) { 62 62 if ( $theme_name == $ct->name ) 63 63 continue; 64 64 $template = $themes[$theme_name]['Template']; … … 106 106 $theme_names = array_keys($broken_themes); 107 107 natcasesort($theme_names); 108 108 109 foreach ( $theme_names as $theme_name) {109 foreach ( (array) $theme_names as $theme_name) { 110 110 $title = $broken_themes[$theme_name]['Title']; 111 111 $description = $broken_themes[$theme_name]['Description']; 112 112