Ticket #2784: foreach_refresh.diff
| File foreach_refresh.diff, 149.8 KB (added by , 19 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_option('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/post-template.php
215 215 216 216 if ( $keys = get_post_custom_keys() ) { 217 217 echo "<ul class='post-meta'>\n"; 218 foreach ( $keys as $key ) {218 foreach ( (array) $keys as $key ) { 219 219 $keyt = trim($key); 220 220 if ( '_' == $keyt{0} ) 221 221 continue; … … 375 375 376 376 $types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime)); 377 377 $exts = array('jpg', 'gif', 'png'); 378 foreach ( $types as $type) {379 foreach ( $exts as $ext) {378 foreach ( (array) $types as $type) { 379 foreach ( (array) $exts as $ext) { 380 380 $src_file = "$icon_dir/$type.$ext"; 381 381 if ( file_exists($src_file) ) { 382 382 $src = "$icon_dir_uri/$type.$ext"; -
wp-includes/plugin.php
9 9 10 10 // check that we don't already have the same filter at the same priority 11 11 if ( isset($wp_filter[$tag]["$priority"]) ) { 12 foreach( $wp_filter[$tag]["$priority"] as $filter) {12 foreach( (array) $wp_filter[$tag]["$priority"] as $filter) { 13 13 // uncomment if we want to match function AND accepted_args 14 14 // if ( $filter == array($function, $accepted_args) ) { 15 15 if ( $filter['function'] == $function_to_add ) { … … 35 35 if ( !isset($wp_filter[$tag]) ) { 36 36 return $string; 37 37 } 38 foreach ( $wp_filter[$tag] as $priority => $functions) {38 foreach ( (array) $wp_filter[$tag] as $priority => $functions) { 39 39 if ( !is_null($functions) ) { 40 foreach( $functions as $function) {40 foreach( (array) $functions as $function) { 41 41 42 42 $function_name = $function['function']; 43 43 $accepted_args = $function['accepted_args']; … … 60 60 function merge_filters($tag) { 61 61 global $wp_filter; 62 62 if ( isset($wp_filter['all']) ) { 63 foreach ( $wp_filter['all'] as $priority => $functions) {63 foreach ( (array) $wp_filter['all'] as $priority => $functions) { 64 64 if ( isset($wp_filter[$tag][$priority]) ) 65 65 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]); 66 66 else … … 81 81 // rebuild the list of filters 82 82 if ( isset($wp_filter[$tag]["$priority"]) ) { 83 83 $new_function_list = array(); 84 foreach( $wp_filter[$tag]["$priority"] as $filter) {84 foreach( (array) $wp_filter[$tag]["$priority"] as $filter) { 85 85 if ( $filter['function'] != $function_to_remove ) { 86 86 $new_function_list[] = $filter; 87 87 } … … 114 114 if ( !isset($wp_filter[$tag]) ) 115 115 return; 116 116 117 foreach ( $wp_filter[$tag] as $priority => $functions) {117 foreach ( (array) $wp_filter[$tag] as $priority => $functions) { 118 118 if ( !is_null($functions) ) { 119 foreach( $functions as $function) {119 foreach( (array) $functions as $function) { 120 120 121 121 $function_name = $function['function']; 122 122 $accepted_args = $function['accepted_args']; … … 142 142 if ( !isset($wp_filter[$tag]) ) 143 143 return; 144 144 145 foreach ( $wp_filter[$tag] as $priority => $functions) {145 foreach ( (array) $wp_filter[$tag] as $priority => $functions) { 146 146 if ( !is_null($functions) ) { 147 foreach( $functions as $function) {147 foreach( (array) $functions as $function) { 148 148 149 149 $function_name = $function['function']; 150 150 $accepted_args = $function['accepted_args']; -
wp-includes/locale.php
35 35 $this->weekday_initial[__('Friday')] = __('F_Friday_initial'); 36 36 $this->weekday_initial[__('Saturday')] = __('S_Saturday_initial'); 37 37 38 foreach ( $this->weekday_initial as $weekday_ => $weekday_initial_) {38 foreach ( (array) $this->weekday_initial as $weekday_ => $weekday_initial_) { 39 39 $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_); 40 40 } 41 41 … … 77 77 $this->month_abbrev[__('November')] = __('Nov_November_abbreviation'); 78 78 $this->month_abbrev[__('December')] = __('Dec_December_abbreviation'); 79 79 80 foreach ( $this->month_abbrev as $month_ => $month_abbrev_) {80 foreach ( (array) $this->month_abbrev as $month_ => $month_abbrev_) { 81 81 $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_); 82 82 } 83 83 … … 98 98 99 99 include($locale_file); 100 100 101 foreach ( $this->locale_vars as $var ) {101 foreach ( (array) $this->locale_vars as $var ) { 102 102 $this->$var = $$var; 103 103 } 104 104 } -
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/bookmark.php
42 42 $category_name = ''; 43 43 $inclinks = preg_split('/[\s,]+/',$include); 44 44 if ( count($inclinks) ) { 45 foreach ( $inclinks as $inclink ) {45 foreach ( (array) $inclinks as $inclink ) { 46 46 if (empty($inclusions)) 47 47 $inclusions = ' AND ( link_id = ' . intval($inclink) . ' '; 48 48 else … … 57 57 if ( !empty($exclude) ) { 58 58 $exlinks = preg_split('/[\s,]+/',$exclude); 59 59 if ( count($exlinks) ) { 60 foreach ( $exlinks as $exlink ) {60 foreach ( (array) $exlinks as $exlink ) { 61 61 if (empty($exclusions)) 62 62 $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' '; 63 63 else … … 78 78 if ( !empty($category) ) { 79 79 $incategories = preg_split('/[\s,]+/',$category); 80 80 if ( count($incategories) ) { 81 foreach ( $incategories as $incat ) {81 foreach ( (array) $incategories as $incat ) { 82 82 if (empty($category_query)) 83 83 $category_query = ' AND ( category_id = ' . intval($incat) . ' '; 84 84 else -
wp-includes/query.php
360 360 , 'preview' 361 361 ); 362 362 363 foreach ( $keys as $key) {363 foreach ( (array) $keys as $key) { 364 364 if ( !isset($array[$key])) 365 365 $array[$key] = ''; 366 366 } … … 780 780 $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) "; 781 781 $cat_array = preg_split('/[,\s]+/', $q['cat']); 782 782 $in_cats = $out_cats = $out_posts = ''; 783 foreach ( $cat_array as $cat ) {783 foreach ( (array) $cat_array as $cat ) { 784 784 $cat = intval($cat); 785 785 $in = strstr($cat, '-') ? false : true; 786 786 $cat = trim($cat, '-'); … … 796 796 if ( strlen($out_cats) > 0 ) { 797 797 $ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id IN ($out_cats)"); 798 798 if ( is_array($ids) && count($ids > 0) ) { 799 foreach ( $ids as $id )799 foreach ( (array) $ids as $id ) 800 800 $out_posts .= "$id, "; 801 801 $out_posts = substr($out_posts, 0, -2); 802 802 } … … 819 819 $cat_paths = '/' . trim(urldecode($q['category_name']), '/'); 820 820 $q['category_name'] = sanitize_title(basename($cat_paths)); 821 821 $cat_paths = explode('/', $cat_paths); 822 foreach( $cat_paths as $pathdir)822 foreach( (array) $cat_paths as $pathdir) 823 823 $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 824 824 825 825 //if we don't match the entire hierarchy fallback on just matching the nicename -
wp-includes/link-template.php
272 272 $sql_exclude_cats = ''; 273 273 if ( !empty($excluded_categories) ) { 274 274 $blah = explode(' and ', $excluded_categories); 275 foreach ( $blah as $category ) {275 foreach ( (array) $blah as $category ) { 276 276 $category = intval($category); 277 277 $sql_cat_ids = " OR pc.category_ID = '$category'"; 278 278 } … … 305 305 $sql_exclude_cats = ''; 306 306 if ( !empty($excluded_categories) ) { 307 307 $blah = explode(' and ', $excluded_categories); 308 foreach ( $blah as $category ) {308 foreach ( (array) $blah as $category ) { 309 309 $category = intval($category); 310 310 $sql_cat_ids = " OR pc.category_ID = '$category'"; 311 311 } -
wp-includes/wp-db.php
258 258 } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { 259 259 if ( $this->last_result ) { 260 260 $i = 0; 261 foreach( $this->last_result as $row ) {261 foreach( (array) $this->last_result as $row ) { 262 262 $new_array[$i] = (array) $row; 263 263 if ( $output == ARRAY_N ) { 264 264 $new_array[$i] = array_values($new_array[$i]); … … 281 281 if ( $this->col_info ) { 282 282 if ( $col_offset == -1 ) { 283 283 $i = 0; 284 foreach( $this->col_info as $col ) {284 foreach( (array) $this->col_info as $col ) { 285 285 $new_array[$i] = $col->{$info_type}; 286 286 $i++; 287 287 } -
wp-includes/author-template.php
188 188 $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; 189 189 $authors = $wpdb->get_results($query); 190 190 191 foreach ( $authors as $author ) {191 foreach ( (array) $authors as $author ) { 192 192 $author = get_userdata( $author->ID ); 193 193 $posts = get_usernumposts($author->ID); 194 194 $name = $author->nickname; -
wp-includes/category.php
37 37 $exclude = ''; 38 38 $incategories = preg_split('/[\s,]+/',$include); 39 39 if ( count($incategories) ) { 40 foreach ( $incategories as $incat ) {40 foreach ( (array) $incategories as $incat ) { 41 41 if (empty($inclusions)) 42 42 $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' '; 43 43 else … … 53 53 if ( !empty($exclude) ) { 54 54 $excategories = preg_split('/[\s,]+/',$exclude); 55 55 if ( count($excategories) ) { 56 foreach ( $excategories as $excat ) {56 foreach ( (array) $excategories as $excat ) { 57 57 if (empty($exclusions)) 58 58 $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' '; 59 59 else … … 89 89 $stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories 90 90 WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id"); 91 91 global $cat_stamps; 92 foreach ( $stamps as $stamp)92 foreach ( (array) $stamps as $stamp) 93 93 $cat_stamps[$stamp->category_id] = $stamp->ts; 94 94 function stamp_cat($cat) { 95 95 global $cat_stamps; … … 105 105 106 106 // Update category counts to include children. 107 107 if ( $hierarchical ) { 108 foreach ( $categories as $k => $category ) {108 foreach ( (array) $categories as $k => $category ) { 109 109 $progeny = $category->category_count; 110 110 if ( $children = _get_cat_children($category->cat_ID, $categories) ) { 111 foreach ( $children as $child )111 foreach ( (array) $children as $child ) 112 112 $progeny += $child->category_count; 113 113 } 114 114 if ( !$progeny && $hide_empty ) … … 161 161 $category_paths = '/' . trim($category_path, '/'); 162 162 $leaf_path = sanitize_title(basename($category_paths)); 163 163 $category_paths = explode('/', $category_paths); 164 foreach( $category_paths as $pathdir)164 foreach( (array) $category_paths as $pathdir) 165 165 $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 166 166 167 167 $categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'"); … … 169 169 if ( empty($categories) ) 170 170 return NULL; 171 171 172 foreach ( $categories as $category) {172 foreach ( (array) $categories as $category) { 173 173 $path = '/' . $leaf_path; 174 174 $curcategory = $category; 175 175 while ( ($curcategory->category_parent != 0) && ($curcategory->category_parent != $curcategory->cat_ID) ) { … … 218 218 return array(); 219 219 220 220 $category_list = array(); 221 foreach ( $categories as $category ) {221 foreach ( (array) $categories as $category ) { 222 222 if ( $category->cat_ID == $category_id ) 223 223 continue; 224 224 -
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; … … 471 471 function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) { 472 472 //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/? 473 473 $feedregex2 = ''; 474 foreach ( $this->feeds as $feed_name) {474 foreach ( (array) $this->feeds as $feed_name) { 475 475 $feedregex2 .= $feed_name . '|'; 476 476 } 477 477 $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$'; … … 486 486 //build up an array of endpoint regexes to append => queries to append 487 487 if ($endpoints) { 488 488 $ep_query_append = array (); 489 foreach ( $this->endpoints as $endpoint) {489 foreach ( (array) $this->endpoints as $endpoint) { 490 490 //match everything after the endpoint name, but allow for nothing to appear there 491 491 $epmatch = $endpoint[1] . '(/(.*))?/?$'; 492 492 //this will be appended on to the rest of the query for each dir … … 600 600 601 601 //do endpoints 602 602 if ($endpoints) { 603 foreach ( $ep_query_append as $regex => $ep) {603 foreach ( (array) $ep_query_append as $regex => $ep) { 604 604 //add the endpoints on if the mask fits 605 605 if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) { 606 606 $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); … … 640 640 $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); 641 641 642 642 //do endpoints for attachments 643 if ($endpoint) { foreach ( $ep_query_append as $regex => $ep) {643 if ($endpoint) { foreach ( (array) $ep_query_append as $regex => $ep) { 644 644 if ($ep[0] & EP_ATTACHMENT) { 645 645 $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2); 646 646 $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2); … … 678 678 } //if($num_toks) 679 679 //add the rules for this dir to the accumulating $post_rewrite 680 680 $post_rewrite = array_merge($rewrite, $post_rewrite); 681 } //foreach ( $dir)681 } //foreach ( (array) $dir) 682 682 return $post_rewrite; //the finished rules. phew! 683 683 } 684 684 … … 769 769 $rules .= "RewriteBase $home_root\n"; 770 770 771 771 //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all) 772 foreach ( $this->non_wp_rules as $match => $query) {772 foreach ( (array) $this->non_wp_rules as $match => $query) { 773 773 // Apache 1.3 does not support the reluctant (non-greedy) modifier. 774 774 $match = str_replace('.+?', '.+', $match); 775 775 … … 790 790 "RewriteCond %{REQUEST_FILENAME} -d\n" . 791 791 "RewriteRule ^.*$ - [S=$num_rules]\n"; 792 792 793 foreach ( $rewrite as $match => $query) {793 foreach ( (array) $rewrite as $match => $query) { 794 794 // Apache 1.3 does not support the reluctant (non-greedy) modifier. 795 795 $match = str_replace('.+?', '.+', $match); 796 796 -
wp-includes/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/post.php
29 29 $children = $wpdb->get_results($query); 30 30 31 31 if ( $children ) { 32 foreach ( $children as $key => $child ) {32 foreach ( (array) $children as $key => $child ) { 33 33 $post_cache[$child->ID] =& $children[$key]; 34 34 $kids[$child->ID] =& $children[$key]; 35 35 } … … 40 40 if ( $output == OBJECT ) { 41 41 return $kids; 42 42 } elseif ( $output == ARRAY_A ) { 43 foreach ( $kids as $kid )43 foreach ( (array) $kids as $kid ) 44 44 $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]); 45 45 return $weeuns; 46 46 } elseif ( $output == ARRAY_N ) { 47 foreach ( $kids as $kid )47 foreach ( (array) $kids as $kid ) 48 48 $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID])); 49 49 return $babes; 50 50 } else { … … 173 173 $incposts = preg_split('/[\s,]+/',$include); 174 174 $numberposts = count($incposts); // only the number of posts included 175 175 if ( count($incposts) ) { 176 foreach ( $incposts as $incpost ) {176 foreach ( (array) $incposts as $incpost ) { 177 177 if (empty($inclusions)) 178 178 $inclusions = ' AND ( ID = ' . intval($incpost) . ' '; 179 179 else … … 188 188 if ( !empty($exclude) ) { 189 189 $exposts = preg_split('/[\s,]+/',$exclude); 190 190 if ( count($exposts) ) { 191 foreach ( $exposts as $expost ) {191 foreach ( (array) $exposts as $expost ) { 192 192 if (empty($exclusions)) 193 193 $exclusions = ' AND ( ID <> ' . intval($expost) . ' '; 194 194 else … … 261 261 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' 262 262 AND meta_key = '$key' AND meta_value = '$value'"); 263 263 $cache_key = $post_meta_cache['$post_id'][$key]; 264 if ($cache_key) foreach ( $cache_key as $index => $data )264 if ($cache_key) foreach ( (array) $cache_key as $index => $data ) 265 265 if ( $data == $value ) 266 266 unset($post_meta_cache['$post_id'][$key][$index]); 267 267 } … … 286 286 287 287 $values = array(); 288 288 if ( $metalist ) { 289 foreach ( $metalist as $metarow) {289 foreach ( (array) $metalist as $metarow) { 290 290 $values[] = $metarow[0]; 291 291 } 292 292 } … … 325 325 meta_key = '$key' AND post_id = '$post_id'"); 326 326 $cache_key = $post_meta_cache['$post_id'][$key]; 327 327 if ( !empty($cache_key) ) 328 foreach ( $cache_key as $index => $data)328 foreach ( (array) $cache_key as $index => $data) 329 329 $post_meta_cache['$post_id'][$key][$index] = $original_value; 330 330 } else { 331 331 $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE 332 332 meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'"); 333 333 $cache_key = $post_meta_cache['$post_id'][$key]; 334 334 if ( !empty($cache_key) ) 335 foreach ( $cache_key as $index => $data)335 foreach ( (array) $cache_key as $index => $data) 336 336 if ( $data == $original_prev ) 337 337 $post_meta_cache['$post_id'][$key][$index] = $original_value; 338 338 } … … 353 353 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) ) { 354 354 // Change from flat structure to hierarchical: 355 355 $post_meta_cache = array(); 356 foreach ( $meta_list as $metarow ) {356 foreach ( (array) $meta_list as $metarow ) { 357 357 $mpid = $metarow['post_id']; 358 358 $mkey = $metarow['meta_key']; 359 359 $mval = $metarow['meta_value']; … … 404 404 if ( 'publish' == $post->post_status && 'post' == $post->post_type ) { 405 405 $categories = wp_get_post_categories($post->ID); 406 406 if( is_array( $categories ) ) { 407 foreach ( $categories as $cat_id ) {407 foreach ( (array) $categories as $cat_id ) { 408 408 $wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'"); 409 409 wp_cache_delete($cat_id, 'category'); 410 410 } … … 782 782 $delete_cats = array_diff($old_categories,$post_categories); 783 783 784 784 if ($delete_cats) { 785 foreach ( $delete_cats as $del) {785 foreach ( (array) $delete_cats as $del) { 786 786 $wpdb->query(" 787 787 DELETE FROM $wpdb->post2cat 788 788 WHERE category_id = $del … … 795 795 $add_cats = array_diff($post_categories, $old_categories); 796 796 797 797 if ($add_cats) { 798 foreach ( $add_cats as $new_cat) {798 foreach ( (array) $add_cats as $new_cat) { 799 799 if ( !empty($new_cat) ) 800 800 $wpdb->query(" 801 801 INSERT INTO $wpdb->post2cat (post_id, category_id) … … 805 805 806 806 // Update category counts. 807 807 $all_affected_cats = array_unique(array_merge($post_categories, $old_categories)); 808 foreach ( $all_affected_cats as $cat_id ) {808 foreach ( (array) $all_affected_cats as $cat_id ) { 809 809 $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'"); 810 810 $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'"); 811 811 wp_cache_delete($cat_id, 'category'); … … 834 834 if ( !is_array( $custom_fields ) ) 835 835 return $pung; 836 836 837 foreach ( $custom_fields as $key => $val ) {837 foreach ( (array) $custom_fields as $key => $val ) { 838 838 if ( 'enclosure' != $key || !is_array( $val ) ) 839 839 continue; 840 foreach( $val as $enc ) {840 foreach( (array) $val as $enc ) { 841 841 $enclosure = split( "\n", $enc ); 842 842 $pung[] = trim( $enclosure[ 0 ] ); 843 843 } … … 882 882 } 883 883 884 884 $trackback_urls = explode(',', $tb_list); 885 foreach( $trackback_urls as $tb_url) {885 foreach( (array) $trackback_urls as $tb_url) { 886 886 $tb_url = trim($tb_url); 887 887 trackback($tb_url, stripslashes($post_title), $excerpt, $post_id); 888 888 } … … 958 958 $page_paths = '/' . trim($page_path, '/'); 959 959 $leaf_path = sanitize_title(basename($page_paths)); 960 960 $page_paths = explode('/', $page_paths); 961 foreach( $page_paths as $pathdir)961 foreach( (array) $page_paths as $pathdir) 962 962 $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 963 963 964 964 $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'"); … … 966 966 if ( empty($pages) ) 967 967 return NULL; 968 968 969 foreach ( $pages as $page) {969 foreach ( (array) $pages as $page) { 970 970 $path = '/' . $leaf_path; 971 971 $curpage = $page; 972 972 while ($curpage->post_parent != 0) { … … 988 988 $pages = &$page_cache; 989 989 990 990 $page_list = array(); 991 foreach ( $pages as $page ) {991 foreach ( (array) $pages as $page ) { 992 992 if ( $page->post_parent == $page_id ) { 993 993 $page_list[] = $page; 994 994 if ( $children = get_page_children($page->ID, $pages) ) … … 1002 1002 //immediately follow their parents 1003 1003 function get_page_hierarchy($posts, $parent = 0) { 1004 1004 $result = array ( ); 1005 if ($posts) { foreach ( $posts as $post) {1005 if ($posts) { foreach ( (array) $posts as $post) { 1006 1006 if ($post->post_parent == $parent) { 1007 1007 $result[$post->ID] = $post->post_name; 1008 1008 $children = get_page_hierarchy($posts, $post->ID); … … 1049 1049 $meta_value = ''; 1050 1050 $incpages = preg_split('/[\s,]+/',$include); 1051 1051 if ( count($incpages) ) { 1052 foreach ( $incpages as $incpage ) {1052 foreach ( (array) $incpages as $incpage ) { 1053 1053 if (empty($inclusions)) 1054 1054 $inclusions = ' AND ( ID = ' . intval($incpage) . ' '; 1055 1055 else … … 1064 1064 if ( !empty($exclude) ) { 1065 1065 $expages = preg_split('/[\s,]+/',$exclude); 1066 1066 if ( count($expages) ) { 1067 foreach ( $expages as $expage ) {1067 foreach ( (array) $expages as $expage ) { 1068 1068 if (empty($exclusions)) 1069 1069 $exclusions = ' AND ( ID <> ' . intval($expage) . ' '; 1070 1070 else … … 1080 1080 $post_authors = preg_split('/[\s,]+/',$authors); 1081 1081 1082 1082 if ( count($post_authors) ) { 1083 foreach ( $post_authors as $post_author ) {1083 foreach ( (array) $post_authors as $post_author ) { 1084 1084 //Do we have an author id or an author login? 1085 1085 if ( 0 == intval($post_author) ) { 1086 1086 $post_author = get_userdatabylogin($post_author); … … 1136 1136 1137 1137 if ($posts) { 1138 1138 1139 foreach ( $posts as $id => $post) {1139 foreach ( (array) $posts as $id => $post) { 1140 1140 1141 1141 // URL => page name 1142 1142 $uri = get_page_uri($id); 1143 1143 $attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$id'"); 1144 1144 if ( $attachments ) { 1145 foreach ( $attachments as $attachment ) {1145 foreach ( (array) $attachments as $attachment ) { 1146 1146 $attach_uri = get_page_uri($attachment->ID); 1147 1147 $page_attachment_uris[$attach_uri] = $attachment->ID; 1148 1148 } -
wp-includes/general-template.php
332 332 $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); 333 333 if ( $arcresults ) { 334 334 $afterafter = $after; 335 foreach ( $arcresults as $arcresult ) {335 foreach ( (array) $arcresults as $arcresult ) { 336 336 $url = get_month_link($arcresult->year, $arcresult->month); 337 337 $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year); 338 338 if ( $show_post_count ) … … 344 344 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts WHERE post_type ='post' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit); 345 345 if ($arcresults) { 346 346 $afterafter = $after; 347 foreach ( $arcresults as $arcresult) {347 foreach ( (array) $arcresults as $arcresult) { 348 348 $url = get_year_link($arcresult->year); 349 349 $text = sprintf('%d', $arcresult->year); 350 350 if ($show_post_count) … … 356 356 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit); 357 357 if ( $arcresults ) { 358 358 $afterafter = $after; 359 foreach ( $arcresults as $arcresult ) {359 foreach ( (array) $arcresults as $arcresult ) { 360 360 $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); 361 361 $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth); 362 362 $text = mysql2date($archive_day_date_format, $date); … … 371 371 $arc_w_last = ''; 372 372 $afterafter = $after; 373 373 if ( $arcresults ) { 374 foreach ( $arcresults as $arcresult ) {374 foreach ( (array) $arcresults as $arcresult ) { 375 375 if ( $arcresult->week != $arc_w_last ) { 376 376 $arc_year = $arcresult->yr; 377 377 $arc_w_last = $arcresult->week; … … 390 390 ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC "; 391 391 $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY $orderby $limit"); 392 392 if ( $arcresults ) { 393 foreach ( $arcresults as $arcresult ) {393 foreach ( (array) $arcresults as $arcresult ) { 394 394 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { 395 395 $url = get_permalink($arcresult); 396 396 $arc_title = $arcresult->post_title; … … 480 480 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); 481 481 } 482 482 483 foreach ( $myweek as $wd ) {483 foreach ( (array) $myweek as $wd ) { 484 484 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 485 485 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 486 486 } … … 524 524 AND post_type = 'post' AND post_status = 'publish' 525 525 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); 526 526 if ( $dayswithposts ) { 527 foreach ( $dayswithposts as $daywith ) {527 foreach ( (array) $dayswithposts as $daywith ) { 528 528 $daywithpost[] = $daywith[0]; 529 529 } 530 530 } else { … … 547 547 ."AND post_type = 'post' AND post_status = 'publish'" 548 548 ); 549 549 if ( $ak_post_titles ) { 550 foreach ( $ak_post_titles as $ak_post_title ) {550 foreach ( (array) $ak_post_titles as $ak_post_title ) { 551 551 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) 552 552 $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; 553 553 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one … … 595 595 function allowed_tags() { 596 596 global $allowedtags; 597 597 $allowed = ''; 598 foreach ( $allowedtags as $tag => $attributes ) {598 foreach ( (array) $allowedtags as $tag => $attributes ) { 599 599 $allowed .= '<'.$tag; 600 600 if ( 0 < count($attributes) ) { 601 foreach ( $attributes as $attribute => $limits ) {601 foreach ( (array) $attributes as $attribute => $limits ) { 602 602 $allowed .= ' '.$attribute.'=""'; 603 603 } 604 604 } -
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); … … 48 48 $returnData = array(); 49 49 $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); 50 50 51 foreach( $dataArr as $dstr) {51 foreach( (array) $dataArr as $dstr) { 52 52 $matches = array(); 53 53 54 54 // Skip this line. … … 78 78 $returnData = array(); 79 79 $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); 80 80 81 foreach( $dataArr as $dstr) {81 foreach( (array) $dataArr as $dstr) { 82 82 $matches = array(); 83 83 84 84 // 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
170 170 171 171 // Load all plugins and their language packs 172 172 $plugins = explode(",", $plugins); 173 foreach ( $plugins as $plugin) {173 foreach ( (array) $plugins as $plugin) { 174 174 $pluginFile = realpath("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"); 175 175 /* WP $languageFile = realpath("plugins/" . $plugin . "/langs/" . $lang . ".js"); WP */ 176 176 -
wp-includes/capabilities.php
28 28 29 29 $this->role_objects = array(); 30 30 $this->role_names = array(); 31 foreach ( $this->roles as $role => $data) {31 foreach ( (array) $this->roles as $role => $data) { 32 32 $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']); 33 33 $this->role_names[$role] = $this->roles[$role]['name']; 34 34 } … … 207 207 } 208 208 209 209 function set_role($role) { 210 foreach( $this->roles as $oldrole)210 foreach( (array) $this->roles as $oldrole) 211 211 unset($this->caps[$oldrole]); 212 212 if ( !empty($role) ) { 213 213 $this->caps[$role] = true; … … 265 265 $caps = call_user_func_array('map_meta_cap', $args); 266 266 // Must have ALL requested caps 267 267 $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args); 268 foreach ( $caps as $cap) {268 foreach ( (array) $caps as $cap) { 269 269 //echo "Checking cap $cap<br/>"; 270 270 if(empty($capabilities[$cap]) || !$capabilities[$cap]) 271 271 return false; -
wp-includes/classes.php
85 85 86 86 // Look for matches. 87 87 $request_match = $request; 88 foreach ( $rewrite as $match => $query) {88 foreach ( (array) $rewrite as $match => $query) { 89 89 // If the requesting file is the anchor of the match, prepend it 90 90 // to the path info. 91 91 if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) { … … 150 150 $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; 151 151 } 152 152 153 foreach ( $this->private_query_vars as $var) {153 foreach ( (array) $this->private_query_vars as $var) { 154 154 if (isset($this->extra_query_vars[$var])) 155 155 $this->query_vars[$var] = $this->extra_query_vars[$var]; 156 156 elseif (isset($GLOBALS[$var]) && '' != $GLOBALS[$var]) … … 227 227 function register_globals() { 228 228 global $wp_query; 229 229 // Extract updated query vars back into global namespace. 230 foreach ( $wp_query->query_vars as $key => $value) {230 foreach ( (array) $wp_query->query_vars as $key => $value) { 231 231 $GLOBALS[$key] = $value; 232 232 } 233 233 … … 314 314 // Return all messages if no code specified. 315 315 if ( empty($code) ) { 316 316 $all_messages = array(); 317 foreach ( $this->errors as $code => $messages )317 foreach ( (array) $this->errors as $code => $messages ) 318 318 $all_messages = array_merge($all_messages, $messages); 319 319 320 320 return $all_messages; … … 390 390 391 391 $flat = ($to_depth == -1) ? true : false; 392 392 393 foreach ( $elements as $element ) {393 foreach ( (array) $elements as $element ) { 394 394 // If flat, start and end the element and skip the level checks. 395 395 if ( $flat) { 396 396 // Start the element. … … 671 671 672 672 $response = ''; 673 673 if ( is_wp_error($data) ) 674 foreach ( $data->get_error_codes() as $code )674 foreach ( (array) $data->get_error_codes() as $code ) 675 675 $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>"; 676 676 else 677 677 $response = "<response_data><![CDATA[$data]]></response_data>"; 678 678 679 679 $s = ''; 680 680 if ( (array) $supplemental ) 681 foreach ( $supplemental as $k => $v )681 foreach ( (array) $supplemental as $k => $v ) 682 682 $s .= "<$k><![CDATA[$v]]></$k>"; 683 683 684 684 if ( false === $action ) … … 699 699 function send() { 700 700 header('Content-type: text/xml'); 701 701 echo "<?xml version='1.0' standalone='yes'?><wp_ajax>"; 702 foreach ( $this->responses as $response )702 foreach ( (array) $this->responses as $response ) 703 703 echo $response; 704 704 echo '</wp_ajax>'; 705 705 die(); -
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
67 67 $key = md5(serialize($args)); 68 68 if ( empty($crons) ) 69 69 return false; 70 foreach ( $crons as $timestamp => $cron ) {70 foreach ( (array) $crons as $timestamp => $cron ) { 71 71 if ( isset( $cron[$hook][$key] ) ) 72 72 return $timestamp; 73 73 } … … 106 106 return; 107 107 108 108 $schedules = wp_get_schedules(); 109 foreach ( $crons as $timestamp => $cronhooks ) {109 foreach ( (array) $crons as $timestamp => $cronhooks ) { 110 110 if ( $timestamp > time() ) break; 111 foreach ( $cronhooks as $hook => $args ) {111 foreach ( (array) $cronhooks as $hook => $args ) { 112 112 if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) ) 113 113 continue; 114 114 spawn_cron(); … … 130 130 $key = md5(serialize($args)); 131 131 if ( empty($crons) ) 132 132 return false; 133 foreach ( $crons as $timestamp => $cron ) {133 foreach ( (array) $crons as $timestamp => $cron ) { 134 134 if ( isset( $cron[$hook][$key] ) ) 135 135 return $cron[$hook][$key]['schedule']; 136 136 } … … 165 165 166 166 $new_cron = array(); 167 167 168 foreach ( $cron as $timestamp => $hooks) {169 foreach ( $hooks as $hook => $args ) {168 foreach ( (array) $cron as $timestamp => $hooks) { 169 foreach ( (array) $hooks as $hook => $args ) { 170 170 $key = md5(serialize($args['args'])); 171 171 $new_cron[$timestamp][$hook][$key] = $args; 172 172 } -
wp-includes/theme.php
129 129 130 130 sort($theme_files); 131 131 132 foreach( $theme_files as $theme_file) {132 foreach( (array) $theme_files as $theme_file) { 133 133 if ( ! is_readable("$theme_root/$theme_file") ) { 134 134 $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.')); 135 135 continue; … … 222 222 // Resolve theme dependencies. 223 223 $theme_names = array_keys($themes); 224 224 225 foreach ( $theme_names as $theme_name) {225 foreach ( (array) $theme_names as $theme_name) { 226 226 $themes[$theme_name]['Parent Theme'] = ''; 227 227 if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) { 228 foreach ( $theme_names as $parent_theme_name) {228 foreach ( (array) $theme_names as $parent_theme_name) { 229 229 if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) { 230 230 $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name']; 231 231 break; … … 256 256 $current_theme = 'WordPress Default'; 257 257 258 258 if ( $themes ) { 259 foreach ( $theme_names as $theme_name) {259 foreach ( (array) $theme_names as $theme_name) { 260 260 if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet && 261 261 $themes[$theme_name]['Template'] == $current_template ) { 262 262 $current_theme = $themes[$theme_name]['Name']; -
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 … … 225 225 do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); 226 226 227 227 if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) { 228 foreach ( $chars[1] as $char) {228 foreach ( (array) $chars[1] as $char) { 229 229 // If it's an encoded char in the normal ASCII set, reject 230 230 if ( 38 == $char ) 231 231 continue; // Unless it's & … … 239 239 return false; // If moderation keys are empty 240 240 $words = explode("\n", $mod_keys ); 241 241 242 foreach ( $words as $word) {242 foreach ( (array) $words as $word) { 243 243 $word = trim($word); 244 244 245 245 // Skip empty lines … … 439 439 $comment = get_comment($commentarr['comment_ID'], ARRAY_A); 440 440 441 441 // Escape data pulled from DB. 442 foreach ( $comment as $key => $value)442 foreach ( (array) $comment as $key => $value) 443 443 $comment[$key] = $wpdb->escape($value); 444 444 445 445 // Merge old and new fields with new fields overwriting old ones. … … 594 594 // Do Trackbacks 595 595 $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); 596 596 if ( is_array($trackbacks) ) { 597 foreach ( $trackbacks as $trackback ) {597 foreach ( (array) $trackbacks as $trackback ) { 598 598 do_trackbacks($trackback->ID); 599 599 } 600 600 } … … 628 628 $post_title = apply_filters('the_title', $post->post_title); 629 629 $post_title = strip_tags($post_title); 630 630 631 if ($to_ping) : foreach ( $to_ping as $tb_ping) :631 if ($to_ping) : foreach ( (array) $to_ping as $tb_ping) : 632 632 $tb_ping = trim($tb_ping); 633 633 if ( !in_array($tb_ping, $pinged) ) { 634 634 trackback($tb_ping, $post_title, $excerpt, $post_id); … … 645 645 $services = trim($services); 646 646 if ( '' != $services ) { 647 647 $services = explode("\n", $services); 648 foreach ( $services as $service) {648 foreach ( (array) $services as $service) { 649 649 weblog_ping($service); 650 650 } 651 651 } … … 689 689 // http://dummy-weblog.org/post.php 690 690 // We don't wanna ping first and second types, even if they have a valid <link/> 691 691 692 foreach( $post_links_temp[0] as $link_test) :692 foreach( (array) $post_links_temp[0] as $link_test) : 693 693 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 694 694 && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. 695 695 $test = parse_url($link_test); … … 702 702 703 703 do_action_ref_array('pre_ping', array(&$post_links, &$pung)); 704 704 705 foreach ( $post_links as $pagelinkedto){705 foreach ( (array) $post_links as $pagelinkedto){ 706 706 debug_fwrite($log, "Processing -- $pagelinkedto\n"); 707 707 $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); 708 708 -
wp-includes/pluggable.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; … … 242 242 if ( !function_exists('check_ajax_referer') ) : 243 243 function check_ajax_referer() { 244 244 $cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie 245 foreach ( $cookie as $tasty ) {245 foreach ( (array) $cookie as $tasty ) { 246 246 if ( false !== strpos($tasty, USER_COOKIE) ) 247 247 $user = substr(strstr($tasty, '='), 1); 248 248 if ( false !== strpos($tasty, PASS_COOKIE) ) -
wp-includes/feed.php
131 131 function get_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>"; … … 155 155 while( list( $key, $val ) = each( $custom_fields ) ) { 156 156 if( $key == 'enclosure' ) { 157 157 if (is_array($val)) { 158 foreach( $val as $enc) {158 foreach( (array) $val as $enc) { 159 159 $enclosure = split( "\n", $enc ); 160 160 print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n"; 161 161 } -
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; … … 405 405 { 406 406 $outarray = array (); 407 407 408 foreach ( $inarray as $inkey => $inval) {408 foreach ( (array) $inarray as $inkey => $inval) { 409 409 $outkey = strtolower($inkey); 410 410 $outarray[$outkey] = array (); 411 411 412 foreach ( $inval as $inkey2 => $inval2) {412 foreach ( (array) $inval as $inkey2 => $inval2) { 413 413 $outkey2 = strtolower($inkey2); 414 414 $outarray[$outkey][$outkey2] = $inval2; 415 415 } # foreach $inval … … 460 460 $string2 = strtolower($string2); 461 461 462 462 $allowed = false; 463 foreach ( $allowed_protocols as $one_protocol)463 foreach ( (array) $allowed_protocols as $one_protocol) 464 464 if (strtolower($one_protocol) == $string2) { 465 465 $allowed = true; 466 466 break; -
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/rss.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/functions.php
206 206 } 207 207 $wpdb->show_errors(); 208 208 209 foreach ( $options as $option) {209 foreach ( (array) $options as $option) { 210 210 // "When trying to design a foolproof system, 211 211 // never underestimate the ingenuity of the fools :)" -- Dougal 212 212 if ( 'siteurl' == $option->option_name ) … … 387 387 debug_fwrite($log, 'Post contents:'); 388 388 debug_fwrite($log, $content."\n"); 389 389 390 foreach( $post_links_temp[0] as $link_test) :390 foreach( (array) $post_links_temp[0] as $link_test) : 391 391 if ( !in_array($link_test, $pung) ) : // If we haven't pung it already 392 392 $test = parse_url($link_test); 393 393 if ( isset($test['query']) ) … … 397 397 endif; 398 398 endforeach; 399 399 400 foreach ( $post_links as $url) :400 foreach ( (array) $post_links as $url) : 401 401 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%')") ) { 402 402 if ( $headers = wp_get_http_headers( $url) ) { 403 403 $len = (int) $headers['content-length']; … … 515 515 if ( empty($dogs) ) 516 516 return; 517 517 518 foreach ( $dogs as $catt)518 foreach ( (array) $dogs as $catt) 519 519 $category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id); 520 520 } 521 521 … … 541 541 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) ) { 542 542 // Change from flat structure to hierarchical: 543 543 $post_meta_cache = array(); 544 foreach ( $meta_list as $metarow) {544 foreach ( (array) $meta_list as $metarow) { 545 545 $mpid = $metarow['post_id']; 546 546 $mkey = $metarow['meta_key']; 547 547 $mval = $metarow['meta_value']; … … 623 623 $qs[func_get_arg(0)] = func_get_arg(1); 624 624 } 625 625 626 foreach( $qs as $k => $v) {626 foreach( (array) $qs as $k => $v) { 627 627 if ( $v != '' ) { 628 628 if ( $ret != '' ) 629 629 $ret .= '&'; … … 658 658 function add_magic_quotes($array) { 659 659 global $wpdb; 660 660 661 foreach ( $array as $k => $v) {661 foreach ( (array) $array as $k => $v) { 662 662 if ( is_array($v) ) { 663 663 $array[$k] = add_magic_quotes($v); 664 664 } else { … … 990 990 $type = false; 991 991 $ext = false; 992 992 993 foreach ( $mimes as $ext_preg => $mime_match) {993 foreach ( (array) $mimes as $ext_preg => $mime_match) { 994 994 $ext_preg = '!\.(' . $ext_preg . ')$!i'; 995 995 if ( preg_match($ext_preg, $filename, $ext_matches) ) { 996 996 $type = $mime_match; -
wp-includes/script-loader.php
88 88 if ( ! $handles = (array) $handles ) 89 89 return array(); 90 90 $return = array(); 91 foreach ( $handles as $handle ) {91 foreach ( (array) $handles as $handle ) { 92 92 $handle = explode('?', $handle); 93 93 if ( isset($handle[1]) ) 94 94 $this->args[$handle[0]] = $handle[1]; -
wp-includes/vars.php
86 86 87 87 88 88 // generates smilies' search & replace arrays 89 foreach( $wpsmiliestrans as $smiley => $img) {89 foreach( (array) $wpsmiliestrans as $smiley => $img) { 90 90 $wp_smiliessearch[] = $smiley; 91 91 $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES); 92 92 $wp_smiliesreplace[] = " <img src='" . get_option('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> "; -
wp-includes/user.php
94 94 return ''; 95 95 } 96 96 97 foreach ( $metas as $index => $meta) {97 foreach ( (array) $metas as $index => $meta) { 98 98 @ $value = unserialize($meta->meta_value); 99 99 if ( $value === FALSE ) 100 100 $value = $meta->meta_value; -
wp-includes/category-template.php
7 7 $chain = ''; 8 8 9 9 $cat_ids = get_all_category_ids(); 10 foreach ( $cat_ids as $cat_id ) {10 foreach ( (array) $cat_ids as $cat_id ) { 11 11 if ( $cat_id == $id) 12 12 continue; 13 13 … … 92 92 $thelist = ''; 93 93 if ( '' == $separator ) { 94 94 $thelist .= '<ul class="post-categories">'; 95 foreach ( $categories as $category ) {95 foreach ( (array) $categories as $category ) { 96 96 $thelist .= "\n\t<li>"; 97 97 switch ( strtolower($parents) ) { 98 98 case 'multiple': … … 114 114 $thelist .= '</ul>'; 115 115 } else { 116 116 $i = 0; 117 foreach ( $categories as $category ) {117 foreach ( (array) $categories as $category ) { 118 118 if ( 0 < $i ) 119 119 $thelist .= $separator . ' '; 120 120 switch ( strtolower($parents) ) { -
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_categories($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_categories($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_categories($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_categories(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 ) ) { … … 1276 1276 } 1277 1277 1278 1278 $pingbacks = array(); 1279 foreach( $comments as $comment) {1279 foreach( (array) $comments as $comment) { 1280 1280 if ( 'pingback' == $comment->comment_type ) 1281 1281 $pingbacks[] = $comment->comment_author_url; 1282 1282 } -
wp-mail.php
28 28 $bodysignal = 0; 29 29 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 30 30 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); 31 foreach ( $message as $line) :31 foreach ( (array) $message as $line) : 32 32 if (strlen($line) < 3) $bodysignal = 1; 33 33 34 34 if ($bodysignal) { -
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-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"> … … 39 39 40 40 <?php if ($comments) { ?> 41 41 <ol id="commentlist"> 42 <?php foreach ( $comments as $comment) { ?>42 <?php foreach ( (array) $comments as $comment) { ?> 43 43 <li id="comment-<?php comment_ID() ?>"> 44 44 <?php comment_text() ?> 45 45 <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/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"> … … 39 39 40 40 <?php if ($comments) { ?> 41 41 <ol id="commentlist"> 42 <?php foreach ( $comments as $comment) { ?>42 <?php foreach ( (array) $comments as $comment) { ?> 43 43 <li id="comment-<?php comment_ID() ?>"> 44 44 <?php comment_text() ?> 45 45 <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-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 } … … 190 190 if ( get_option('active_plugins') ) { 191 191 $current_plugins = get_option('active_plugins'); 192 192 if ( is_array($current_plugins) ) { 193 foreach ( $current_plugins as $plugin) {193 foreach ( (array) $current_plugins as $plugin) { 194 194 if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin)) 195 195 include_once(ABSPATH . 'wp-content/plugins/' . $plugin); 196 196 } -
wp-cron.php
10 10 $keys = array_keys($crons); 11 11 if (!is_array($crons) || $keys[0] > time()) 12 12 return; 13 foreach ( $crons as $timestamp => $cronhooks) {13 foreach ( (array) $crons as $timestamp => $cronhooks) { 14 14 if ($timestamp > time()) break; 15 foreach ( $cronhooks as $hook => $keys) {16 foreach ( $keys as $key => $args) {15 foreach ( (array) $cronhooks as $hook => $keys) { 16 foreach ( (array) $keys as $key => $args) { 17 17 do_action_ref_array($hook, $args['args']); 18 18 $schedule = $args['schedule']; 19 19 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/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
132 132 133 133 $userids = $_POST['users']; 134 134 $update = 'promote'; 135 foreach( $userids as $id) {135 foreach( (array) $userids as $id) { 136 136 if ( ! current_user_can('edit_user', $id) ) 137 137 wp_die(__('You can’t edit that user.')); 138 138 // The new role of the current user must also have edit_users caps … … 274 274 $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']); 275 275 276 276 // Make the user objects 277 foreach ( $wp_user_search->get_results() as $userid ) {277 foreach ( (array) $wp_user_search->get_results() as $userid ) { 278 278 $tmp_user = new WP_User($userid); 279 279 $roles = $tmp_user->roles; 280 280 $role = array_shift($roles); … … 319 319 <div class="error"> 320 320 <ul> 321 321 <?php 322 foreach ( $errors->get_error_messages() as $message )322 foreach ( (array) $errors->get_error_messages() as $message ) 323 323 echo "<li>$message</li>"; 324 324 ?> 325 325 </ul> … … 348 348 <div class="error"> 349 349 <ul> 350 350 <?php 351 foreach ( $wp_user_search->search_errors->get_error_messages() as $message )351 foreach ( (array) $wp_user_search->search_errors->get_error_messages() as $message ) 352 352 echo "<li>$message</li>"; 353 353 ?> 354 354 </ul> … … 372 372 <?php wp_nonce_field('bulk-users') ?> 373 373 <table class="widefat"> 374 374 <?php 375 foreach( $roleclasses as $role => $roleclass) {375 foreach( (array) $roleclasses as $role => $roleclass) { 376 376 ksort($roleclass); 377 377 ?> 378 378 … … 491 491 <?php if ( is_wp_error( $add_user_errors ) ) : ?> 492 492 <div class="error"> 493 493 <?php 494 foreach ( $add_user_errors->get_error_messages() as $message )494 foreach ( (array) $add_user_errors->get_error_messages() as $message ) 495 495 echo "<p>$message</p>"; 496 496 ?> 497 497 </div> -
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-comment-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" style="text-align: center">' . __('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
111 111 die('-1'); 112 112 $names = explode(',', $_POST['newcat']); 113 113 $x = new WP_Ajax_Response(); 114 foreach ( $names as $cat_name ) {114 foreach ( (array) $names as $cat_name ) { 115 115 $cat_name = trim($cat_name); 116 116 if ( !$category_nicename = sanitize_title($cat_name) ) 117 117 die('0'); … … 204 204 if ( !$user_id = add_user() ) 205 205 die('0'); 206 206 elseif ( is_wp_error( $user_id ) ) { 207 foreach( $user_id->get_error_messages() as $message )207 foreach( (array) $user_id->get_error_messages() as $message ) 208 208 echo "<p>$message<p>"; 209 209 exit; 210 210 } -
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
84 84 <?php _e('Select theme to edit:') ?> 85 85 <select name="theme" id="theme"> 86 86 <?php 87 foreach ( $themes as $a_theme) {87 foreach ( (array) $themes as $a_theme) { 88 88 $theme_name = $a_theme['Name']; 89 89 if ($theme_name == $theme) $selected = " selected='selected'"; 90 90 else $selected = ''; … … 112 112 if ($allowed_files) : 113 113 ?> 114 114 <ul> 115 <?php foreach( $allowed_files as $allowed_file) : ?>115 <?php foreach( (array) $allowed_files as $allowed_file) : ?> 116 116 <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> 117 117 <?php endforeach; ?> 118 118 </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
93 93 <h3><?php _e('Recent'); ?></h3> 94 94 <?php 95 95 echo '<ol>'; 96 foreach ( $recents as $recent) :96 foreach ( (array) $recents as $recent) : 97 97 echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>"; 98 98 endforeach; 99 99 echo '</ol>'; … … 102 102 <h3><?php _e('Common'); ?></h3> 103 103 <?php $common_files = array('index.php', '.htaccess', 'my-hacks.php'); 104 104 $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php'); 105 foreach ( $old_files as $old_file) {105 foreach ( (array) $old_files as $old_file) { 106 106 if (file_exists(ABSPATH . $old_file)) 107 107 $common_files[] = $old_file; 108 108 } ?> 109 109 <ul> 110 <?php foreach ( $common_files as $common_file) : ?>110 <?php foreach ( (array) $common_files as $common_file) : ?> 111 111 <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li> 112 112 <?php endforeach; ?> 113 113 </ul> -
wp-admin/admin-functions.php
123 123 124 124 $i = 0; 125 125 $search = "# id=(\"|')p(\d+)\\1#i"; 126 foreach ( $anchor_matches[0] as $anchor ) {126 foreach ( (array) $anchor_matches[0] as $anchor ) { 127 127 if ( 0 == preg_match($search, $anchor, $id_matches) ) 128 128 continue; 129 129 … … 233 233 234 234 // Meta Stuff 235 235 if ($_POST['meta']) { 236 foreach ( $_POST['meta'] as $key => $value)236 foreach ( (array) $_POST['meta'] as $key => $value) 237 237 update_meta($key, $value['key'], $value['value']); 238 238 } 239 239 240 240 if ($_POST['deletemeta']) { 241 foreach ( $_POST['deletemeta'] as $key => $value)241 foreach ( (array) $_POST['deletemeta'] as $key => $value) 242 242 delete_meta($key); 243 243 } 244 244 … … 374 374 function wp_dropdown_roles( $default = false ) { 375 375 global $wp_roles; 376 376 $r = ''; 377 foreach( $wp_roles->role_names as $role => $name)377 foreach( (array) $wp_roles->role_names as $role => $name) 378 378 if ( $default == $role ) // Make default first in list 379 379 $p = "\n\t<option selected='selected' value='$role'>$name</option>"; 380 380 else … … 639 639 $result = array (); 640 640 641 641 if (is_array($cats)) { 642 foreach ( $cats as $cat) {642 foreach ( (array) $cats as $cat) { 643 643 $result[$cat]['children'] = get_nested_categories($default, $cat); 644 644 $result[$cat]['cat_ID'] = $cat; 645 645 $result[$cat]['checked'] = in_array($cat, $checked_categories); … … 653 653 } 654 654 655 655 function write_nested_categories($categories) { 656 foreach ( $categories as $category) {656 foreach ( (array) $categories as $category) { 657 657 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"; 658 658 659 659 if ( $category['children'] ) { … … 695 695 $result = array (); 696 696 697 697 if (is_array($cats)) { 698 foreach ( $cats as $cat) {698 foreach ( (array) $cats as $cat) { 699 699 $result[$cat]['children'] = get_nested_link_categories($default, $cat); 700 700 $result[$cat]['cat_ID'] = $cat; 701 701 $result[$cat]['checked'] = in_array($cat, $checked_categories); … … 718 718 $categories = get_categories('hide_empty=0'); 719 719 720 720 if ($categories) { 721 foreach ( $categories as $category) {721 foreach ( (array) $categories as $category) { 722 722 if ($category->category_parent == $parent) { 723 723 echo "\t" . _cat_row( $category, $level ); 724 724 cat_rows($category->cat_ID, $level +1, $categories); … … 767 767 if (! $pages) 768 768 return false; 769 769 770 foreach ( $pages as $post) {770 foreach ( (array) $pages as $post) { 771 771 setup_postdata($post); 772 772 if ( $hierarchy && ($post->post_parent != $parent) ) 773 773 continue; … … 832 832 $categories = get_categories('hide_empty=0'); 833 833 834 834 if ($categories) { 835 foreach ( $categories as $category) {835 foreach ( (array) $categories as $category) { 836 836 if ($currentcat != $category->cat_ID && $parent == $category->category_parent) { 837 837 $pad = str_repeat('– ', $level); 838 838 $category->cat_name = wp_specialchars($category->cat_name); … … 973 973 </thead> 974 974 <?php 975 975 $r ="\n\t<tbody id='the-list'>"; 976 foreach ( $meta as $entry) {976 foreach ( (array) $meta as $entry) { 977 977 ++ $count; 978 978 if ($count % 2) 979 979 $style = 'alternate'; … … 1032 1032 <option value="#NONE#"><?php _e('- Select -'); ?></option> 1033 1033 <?php 1034 1034 1035 foreach ( $keys as $key) {1035 foreach ( (array) $keys as $key) { 1036 1036 $key = wp_specialchars($key, 1); 1037 1037 echo "\n\t<option value='$key'>$key</option>"; 1038 1038 } … … 1159 1159 $foundit = false; 1160 1160 if ($markerdata) { 1161 1161 $state = true; 1162 foreach ( $markerdata as $n => $markerline) {1162 foreach ( (array) $markerdata as $n => $markerline) { 1163 1163 if (strstr($markerline, "# BEGIN {$marker}")) 1164 1164 $state = false; 1165 1165 if ($state) { … … 1171 1171 if (strstr($markerline, "# END {$marker}")) { 1172 1172 fwrite($f, "# BEGIN {$marker}\n"); 1173 1173 if (is_array($insertion)) 1174 foreach ( $insertion as $insertline)1174 foreach ( (array) $insertion as $insertline) 1175 1175 fwrite($f, "{$insertline}\n"); 1176 1176 fwrite($f, "# END {$marker}\n"); 1177 1177 $state = true; … … 1181 1181 } 1182 1182 if (!$foundit) { 1183 1183 fwrite($f, "# BEGIN {$marker}\n"); 1184 foreach ( $insertion as $insertline)1184 foreach ( (array) $insertion as $insertline) 1185 1185 fwrite($f, "{$insertline}\n"); 1186 1186 fwrite($f, "# END {$marker}\n"); 1187 1187 } … … 1205 1205 if ($markerdata = explode("\n", implode('', file($filename)))); 1206 1206 { 1207 1207 $state = false; 1208 foreach ( $markerdata as $markerline) {1208 foreach ( (array) $markerdata as $markerline) { 1209 1209 if (strstr($markerline, "# END {$marker}")) 1210 1210 $state = false; 1211 1211 if ($state) … … 1264 1264 $page_templates = array (); 1265 1265 1266 1266 if (is_array($templates)) { 1267 foreach ( $templates as $template) {1267 foreach ( (array) $templates as $template) { 1268 1268 $template_data = implode('', file(ABSPATH.$template)); 1269 1269 preg_match("|Template Name:(.*)|i", $template_data, $name); 1270 1270 preg_match("|Description:(.*)|i", $template_data, $description); … … 1297 1297 $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"); 1298 1298 1299 1299 if ($items) { 1300 foreach ( $items as $item) {1300 foreach ( (array) $items as $item) { 1301 1301 // A page cannot be it's own parent. 1302 1302 if (!empty ($post_ID)) { 1303 1303 if ($item->ID == $post_ID) { … … 1355 1355 } 1356 1356 1357 1357 if (isset ($submenu[$parent])) { 1358 foreach ( $submenu[$parent] as $submenu_array) {1358 foreach ( (array) $submenu[$parent] as $submenu_array) { 1359 1359 if ($submenu_array[2] == $pagenow) { 1360 1360 if (current_user_can($submenu_array[1])) 1361 1361 return true; … … 1365 1365 } 1366 1366 } 1367 1367 1368 foreach ( $menu as $menu_array) {1368 foreach ( (array) $menu as $menu_array) { 1369 1369 if ($menu_array[2] == $parent) { 1370 1370 if (current_user_can($menu_array[1])) 1371 1371 return true; … … 1392 1392 1393 1393 $parent = $parent1 = get_admin_page_parent(); 1394 1394 if (empty ($parent)) { 1395 foreach ( $menu as $menu_array) {1395 foreach ( (array) $menu as $menu_array) { 1396 1396 if (isset ($menu_array[3])) { 1397 1397 if ($menu_array[2] == $pagenow) { 1398 1398 $title = $menu_array[3]; … … 1406 1406 } 1407 1407 } else { 1408 1408 foreach (array_keys($submenu) as $parent) { 1409 foreach ( $submenu[$parent] as $submenu_array) {1409 foreach ( (array) $submenu[$parent] as $submenu_array) { 1410 1410 if (isset ($submenu_array[3])) { 1411 1411 if ($submenu_array[2] == $pagenow) { 1412 1412 $title = $submenu_array[3]; … … 1442 1442 } 1443 1443 1444 1444 if ($pagenow == 'admin.php' && isset ($plugin_page)) { 1445 foreach ( $menu as $parent_menu) {1445 foreach ( (array) $menu as $parent_menu) { 1446 1446 if ($parent_menu[2] == $plugin_page) { 1447 1447 $parent_file = $plugin_page; 1448 1448 if ( isset($_wp_real_parent_file[$parent_file]) ) … … 1466 1466 } 1467 1467 1468 1468 foreach (array_keys($submenu) as $parent) { 1469 foreach ( $submenu[$parent] as $submenu_array) {1469 foreach ( (array) $submenu[$parent] as $submenu_array) { 1470 1470 if ( isset($_wp_real_parent_file[$parent]) ) 1471 1471 $parent = $_wp_real_parent_file[$parent]; 1472 1472 if ($submenu_array[2] == $pagenow) { … … 1523 1523 // parent file someone is trying to link back to the parent manually. In 1524 1524 // this case, don't automatically add a link back to avoid duplication. 1525 1525 if (!isset ($submenu[$parent]) && $file != $parent ) { 1526 foreach ( $menu as $parent_menu) {1526 foreach ( (array) $menu as $parent_menu) { 1527 1527 if ( $parent_menu[2] == $parent && current_user_can($parent_menu[1]) ) { 1528 1528 $submenu[$parent][] = $parent_menu; 1529 1529 } … … 1711 1711 1712 1712 sort($plugin_files); 1713 1713 1714 foreach ( $plugin_files as $plugin_file) {1714 foreach ( (array) $plugin_files as $plugin_file) { 1715 1715 if ( !is_readable("$plugin_root/$plugin_file")) 1716 1716 continue; 1717 1717 -
wp-admin/edit-page-form.php
105 105 <div class="dbx-content"> 106 106 <select name="post_author_override" id="post_author_override"> 107 107 <?php 108 foreach ( $authors as $o) :108 foreach ( (array) $authors as $o) : 109 109 $o = get_userdata( $o->ID ); 110 110 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"'; 111 111 else $selected = ''; -
wp-admin/moderation.php
9 9 10 10 $comment = array(); 11 11 if (isset($_POST["comment"])) { 12 foreach ( $_POST["comment"] as $k => $v) {12 foreach ( (array) $_POST["comment"] as $k => $v) { 13 13 $comment[intval($k)] = $v; 14 14 } 15 15 } … … 28 28 $item_approved = 0; 29 29 $item_spam = 0; 30 30 31 foreach( $comment as $key => $value) {31 foreach( (array) $comment as $key => $value) { 32 32 if ($feelinglucky && 'later' == $value) 33 33 $value = 'delete'; 34 34 switch($value) { … … 123 123 <ol id="the-comment-list" class="commentlist"> 124 124 <?php 125 125 $i = 0; 126 foreach( $comments as $comment) {126 foreach( (array) $comments as $comment) { 127 127 ++$i; 128 128 $comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date); 129 129 $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'"); -
wp-admin/index.php
24 24 <ul> 25 25 <?php 26 26 $rss->items = array_slice($rss->items, 0, 10); 27 foreach ( $rss->items as $item ) {27 foreach ( (array) $rss->items as $item ) { 28 28 ?> 29 29 <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wp_specialchars($item['title']); ?></a></li> 30 30 <?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>"; … … 135 135 <h3><?php _e('WordPress Development News'); ?></h3> 136 136 <?php 137 137 $rss->items = array_slice($rss->items, 0, 3); 138 foreach ( $rss->items as $item ) {138 foreach ( (array) $rss->items as $item ) { 139 139 ?> 140 140 <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> 141 141 <p><?php echo $item['description']; ?></p> … … 154 154 <ul> 155 155 <?php 156 156 $rss->items = array_slice($rss->items, 0, 20); 157 foreach ( $rss->items as $item ) {157 foreach ( (array) $rss->items as $item ) { 158 158 ?> 159 159 <li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li> 160 160 <?php -
wp-admin/admin-db.php
189 189 // Only set posts and links to the default category if they're not in another category already. 190 190 $default_cat = get_option('default_category'); 191 191 $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'"); 192 if ( is_array($posts) ) foreach ( $posts as $post_id) {192 if ( is_array($posts) ) foreach ( (array) $posts as $post_id) { 193 193 $cats = wp_get_post_categories($post_id); 194 194 if ( 1 == count($cats) ) 195 195 $cats = array($default_cat); … … 200 200 201 201 $default_link_cat = get_option('default_link_category'); 202 202 $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'"); 203 if ( is_array($links) ) foreach ( $links as $link_id) {203 if ( is_array($links) ) foreach ( (array) $links as $link_id) { 204 204 $cats = wp_get_link_cats($link_id); 205 205 if ( 1 == count($cats) ) 206 206 $cats = array($default_link_cat); … … 224 224 225 225 function wp_create_categories($categories, $post_id = '') { 226 226 $cat_ids = array (); 227 foreach ( $categories as $category) {227 foreach ( (array) $categories as $category) { 228 228 if ($id = category_exists($category)) 229 229 $cat_ids[] = $id; 230 230 else … … 256 256 $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); 257 257 258 258 if ($post_ids) { 259 foreach ( $post_ids as $post_id)259 foreach ( (array) $post_ids as $post_id) 260 260 wp_delete_post($post_id); 261 261 } 262 262 … … 402 402 403 403 $categories = wp_get_link_cats($link_id); 404 404 if( is_array( $categories ) ) { 405 foreach ( $categories as $category ) {405 foreach ( (array) $categories as $category ) { 406 406 $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'"); 407 407 wp_cache_delete($category, 'category'); 408 408 } … … 452 452 $delete_cats = array_diff($old_categories,$link_categories); 453 453 454 454 if ($delete_cats) { 455 foreach ( $delete_cats as $del) {455 foreach ( (array) $delete_cats as $del) { 456 456 $wpdb->query(" 457 457 DELETE FROM $wpdb->link2cat 458 458 WHERE category_id = $del … … 465 465 $add_cats = array_diff($link_categories, $old_categories); 466 466 467 467 if ($add_cats) { 468 foreach ( $add_cats as $new_cat) {468 foreach ( (array) $add_cats as $new_cat) { 469 469 $wpdb->query(" 470 470 INSERT INTO $wpdb->link2cat (link_id, category_id) 471 471 VALUES ($link_ID, $new_cat)"); … … 474 474 475 475 // Update category counts. 476 476 $all_affected_cats = array_unique(array_merge($link_categories, $old_categories)); 477 foreach ( $all_affected_cats as $cat_id ) {477 foreach ( (array) $all_affected_cats as $cat_id ) { 478 478 $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'"); 479 479 $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'"); 480 480 wp_cache_delete($cat_id, 'category'); -
wp-admin/upload.php
43 43 exit; 44 44 } 45 45 46 foreach ( $wp_upload_tabs as $t => $tab_array ) {46 foreach ( (array) $wp_upload_tabs as $t => $tab_array ) { 47 47 if ( !current_user_can( $tab_array[1] ) ) { 48 48 unset($wp_upload_tabs[$t]); 49 49 if ( $tab == $t ) … … 54 54 include_once('admin-header.php'); 55 55 56 56 echo "<ul id='upload-menu'>\n"; 57 foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check57 foreach ( (array) $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check 58 58 $class = 'upload-tab'; 59 59 $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') ); 60 60 if ( isset($tab_array[4]) && is_array($tab_array[4]) ) -
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 />'.sprintf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br />'); 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 wp_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 wp_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/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/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/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 = str_replace(array('<![CDATA[', ']]>'), '', $wpdb->escape( trim($post_title[1]) )); 42 42 … … 64 64 } 65 65 66 66 $cat_index = 0; 67 foreach ( $categories as $category) {67 foreach ( (array) $categories as $category) { 68 68 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category)); 69 69 $cat_index++; 70 70 } … … 99 99 function import_posts() { 100 100 echo '<ol>'; 101 101 102 foreach ( $this->posts as $post) {102 foreach ( (array) $this->posts as $post) { 103 103 echo "<li>".__('Importing post...'); 104 104 105 105 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 />'.sprintf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br />'); 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>" . wp_specialchars($pinged_url) . "</li>"; 43 43 } 44 44 $pings .= '</ul>'; … … 124 124 <div class="dbx-content"> 125 125 <select name="post_author_override" id="post_author_override"> 126 126 <?php 127 foreach ( $authors as $o) :127 foreach ( (array) $authors as $o) : 128 128 $o = get_userdata( $o->ID ); 129 129 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"'; 130 130 else $selected = ''; -
wp-admin/menu.php
66 66 $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php'); 67 67 68 68 // Create list of page plugin hook names. 69 foreach ( $menu as $menu_page) {69 foreach ( (array) $menu as $menu_page) { 70 70 $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]); 71 71 } 72 72 73 73 $_wp_submenu_nopriv = array(); 74 74 $_wp_menu_nopriv = array(); 75 75 // Loop over submenus and remove pages for which the user does not have privs. 76 foreach ( $submenu as $parent => $sub) {77 foreach ( $sub as $index => $data) {76 foreach ( (array) $submenu as $parent => $sub) { 77 foreach ( (array) $sub as $index => $data) { 78 78 if ( ! current_user_can($data[1]) ) { 79 79 unset($submenu[$parent][$index]); 80 80 $_wp_submenu_nopriv[$parent][$data[2]] = true; … … 88 88 // Loop over the top-level menu. 89 89 // Menus for which the original parent is not acessible due to lack of privs will have the next 90 90 // submenu in line be assigned as the new menu parent. 91 foreach ( $menu as $id => $data ) {91 foreach ( (array) $menu as $id => $data ) { 92 92 if ( empty($submenu[$data[2]]) ) 93 93 continue; 94 94 $subs = $submenu[$data[2]]; … … 101 101 $_wp_real_parent_file[$old_parent] = $new_parent; 102 102 $menu[$id][2] = $new_parent; 103 103 104 foreach ( $submenu[$old_parent] as $index => $data) {104 foreach ( (array) $submenu[$old_parent] as $index => $data) { 105 105 $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; 106 106 unset($submenu[$old_parent][$index]); 107 107 } … … 114 114 115 115 // Remove menus that have no accessible submenus and require privs that the user does not have. 116 116 // Run re-parent loop again. 117 foreach ( $menu as $id => $data ) {117 foreach ( (array) $menu as $id => $data ) { 118 118 // If submenu is empty... 119 119 if ( empty($submenu[$data[2]]) ) { 120 120 // And user doesn't have privs, remove menu. -
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 . PLUGINDIR . '/' . $check_plugin)) { 46 46 $current = get_option('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); … … 145 145 <thead> 146 146 <tr> 147 147 148 <?php foreach( $posts_columns as $column_display_name) { ?>148 <?php foreach( (array) $posts_columns as $column_display_name) { ?> 149 149 <th scope="col"><?php echo $column_display_name; ?></th> 150 150 <?php } ?> 151 151 … … 155 155 <?php 156 156 if ($posts) { 157 157 $bgcolor = ''; 158 foreach ( $posts as $post) { start_wp();158 foreach ( (array) $posts as $post) { start_wp(); 159 159 add_filter('the_title','wp_specialchars'); 160 160 $class = ('alternate' == $class) ? '' : 'alternate'; 161 161 ?> … … 163 163 164 164 <?php 165 165 166 foreach( $posts_columns as $column_name=>$column_display_name) {166 foreach( (array) $posts_columns as $column_name=>$column_display_name) { 167 167 168 168 switch($column_name) { 169 169 … … 262 262 <ol id="the-comment-list" class="commentlist"> 263 263 <?php 264 264 $i = 0; 265 foreach ( $comments as $comment) {265 foreach ( (array) $comments as $comment) { 266 266 267 267 ++$i; $class = ''; 268 268 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); -
wp-admin/options.php
79 79 check_admin_referer('update-options'); 80 80 81 81 if (!$_POST['page_options']) { 82 foreach ( $_POST as $key => $value) {82 foreach ( (array) $_POST as $key => $value) { 83 83 $options[] = $key; 84 84 } 85 85 } else { … … 87 87 } 88 88 89 89 if ($options) { 90 foreach ( $options as $option) {90 foreach ( (array) $options as $option) { 91 91 $option = trim($option); 92 92 $value = trim(stripslashes($_POST[$option])); 93 93 $value = sanitize_option($option, $value); … … 113 113 <?php 114 114 $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name"); 115 115 116 foreach ( $options as $option) :116 foreach ( (array) $options as $option) : 117 117 $value = wp_specialchars($option->option_value, 'single'); 118 118 echo " 119 119 <tr> -
wp-admin/link.php
27 27 } 28 28 29 29 $deleted = 0; 30 foreach ( $linkcheck as $link_id) {30 foreach ( (array) $linkcheck as $link_id) { 31 31 $link_id = (int) $link_id; 32 32 33 33 if ( wp_delete_link($link_id) ) -
wp-admin/profile.php
125 125 <th scope="row"><?php _e('Additional Capabilities:') ?></th> 126 126 <td><?php 127 127 $output = ''; 128 foreach( $profileuser->caps as $cap => $value) {128 foreach( (array) $profileuser->caps as $cap => $value) { 129 129 if(!$wp_roles->is_role($cap)) { 130 130 if($output != '') $output .= ', '; 131 131 $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> … … 95 95 echo '<select name="role">'; 96 96 $role_list = ''; 97 97 $user_has_role = false; 98 foreach( $wp_roles->role_names as $role => $name) {98 foreach( (array) $wp_roles->role_names as $role => $name) { 99 99 if ( $profileuser->has_cap($role) ) { 100 100 $selected = ' selected="selected"'; 101 101 $user_has_role = true; … … 194 194 <th scope="row"><?php _e('Additional Capabilities:') ?></th> 195 195 <td><?php 196 196 $output = ''; 197 foreach( $profileuser->caps as $cap => $value) {197 foreach( (array) $profileuser->caps as $cap => $value) { 198 198 if(!$wp_roles->is_role($cap)) { 199 199 if($output != '') $output .= ', '; 200 200 $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
119 119 $cat_id = ''; 120 120 $links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0"); 121 121 if ($links) 122 foreach ( $links as $link) {122 foreach ( (array) $links as $link) { 123 123 $link->link_name = wp_specialchars($link->link_name); 124 124 $link->link_description = wp_specialchars($link->link_description); 125 125 $link->link_url = wp_specialchars($link->link_url); … … 147 147 <?php 148 148 149 149 $cat_names = array(); 150 foreach ( $link->link_category as $category) {150 foreach ( (array) $link->link_category as $category) { 151 151 $cat_name = get_the_category_by_ID($category); 152 152 $cat_name = wp_specialchars($cat_name); 153 153 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='".wptexturize(strip_tags($data[1]))."'>{$data[0]}</a>"; 40 40 -
wp-admin/options-writing.php
35 35 <td><select name="default_category" id="default_category"> 36 36 <?php 37 37 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name"); 38 foreach ( $categories as $category) :38 foreach ( (array) $categories as $category) : 39 39 if ($category->cat_ID == get_option('default_category')) $selected = " selected='selected'"; 40 40 else $selected = ''; 41 41 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; … … 47 47 <th scope="row"><?php _e('Default bookmark category:') ?></th> 48 48 <td><select name="default_link_category" id="default_link_category"> 49 49 <?php 50 foreach ( $categories as $category) :50 foreach ( (array) $categories as $category) : 51 51 if ($category->cat_ID == get_option('default_link_category')) $selected = " selected='selected'"; 52 52 else $selected = ''; 53 53 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; … … 84 84 <td><select name="default_email_category" id="default_email_category"> 85 85 <?php 86 86 //Alreay have $categories from default_category 87 foreach ( $categories as $category) :87 foreach ( (array) $categories as $category) : 88 88 if ($category->cat_ID == get_option('default_email_category')) $selected = " selected='selected'"; 89 89 else $selected = ''; 90 90 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
76 76 if ($plugin_files) : 77 77 ?> 78 78 <ul> 79 <?php foreach( $plugin_files as $plugin_file) : ?>79 <?php foreach( (array) $plugin_files as $plugin_file) : ?> 80 80 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li> 81 81 <?php endforeach; ?> 82 82 </ul> -
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 -
wp-admin/upgrade-schema.php
234 234 235 235 // Delete unused options 236 236 $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog'); 237 foreach ( $unusedoptions as $option) :237 foreach ( (array) $unusedoptions as $option) : 238 238 delete_option($option); 239 239 endforeach; 240 240 241 241 // Set up a few options not to load by default 242 242 $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); 243 foreach ( $fatoptions as $fatoption) :243 foreach ( (array) $fatoptions as $fatoption) : 244 244 $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'"); 245 245 endforeach; 246 246 } … … 341 341 342 342 function populate_roles_210() { 343 343 $roles = array('administrator', 'editor'); 344 foreach ( $roles as $role) {344 foreach ( (array) $roles as $role) { 345 345 $role = get_role($role); 346 346 if ( empty($role) ) 347 347 continue;