Ticket #2784: 2784.diff
| File 2784.diff, 39.4 KB (added by , 18 years ago) |
|---|
-
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; -
category-template.php
7 7 $chain = ''; 8 8 // TODO: consult hierarchy 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 … … 84 84 else 85 85 $categories = array(); 86 86 87 foreach( array_keys($categories) as $key) {87 foreach( (array) array_keys($categories) as $key) { 88 88 _make_cat_compat($categories[$key]); 89 89 } 90 90 -
category.php
43 43 $taxonomy = 'category'; 44 44 if ( 'link' == $args['type'] ) 45 45 $taxonomy = 'link_category'; 46 $categories = get_terms($taxonomy, $args);46 $categories = (array) get_terms($taxonomy, $args); 47 47 48 48 foreach ( array_keys($categories) as $k ) 49 49 _make_cat_compat($categories[$k]); -
classes.php
90 90 91 91 // Look for matches. 92 92 $request_match = $request; 93 foreach ( $rewrite as $match => $query) {93 foreach ( (array) $rewrite as $match => $query) { 94 94 // Don't try to match against AtomPub calls 95 95 if ( $req_uri == 'wp-app.php' ) 96 96 break; … … 171 171 } 172 172 } 173 173 174 foreach ( $this->private_query_vars as $var) {174 foreach ( (array) $this->private_query_vars as $var) { 175 175 if (isset($this->extra_query_vars[$var])) 176 176 $this->query_vars[$var] = $this->extra_query_vars[$var]; 177 177 elseif (isset($GLOBALS[$var]) && '' != $GLOBALS[$var]) … … 242 242 243 243 function build_query_string() { 244 244 $this->query_string = ''; 245 foreach ( array_keys($this->query_vars) as $wpvar) {245 foreach ( (array) array_keys($this->query_vars) as $wpvar) { 246 246 if ( '' != $this->query_vars[$wpvar] ) { 247 247 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; 248 248 if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars. … … 261 261 function register_globals() { 262 262 global $wp_query; 263 263 // Extract updated query vars back into global namespace. 264 foreach ( $wp_query->query_vars as $key => $value) {264 foreach ( (array) $wp_query->query_vars as $key => $value) { 265 265 $GLOBALS[$key] = $value; 266 266 } 267 267 … … 350 350 // Return all messages if no code specified. 351 351 if ( empty($code) ) { 352 352 $all_messages = array(); 353 foreach ( $this->errors as $code => $messages )353 foreach ( (array) $this->errors as $code => $messages ) 354 354 $all_messages = array_merge($all_messages, $messages); 355 355 356 356 return $all_messages; … … 534 534 * if we are displaying all levels, and remaining children_elements is not empty, 535 535 * then we got orphans, which should be displayed regardless 536 536 */ 537 if ( ( $max_depth == 0 ) && sizeof( $children_elements ) > 0 ) {537 if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) { 538 538 $empty_array = array(); 539 539 foreach ( $children_elements as $orphan_e ) 540 540 $this->display_element( $orphan_e, $empty_array, 1, 0, $args, $output ); … … 755 755 756 756 $response = ''; 757 757 if ( is_wp_error($data) ) { 758 foreach ( $data->get_error_codes() as $code ) {758 foreach ( (array) $data->get_error_codes() as $code ) { 759 759 $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>"; 760 760 if ( !$error_data = $data->get_error_data($code) ) 761 761 continue; … … 781 781 } 782 782 783 783 $s = ''; 784 if ( (array) $supplemental) {784 if ( is_array($supplemental) ) { 785 785 foreach ( $supplemental as $k => $v ) 786 786 $s .= "<$k><![CDATA[$v]]></$k>"; 787 787 $s = "<supplemental>$s</supplemental>"; … … 805 805 function send() { 806 806 header('Content-Type: text/xml'); 807 807 echo "<?xml version='1.0' standalone='yes'?><wp_ajax>"; 808 foreach ( $this->responses as $response )808 foreach ( (array) $this->responses as $response ) 809 809 echo $response; 810 810 echo '</wp_ajax>'; 811 811 die(); -
comment-template.php
107 107 */ 108 108 function get_comment_author_link() { 109 109 /** @todo Only call these functions when they are needed. Include in if... else blocks */ 110 $url = get_comment_author_url();110 $url = get_comment_author_url(); 111 111 $author = get_comment_author(); 112 112 113 113 if ( empty( $url ) || 'http://' == $url ) … … 769 769 echo '</a>'; 770 770 } 771 771 772 ?> 773 No newline at end of file 772 ?> -
comment.php
51 51 if ( !empty($mod_keys) ) { 52 52 $words = explode("\n", $mod_keys ); 53 53 54 foreach ( $words as $word) {54 foreach ( (array) $words as $word) { 55 55 $word = trim($word); 56 56 57 57 // Skip empty lines … … 1190 1190 // http://dummy-weblog.org/post.php 1191 1191 // We don't wanna ping first and second types, even if they have a valid <link/> 1192 1192 1193 foreach ( $post_links_temp[0] as $link_test ) :1193 foreach ( (array) $post_links_temp[0] as $link_test ) : 1194 1194 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 1195 1195 && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. 1196 1196 $test = parse_url($link_test); -
cron.php
121 121 $schedules = wp_get_schedules(); 122 122 foreach ( $crons as $timestamp => $cronhooks ) { 123 123 if ( $timestamp > time() ) break; 124 foreach ( $cronhooks as $hook => $args ) {124 foreach ( (array) $cronhooks as $hook => $args ) { 125 125 if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) ) 126 126 continue; 127 127 spawn_cron(); … … 178 178 179 179 $new_cron = array(); 180 180 181 foreach ( $cron as $timestamp => $hooks) {182 foreach ( $hooks as $hook => $args ) {181 foreach ( (array) $cron as $timestamp => $hooks) { 182 foreach ( (array) $hooks as $hook => $args ) { 183 183 $key = md5(serialize($args['args'])); 184 184 $new_cron[$timestamp][$hook][$key] = $args; 185 185 } -
feed.php
398 398 if ( !empty($post->post_password) && (!isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) 399 399 return; 400 400 401 foreach ( get_post_custom() as $key => $val) {401 foreach ( (array) get_post_custom() as $key => $val) { 402 402 if ($key == 'enclosure') { 403 foreach ( (array)$val as $enc) {403 foreach ( (array) $val as $enc ) { 404 404 $enclosure = split("\n", $enc); 405 405 echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n"); 406 406 } … … 430 430 if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) 431 431 return; 432 432 433 foreach ( get_post_custom() as $key => $val) {433 foreach ( (array) get_post_custom() as $key => $val ) { 434 434 if ($key == 'enclosure') { 435 foreach ( (array)$val as $enc) {435 foreach ( (array) $val as $enc ) { 436 436 $enclosure = split("\n", $enc); 437 437 echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n"); 438 438 } -
formatting.php
708 708 709 709 function convert_smilies($text) { 710 710 global $wp_smiliessearch, $wp_smiliesreplace; 711 $output = '';711 $output = ''; 712 712 if ( get_option('use_smilies') && !empty($wp_smiliessearch) && !empty($wp_smiliesreplace) ) { 713 713 // HTML loop taken from texturize function, could possible be consolidated 714 714 $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between -
functions.php
421 421 $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); 422 422 $wpdb->show_errors($show); 423 423 424 foreach ( $options as $option ) {424 foreach ( (array) $options as $option ) { 425 425 // "When trying to design a foolproof system, 426 426 // never underestimate the ingenuity of the fools :)" -- Dougal 427 427 if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) ) … … 777 777 debug_fwrite( $log, 'Post contents:' ); 778 778 debug_fwrite( $log, $content . "\n" ); 779 779 780 foreach ( $post_links_temp[0] as $link_test ) {780 foreach ( (array) $post_links_temp[0] as $link_test ) { 781 781 if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already 782 782 $test = parse_url( $link_test ); 783 783 if ( isset( $test['query'] ) ) … … 787 787 } 788 788 } 789 789 790 foreach ( $post_links as $url ) {790 foreach ( (array) $post_links as $url ) { 791 791 if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) { 792 792 if ( $headers = wp_get_http_headers( $url) ) { 793 793 $len = (int) $headers['content-length']; … … 1007 1007 $qs[func_get_arg( 0 )] = func_get_arg( 1 ); 1008 1008 } 1009 1009 1010 foreach ( $qs as $k => $v ) {1010 foreach ( (array) $qs as $k => $v ) { 1011 1011 if ( $v === false ) 1012 1012 unset( $qs[$k] ); 1013 1013 } … … 1031 1031 */ 1032 1032 function remove_query_arg( $key, $query=false ) { 1033 1033 if ( is_array( $key ) ) { // removing multiple keys 1034 foreach ( (array)$key as $k )1034 foreach ( $key as $k ) 1035 1035 $query = add_query_arg( $k, false, $query ); 1036 1036 return $query; 1037 1037 } … … 1049 1049 function add_magic_quotes( $array ) { 1050 1050 global $wpdb; 1051 1051 1052 foreach ( $array as $k => $v ) {1052 foreach ( (array) $array as $k => $v ) { 1053 1053 if ( is_array( $v ) ) { 1054 1054 $array[$k] = add_magic_quotes( $v ); 1055 1055 } else { … … 2329 2329 return $url; 2330 2330 } 2331 2331 2332 ?> 2333 No newline at end of file 2332 ?> -
general-template.php
426 426 } 427 427 if ( $arcresults ) { 428 428 $afterafter = $after; 429 foreach ( $arcresults as $arcresult ) {429 foreach ( (array) $arcresults as $arcresult ) { 430 430 $url = get_month_link($arcresult->year, $arcresult->month); 431 431 $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year); 432 432 if ( $show_post_count ) … … 447 447 } 448 448 if ($arcresults) { 449 449 $afterafter = $after; 450 foreach ( $arcresults as $arcresult) {450 foreach ( (array) $arcresults as $arcresult) { 451 451 $url = get_year_link($arcresult->year); 452 452 $text = sprintf('%d', $arcresult->year); 453 453 if ($show_post_count) … … 468 468 } 469 469 if ( $arcresults ) { 470 470 $afterafter = $after; 471 foreach ( $arcresults as $arcresult ) {471 foreach ( (array) $arcresults as $arcresult ) { 472 472 $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); 473 473 $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth); 474 474 $text = mysql2date($archive_day_date_format, $date); … … 492 492 $arc_w_last = ''; 493 493 $afterafter = $after; 494 494 if ( $arcresults ) { 495 foreach ( $arcresults as $arcresult ) {495 foreach ( (array) $arcresults as $arcresult ) { 496 496 if ( $arcresult->week != $arc_w_last ) { 497 497 $arc_year = $arcresult->yr; 498 498 $arc_w_last = $arcresult->week; … … 520 520 $arcresults = $cache[ $key ]; 521 521 } 522 522 if ( $arcresults ) { 523 foreach ( $arcresults as $arcresult ) {523 foreach ( (array) $arcresults as $arcresult ) { 524 524 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { 525 525 $url = get_permalink($arcresult); 526 526 $arc_title = $arcresult->post_title; … … 660 660 AND post_type = 'post' AND post_status = 'publish' 661 661 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); 662 662 if ( $dayswithposts ) { 663 foreach ( $dayswithposts as $daywith ) {663 foreach ( (array) $dayswithposts as $daywith ) { 664 664 $daywithpost[] = $daywith[0]; 665 665 } 666 666 } else { … … 681 681 ."AND post_type = 'post' AND post_status = 'publish'" 682 682 ); 683 683 if ( $ak_post_titles ) { 684 foreach ( $ak_post_titles as $ak_post_title ) {684 foreach ( (array) $ak_post_titles as $ak_post_title ) { 685 685 686 686 $post_title = apply_filters( "the_title", $ak_post_title->post_title ); 687 687 $post_title = str_replace('"', '"', wptexturize( $post_title )); … … 748 748 function allowed_tags() { 749 749 global $allowedtags; 750 750 $allowed = ''; 751 foreach ( $allowedtags as $tag => $attributes ) {751 foreach ( (array) $allowedtags as $tag => $attributes ) { 752 752 $allowed .= '<'.$tag; 753 753 if ( 0 < count($attributes) ) { 754 754 foreach ( $attributes as $attribute => $limits ) { … … 1058 1058 extract($args, EXTR_SKIP); 1059 1059 1060 1060 // Who knows what else people pass in $args 1061 $total = (int) $total;1061 $total = (int) $total; 1062 1062 if ( $total < 2 ) 1063 1063 return; 1064 1064 $current = (int) $current; -
kses.php
793 793 function wp_kses_array_lc($inarray) { 794 794 $outarray = array (); 795 795 796 foreach ( $inarray as $inkey => $inval) {796 foreach ( (array) $inarray as $inkey => $inval) { 797 797 $outkey = strtolower($inkey); 798 798 $outarray[$outkey] = array (); 799 799 800 foreach ( $inval as $inkey2 => $inval2) {800 foreach ( (array) $inval as $inkey2 => $inval2) { 801 801 $outkey2 = strtolower($inkey2); 802 802 $outarray[$outkey][$outkey2] = $inval2; 803 803 } # foreach $inval -
locale.php
190 190 $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans; 191 191 192 192 // Import global locale vars set during inclusion of $locale.php. 193 foreach ( $this->locale_vars as $var ) {193 foreach ( (array) $this->locale_vars as $var ) { 194 194 if ( isset($GLOBALS[$var]) ) 195 195 $this->$var = $GLOBALS[$var]; 196 196 } -
pluggable.php
789 789 $found = true; 790 790 while($found) { 791 791 $found = false; 792 foreach( $strip as $val) {792 foreach( (array) $strip as $val) { 793 793 while(strpos($location, $val) !== false) { 794 794 $found = true; 795 795 $location = str_replace($val, '', $location); … … 1562 1562 } 1563 1563 endif; 1564 1564 1565 ?> 1566 No newline at end of file 1565 ?> -
plugin.php
90 90 if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) ) 91 91 return false; 92 92 93 foreach ( array_keys($wp_filter[$tag]) as $priority ) {93 foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) { 94 94 if ( isset($wp_filter[$tag][$priority][$idx]) ) 95 95 return $priority; 96 96 } -
post-template.php
252 252 function the_meta() { 253 253 if ( $keys = get_post_custom_keys() ) { 254 254 echo "<ul class='post-meta'>\n"; 255 foreach ( $keys as $key ) {255 foreach ( (array) $keys as $key ) { 256 256 $keyt = trim($key); 257 257 if ( '_' == $keyt{0} ) 258 258 continue; -
post.php
143 143 if ( $output == OBJECT ) { 144 144 return $kids; 145 145 } elseif ( $output == ARRAY_A ) { 146 foreach ( $kids as $kid )146 foreach ( (array) $kids as $kid ) 147 147 $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]); 148 148 return $weeuns; 149 149 } elseif ( $output == ARRAY_N ) { 150 foreach ( $kids as $kid )150 foreach ( (array) $kids as $kid ) 151 151 $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID])); 152 152 return $babes; 153 153 } else { … … 1497 1497 wp_transition_post_status('publish', $old_status, $post); 1498 1498 1499 1499 // Update counts for the post's terms. 1500 foreach ( get_object_taxonomies('post') as $taxonomy ) {1500 foreach ( (array) get_object_taxonomies('post') as $taxonomy ) { 1501 1501 $terms = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids'); 1502 1502 wp_update_term_count($terms, $taxonomy); 1503 1503 } … … 1763 1763 } 1764 1764 1765 1765 $trackback_urls = explode(',', $tb_list); 1766 foreach( $trackback_urls as $tb_url) {1766 foreach( (array) $trackback_urls as $tb_url) { 1767 1767 $tb_url = trim($tb_url); 1768 1768 trackback($tb_url, stripslashes($post_title), $excerpt, $post_id); 1769 1769 } … … 1844 1844 $page_paths = '/' . trim($page_path, '/'); 1845 1845 $leaf_path = sanitize_title(basename($page_paths)); 1846 1846 $page_paths = explode('/', $page_paths); 1847 foreach( $page_paths as $pathdir)1847 foreach( (array) $page_paths as $pathdir) 1848 1848 $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 1849 1849 1850 1850 $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = 'page' OR post_type = 'attachment')", $leaf_path )); … … 1905 1905 */ 1906 1906 function &get_page_children($page_id, $pages) { 1907 1907 $page_list = array(); 1908 foreach ( $pages as $page ) {1908 foreach ( (array) $pages as $page ) { 1909 1909 if ( $page->post_parent == $page_id ) { 1910 1910 $page_list[] = $page; 1911 1911 if ( $children = get_page_children($page->ID, $pages) ) … … 1931 1931 */ 1932 1932 function get_page_hierarchy($posts, $parent = 0) { 1933 1933 $result = array ( ); 1934 if ($posts) { foreach ( $posts as $post) {1934 if ($posts) { foreach ( (array) $posts as $post) { 1935 1935 if ($post->post_parent == $parent) { 1936 1936 $result[$post->ID] = $post->post_name; 1937 1937 $children = get_page_hierarchy($posts, $post->ID); … … 2946 2946 $cache[$id] = array(); 2947 2947 } 2948 2948 2949 foreach ( array_keys($cache) as $post)2949 foreach ( (array) array_keys($cache) as $post) 2950 2950 wp_cache_set($post, $cache[$post], 'post_meta'); 2951 2951 2952 2952 return $cache; -
query.php
214 214 215 215 $page = (array) $page; 216 216 217 if ( in_array( $page_obj->ID, $page ) )217 if ( in_array( $page_obj->ID, $page ) ) 218 218 return true; 219 219 elseif ( in_array( $page_obj->post_title, $page ) ) 220 220 return true; … … 987 987 } 988 988 $n = ($q['exact']) ? '' : '%'; 989 989 $searchand = ''; 990 foreach( (array)$q['search_terms'] as $term) {990 foreach( (array) $q['search_terms'] as $term) { 991 991 $term = addslashes_gpc($term); 992 992 $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))"; 993 993 $searchand = ' AND '; … … 1012 1012 $cat_array = preg_split('/[,\s]+/', $q['cat']); 1013 1013 $q['cat'] = ''; 1014 1014 $req_cats = array(); 1015 foreach ( $cat_array as $cat ) {1015 foreach ( (array) $cat_array as $cat ) { 1016 1016 $cat = intval($cat); 1017 1017 $req_cats[] = $cat; 1018 1018 $in = ($cat > 0); -
rewrite.php
157 157 global $wp; 158 158 parse_str($query, $query_vars); 159 159 $query = array(); 160 foreach ( $query_vars as $key => $value ) {160 foreach ( (array) $query_vars as $key => $value ) { 161 161 if ( in_array($key, $wp->public_query_vars) ) 162 162 $query[$key] = $value; 163 163 } … … 390 390 $front = $this->front; 391 391 preg_match_all('/%.+?%/', $this->permalink_structure, $tokens); 392 392 $tok_index = 1; 393 foreach ( $tokens[0] as $token) {393 foreach ( (array) $tokens[0] as $token) { 394 394 if ( ($token == '%post_id%') && ($tok_index <= 3) ) { 395 395 $front = $front . 'date/'; 396 396 break; … … 574 574 function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) { 575 575 //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/? 576 576 $feedregex2 = ''; 577 foreach ( $this->feeds as $feed_name) {577 foreach ( (array) $this->feeds as $feed_name) { 578 578 $feedregex2 .= $feed_name . '|'; 579 579 } 580 580 $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$'; … … 589 589 //build up an array of endpoint regexes to append => queries to append 590 590 if ($endpoints) { 591 591 $ep_query_append = array (); 592 foreach ( $this->endpoints as $endpoint) {592 foreach ( (array) $this->endpoints as $endpoint) { 593 593 //match everything after the endpoint name, but allow for nothing to appear there 594 594 $epmatch = $endpoint[1] . '(/(.*))?/?$'; 595 595 //this will be appended on to the rest of the query for each dir … … 688 688 689 689 //do endpoints 690 690 if ($endpoints) { 691 foreach ( $ep_query_append as $regex => $ep) {691 foreach ( (array) $ep_query_append as $regex => $ep) { 692 692 //add the endpoints on if the mask fits 693 693 if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) { 694 694 $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); … … 745 745 $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); 746 746 747 747 //do endpoints for attachments 748 if ( ! empty($endpoint) ) { foreach ($ep_query_append as $regex => $ep) {748 if ( !empty($endpoint) ) { foreach ( (array) $ep_query_append as $regex => $ep ) { 749 749 if ($ep[0] & EP_ATTACHMENT) { 750 750 $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2); 751 751 $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2); … … 893 893 $rules .= "RewriteBase $home_root\n"; 894 894 895 895 //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all) 896 foreach ( $this->non_wp_rules as $match => $query) {896 foreach ( (array) $this->non_wp_rules as $match => $query) { 897 897 // Apache 1.3 does not support the reluctant (non-greedy) modifier. 898 898 $match = str_replace('.+?', '.+', $match); 899 899 … … 914 914 "RewriteCond %{REQUEST_FILENAME} -d\n" . 915 915 "RewriteRule ^.*$ - [S=$num_rules]\n"; 916 916 917 foreach ( $rewrite as $match => $query) {917 foreach ( (array) $rewrite as $match => $query) { 918 918 // Apache 1.3 does not support the reluctant (non-greedy) modifier. 919 919 $match = str_replace('.+?', '.+', $match); 920 920 -
rss.php
534 534 $rss = new MagpieRSS( $resp->results ); 535 535 536 536 // if RSS parsed successfully 537 if ( $rss and!$rss->ERROR) {537 if ( $rss && !$rss->ERROR) { 538 538 539 539 // find Etag, and Last-Modified 540 foreach( $resp->headers as $h) {540 foreach( (array) $resp->headers as $h) { 541 541 // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" 542 542 if (strpos($h, ": ")) { 543 543 list($field, $val) = explode(": ", $h, 2); … … 843 843 $rss->items = array_slice( $rss->items, 0, $num_items ); 844 844 } 845 845 846 foreach ( $rss->items as $item ) {846 foreach ( (array) $rss->items as $item ) { 847 847 printf( 848 848 '<li><a href="%1$s" title="%2$s">%3$s</a></li>', 849 849 clean_url( $item['link'] ), … … 864 864 $rss = fetch_rss($url); 865 865 if ( $rss ) { 866 866 $rss->items = array_slice($rss->items, 0, $num_items); 867 foreach ( $rss->items as $item ) {867 foreach ( (array) $rss->items as $item ) { 868 868 echo "<li>\n"; 869 869 echo "<a href='$item[link]' title='$item[description]'>"; 870 870 echo htmlentities($item['title']); … … 877 877 } 878 878 endif; 879 879 880 ?> 881 No newline at end of file 880 ?> -
taxonomy.php
49 49 $object = (array) $object; 50 50 51 51 $taxonomies = array(); 52 foreach ( $wp_taxonomies as $taxonomy ) {52 foreach ( (array) $wp_taxonomies as $taxonomy ) { 53 53 if ( array_intersect($object, (array) $taxonomy->object_type) ) 54 54 $taxonomies[] = $taxonomy->name; 55 55 } … … 230 230 if ( !is_array($taxonomies) ) 231 231 $taxonomies = array($taxonomies); 232 232 233 foreach ( $taxonomies as $taxonomy ) {233 foreach ( (array) $taxonomies as $taxonomy ) { 234 234 if ( ! is_taxonomy($taxonomy) ) 235 235 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 236 236 } … … 425 425 426 426 $children = $terms[$term]; 427 427 428 foreach ( $terms[$term] as $child ) {428 foreach ( (array) $terms[$term] as $child ) { 429 429 if ( isset($terms[$child]) ) 430 430 $children = array_merge($children, get_term_children($child, $taxonomy)); 431 431 } … … 558 558 $taxonomies = array($taxonomies); 559 559 } 560 560 561 foreach ( $taxonomies as $taxonomy ) {561 foreach ( (array) $taxonomies as $taxonomy ) { 562 562 if ( ! is_taxonomy($taxonomy) ) 563 563 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 564 564 } … … 626 626 $exclude = ''; 627 627 $interms = preg_split('/[\s,]+/',$include); 628 628 if ( count($interms) ) { 629 foreach ( $interms as $interm ) {629 foreach ( (array) $interms as $interm ) { 630 630 if (empty($inclusions)) 631 631 $inclusions = ' AND ( t.term_id = ' . intval($interm) . ' '; 632 632 else … … 643 643 if ( !empty($exclude) ) { 644 644 $exterms = preg_split('/[\s,]+/',$exclude); 645 645 if ( count($exterms) ) { 646 foreach ( $exterms as $exterm ) {646 foreach ( (array) $exterms as $exterm ) { 647 647 if (empty($exclusions)) 648 648 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' '; 649 649 else … … 721 721 _pad_term_counts($terms, $taxonomies[0]); 722 722 723 723 // Make sure we show empty categories that have children. 724 if ( $hierarchical && $hide_empty ) {724 if ( $hierarchical && $hide_empty && is_array($terms) ) { 725 725 foreach ( $terms as $k => $term ) { 726 726 if ( ! $term->count ) { 727 727 $children = _get_term_children($term->term_id, $terms, $taxonomies[0]); 728 foreach ( $children as $child ) 729 if ( $child->count ) 730 continue 2; 728 if( is_array($children) ) 729 foreach ( $children as $child ) 730 if ( $child->count ) 731 continue 2; 731 732 732 733 // It really is empty 733 734 unset($terms[$k]); … … 824 825 if ( is_object($term) ) 825 826 $do_object = true; 826 827 827 foreach ( $fields as $field ) {828 foreach ( (array) $fields as $field ) { 828 829 if ( $do_object ) 829 830 $term->$field = sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context); 830 831 else … … 955 956 if ( !is_array($taxonomies) ) 956 957 $taxonomies = array($taxonomies); 957 958 958 foreach ( $taxonomies as $taxonomy ) {959 foreach ( (array) $taxonomies as $taxonomy ) { 959 960 $terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids'); 960 961 $in_terms = "'" . implode("', '", $terms) . "'"; 961 962 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_terms)", $object_id) ); … … 1082 1083 if ( !is_array($taxonomies) ) 1083 1084 $taxonomies = array($taxonomies); 1084 1085 1085 foreach ( $taxonomies as $taxonomy ) {1086 foreach ( (array) $taxonomies as $taxonomy ) { 1086 1087 if ( ! is_taxonomy($taxonomy) ) 1087 1088 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 1088 1089 } … … 1323 1324 $tt_ids = array(); 1324 1325 $term_ids = array(); 1325 1326 1326 foreach ( $terms as $term) {1327 foreach ( (array) $terms as $term) { 1327 1328 if ( !strlen(trim($term)) ) 1328 1329 continue; 1329 1330 … … 1587 1588 static $_deferred = array(); 1588 1589 1589 1590 if ( $do_deferred ) { 1590 foreach ( array_keys($_deferred) as $tax ) {1591 foreach ( (array) array_keys($_deferred) as $tax ) { 1591 1592 wp_update_term_count_now( $_deferred[$tax], $tax ); 1592 1593 unset( $_deferred[$tax] ); 1593 1594 } … … 1628 1629 call_user_func($taxonomy->update_count_callback, $terms); 1629 1630 } else { 1630 1631 // Default count updater 1631 foreach ( $terms as $term) {1632 foreach ( (array) $terms as $term) { 1632 1633 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) ); 1633 1634 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 1634 1635 } … … 1821 1822 * @param string $taxonomy Optional. Update Term to this taxonomy in cache 1822 1823 */ 1823 1824 function update_term_cache($terms, $taxonomy = '') { 1824 foreach ( $terms as $term ) {1825 foreach ( (array) $terms as $term ) { 1825 1826 $term_taxonomy = $taxonomy; 1826 1827 if ( empty($term_taxonomy) ) 1827 1828 $term_taxonomy = $term->taxonomy; … … 1896 1897 if ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) ) 1897 1898 return $empty_array; 1898 1899 1899 foreach ( $terms as $term ) {1900 foreach ( (array) $terms as $term ) { 1900 1901 $use_id = false; 1901 1902 if ( !is_object($term) ) { 1902 1903 $term = get_term($term, $taxonomy); … … 1956 1957 1957 1958 $term_items = array(); 1958 1959 1959 foreach ( $terms as $key => $term ) {1960 foreach ( (array) $terms as $key => $term ) { 1960 1961 $terms_by_id[$term->term_id] = & $terms[$key]; 1961 1962 $term_ids[$term->term_taxonomy_id] = $term->term_id; 1962 1963 } … … 2006 2007 function _update_post_term_count( $terms ) { 2007 2008 global $wpdb; 2008 2009 2009 foreach ( $terms as $term ) {2010 foreach ( (array) $terms as $term ) { 2010 2011 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term ) ); 2011 2012 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 2012 2013 } … … 2154 2155 return get_object_taxonomies($post); 2155 2156 } 2156 2157 2157 ?> 2158 No newline at end of file 2158 ?> -
user.php
286 286 if ( $show_option_none ) 287 287 $output .= "\t<option value='-1'>$show_option_none</option>\n"; 288 288 289 foreach ( $users as $user ) {289 foreach ( (array) $users as $user ) { 290 290 $user->ID = (int) $user->ID; 291 291 $_selected = $user->ID == $selected ? " selected='selected'" : ''; 292 292 $output .= "\t<option value='$user->ID'$_selected>" . wp_specialchars($user->$show) . "</option>\n"; … … 311 311 $wpdb->show_errors($show); 312 312 313 313 if ( $metavalues ) { 314 foreach ( $metavalues as $meta ) {314 foreach ( (array) $metavalues as $meta ) { 315 315 $value = maybe_unserialize($meta->meta_value); 316 316 $user->{$meta->meta_key} = $value; 317 317 } -
widgets.php
208 208 $index = "sidebar-$index"; 209 209 } else { 210 210 $index = sanitize_title($index); 211 foreach ( $wp_registered_sidebars as $key => $value ) {211 foreach ( (array) $wp_registered_sidebars as $key => $value ) { 212 212 if ( sanitize_title($value['name']) == $index ) { 213 213 $index = $key; 214 214 break; … … 224 224 $sidebar = $wp_registered_sidebars[$index]; 225 225 226 226 $did_one = false; 227 foreach ( $sidebars_widgets[$index] as $id ) {227 foreach ( (array) $sidebars_widgets[$index] as $id ) { 228 228 $params = array_merge( 229 229 array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ), 230 230 (array) $wp_registered_widgets[$id]['params'] … … 274 274 function is_dynamic_sidebar() { 275 275 global $wp_registered_widgets, $wp_registered_sidebars; 276 276 $sidebars_widgets = get_option('sidebars_widgets'); 277 foreach ( $wp_registered_sidebars as $index => $sidebar ) {277 foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) { 278 278 if ( count($sidebars_widgets[$index]) ) { 279 foreach ( $sidebars_widgets[$index] as $widget )279 foreach ( (array) $sidebars_widgets[$index] as $widget ) 280 280 if ( array_key_exists($widget, $wp_registered_widgets) ) 281 281 return true; 282 282 } … … 297 297 298 298 switch ( $sidebars_widgets['array_version'] ) { 299 299 case 1 : 300 foreach ( $sidebars_widgets as $index => $sidebar )300 foreach ( (array) $sidebars_widgets as $index => $sidebar ) 301 301 if ( is_array($sidebar) ) 302 foreach ( $sidebar as $i => $name ) {302 foreach ( (array) $sidebar as $i => $name ) { 303 303 $id = strtolower($name); 304 304 if ( isset($wp_registered_widgets[$id]) ) { 305 305 $_sidebars_widgets[$index][$i] = $id; … … 338 338 $sidebars = array_keys( $wp_registered_sidebars ); 339 339 if ( !empty( $sidebars ) ) { 340 340 // Move the known-good ones first 341 foreach ( $sidebars as $id ) {341 foreach ( (array) $sidebars as $id ) { 342 342 if ( array_key_exists( $id, $sidebars_widgets ) ) { 343 343 $_sidebars_widgets[$id] = $sidebars_widgets[$id]; 344 344 unset($sidebars_widgets[$id], $sidebars[$id]); … … 373 373 374 374 $defaults = array(); 375 375 376 foreach ( $wp_registered_sidebars as $index => $sidebar )376 foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) 377 377 $defaults[$index] = array(); 378 378 379 379 return $defaults; … … 635 635 else 636 636 $this_sidebar = array(); 637 637 638 foreach ( $this_sidebar as $_widget_id ) {638 foreach ( (array) $this_sidebar as $_widget_id ) { 639 639 if ( 'wp_widget_text' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { 640 640 $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; 641 641 if ( !in_array( "text-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. … … 683 683 $name = __('Text'); 684 684 685 685 $id = false; 686 foreach ( array_keys($options) as $o ) {686 foreach ( (array) array_keys($options) as $o ) { 687 687 // Old widgets can have null values for some reason 688 688 if ( !isset($options[$o]['title']) || !isset($options[$o]['text']) ) 689 689 continue; … … 729 729 730 730 <script type='text/javascript'> 731 731 /* <![CDATA[ */ 732 var dropdown = document.getElementById("cat");733 function onCatChange() {732 var dropdown = document.getElementById("cat"); 733 function onCatChange() { 734 734 if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { 735 735 location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value; 736 736 } 737 }738 dropdown.onchange = onCatChange;737 } 738 dropdown.onchange = onCatChange; 739 739 /* ]]> */ 740 740 </script> 741 741 … … 777 777 else 778 778 $this_sidebar = array(); 779 779 780 foreach ( $this_sidebar as $_widget_id ) {780 foreach ( (array) $this_sidebar as $_widget_id ) { 781 781 if ( 'wp_widget_categories' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { 782 782 $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; 783 783 if ( !in_array( "categories-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. … … 852 852 $name = __( 'Categories' ); 853 853 854 854 $id = false; 855 foreach ( array_keys($options) as $o ) {855 foreach ( (array) array_keys($options) as $o ) { 856 856 // Old widgets can have null values for some reason 857 857 if ( !isset($options[$o]['title']) ) 858 858 continue; … … 986 986 <?php echo $before_widget; ?> 987 987 <?php echo $before_title . $title . $after_title; ?> 988 988 <ul id="recentcomments"><?php 989 if ( $comments ) : foreach ( $comments as $comment) :989 if ( $comments ) : foreach ( (array) $comments as $comment) : 990 990 echo '<li class="recentcomments">' . 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>') . '</li>'; 991 991 endforeach; endif;?></ul> 992 992 <?php echo $after_widget; ?> … … 1117 1117 if ( is_array( $rss->items ) && !empty( $rss->items ) ) { 1118 1118 $rss->items = array_slice($rss->items, 0, $items); 1119 1119 echo '<ul>'; 1120 foreach ( $rss->items as $item ) {1120 foreach ( (array) $rss->items as $item ) { 1121 1121 while ( strstr($item['link'], 'http') != $item['link'] ) 1122 1122 $item['link'] = substr($item['link'], 1); 1123 1123 $link = clean_url(strip_tags($item['link'])); … … 1191 1191 $options = array(); 1192 1192 1193 1193 $urls = array(); 1194 foreach ( $options as $option )1194 foreach ( (array) $options as $option ) 1195 1195 if ( isset($option['url']) ) 1196 1196 $urls[$option['url']] = true; 1197 1197 … … 1204 1204 else 1205 1205 $this_sidebar = array(); 1206 1206 1207 foreach ( $this_sidebar as $_widget_id ) {1207 foreach ( (array) $this_sidebar as $_widget_id ) { 1208 1208 if ( 'wp_widget_rss' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { 1209 1209 $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; 1210 1210 if ( !in_array( "rss-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. … … 1349 1349 $name = __('RSS'); 1350 1350 1351 1351 $id = false; 1352 foreach ( array_keys($options) as $o ) {1352 foreach ( (array) array_keys($options) as $o ) { 1353 1353 // Old widgets can have null values for some reason 1354 1354 if ( !isset($options[$o]['url']) || !isset($options[$o]['title']) || !isset($options[$o]['items']) ) 1355 1355 continue; -
wp-db.php
378 378 $old_prefix = $this->prefix; 379 379 $this->prefix = $prefix; 380 380 381 foreach ( $this->tables as $table )381 foreach ( (array) $this->tables as $table ) 382 382 $this->$table = $this->prefix . $table; 383 383 384 384 if ( defined('CUSTOM_USER_TABLE') ) … … 677 677 function update($table, $data, $where){ 678 678 $data = add_magic_quotes($data); 679 679 $bits = $wheres = array(); 680 foreach ( array_keys($data) as $k )680 foreach ( (array) array_keys($data) as $k ) 681 681 $bits[] = "`$k` = '$data[$k]'"; 682 682 683 683 if ( is_array( $where ) ) … … 805 805 // Return an integer-keyed array of... 806 806 if ( $this->last_result ) { 807 807 $i = 0; 808 foreach( $this->last_result as $row ) {808 foreach( (array) $this->last_result as $row ) { 809 809 if ( $output == ARRAY_N ) { 810 810 // ...integer-keyed row arrays 811 811 $new_array[$i] = array_values( get_object_vars( $row ) ); … … 833 833 if ( $this->col_info ) { 834 834 if ( $col_offset == -1 ) { 835 835 $i = 0; 836 foreach( $this->col_info as $col ) {836 foreach( (array) $this->col_info as $col ) { 837 837 $new_array[$i] = $col->{$info_type}; 838 838 $i++; 839 839 } … … 941 941 $bt = debug_backtrace(); 942 942 $caller = ''; 943 943 944 foreach ( $bt as $trace ) {944 foreach ( (array) $bt as $trace ) { 945 945 if ( @$trace['class'] == __CLASS__ ) 946 946 continue; 947 947 elseif ( strtolower(@$trace['function']) == 'call_user_func_array' )