diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php index f8adbf26ff..fe588cd461 100644 --- a/wp-admin/includes/nav-menu.php +++ b/wp-admin/includes/nav-menu.php @@ -1252,7 +1252,7 @@ add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); */ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) { $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) ); - + $messages = array(); $menu_items = array(); // Index menu items by db ID foreach ( $unsorted_menu_items as $_item ) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 425e40b0f0..b3e7b61675 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -301,11 +301,14 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech function wp_link_category_checklist( $link_id = 0 ) { $default = 1; + $checked_categories = array(); + if ( $link_id ) { $checked_categories = wp_get_link_cats( $link_id ); // No selected categories, strange - if ( ! count( $checked_categories ) ) + if ( ! count( $checked_categories ) ) { $checked_categories[] = $default; + } } else { $checked_categories[] = $default; } diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 1bc7212bb1..8c2c678eca 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -430,6 +430,9 @@ function wp_prepare_themes_for_js( $themes = null ) { } WP_Theme::sort_by_name( $themes ); + + $parents = array(); + foreach ( $themes as $theme ) { $slug = $theme->get_stylesheet(); $encoded_slug = urlencode( $slug ); @@ -469,7 +472,7 @@ function wp_prepare_themes_for_js( $themes = null ) { } // Remove 'delete' action if theme has an active child - if ( isset( $parents ) && array_key_exists( $current_theme, $parents ) ) { + if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) { unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] ); } diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 15a1097fe8..b72303afa7 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1786,7 +1786,7 @@ function dbDelta( $queries = '', $execute = true ) { if ($tableindices) { // Clear the index array. - unset($index_ary); + $index_ary = array(); // For every index in the table. foreach ($tableindices as $tableindex) { diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 0f97068ff9..6048432f22 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -1289,11 +1289,14 @@ function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' if ( empty( $terms ) ) return false; + $links = array(); + foreach ( $terms as $term ) { $link = get_term_link( $term, $taxonomy ); - if ( is_wp_error( $link ) ) + if ( is_wp_error( $link ) ) { return $link; - $term_links[] = ''; + } + $links[] = ''; } /** @@ -1304,9 +1307,9 @@ function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' * * @since 2.5.0 * - * @param array $term_links An array of term links. + * @param array $links An array of term links. */ - $term_links = apply_filters( "term_links-$taxonomy", $term_links ); + $term_links = apply_filters( "term_links-$taxonomy", $links ); return $before . join( $sep, $term_links ) . $after; } diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 1bdadd8ee2..180e0744d9 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -1266,6 +1266,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget { } public function update( $new_instance, $old_instance ) { + $instance = array(); $instance['title'] = strip_tags(stripslashes($new_instance['title'])); $instance['taxonomy'] = stripslashes($new_instance['taxonomy']); return $instance; diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 3d4d1f20c7..ea22c4d805 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1022,6 +1022,7 @@ function remove_accents($string) { $string = strtr($string, $chars); } else { + $chars = array(); // Assume ISO-8859-1 if not UTF-8 $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158) .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194) @@ -1037,6 +1038,7 @@ function remove_accents($string) { $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; $string = strtr($string, $chars['in'], $chars['out']); + $double_chars = array(); $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)); $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th'); $string = str_replace($double_chars['in'], $double_chars['out'], $string); diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 8655ceed21..5136a53617 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1438,7 +1438,6 @@ function wp_get_archives( $args = '' ) { $key = "wp_get_archives:$key:$last_changed"; if ( ! $results = wp_cache_get( $key, 'posts' ) ) { $results = $wpdb->get_results( $query ); - $cache[ $key ] = $results; wp_cache_set( $key, $results, 'posts' ); } if ( $results ) { @@ -1657,6 +1656,8 @@ function get_calendar($initial = true, $echo = true) { '; + $daywithpost = array(); + // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' @@ -1666,8 +1667,6 @@ function get_calendar($initial = true, $echo = true) { foreach ( (array) $dayswithposts as $daywith ) { $daywithpost[] = $daywith[0]; } - } else { - $daywithpost = array(); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) diff --git a/wp-includes/media.php b/wp-includes/media.php index c7d092d966..c02aabcf59 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -586,6 +586,8 @@ function image_get_intermediate_size($post_id, $size='thumbnail') { // get the best one for a specified set of dimensions if ( is_array($size) && !empty($imagedata['sizes']) ) { + $areas = array(); + foreach ( $imagedata['sizes'] as $_size => $data ) { // already cropped to width or height; so use this size if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) { diff --git a/wp-includes/ms-deprecated.php b/wp-includes/ms-deprecated.php index ffd65ca821..1a0b253242 100644 --- a/wp-includes/ms-deprecated.php +++ b/wp-includes/ms-deprecated.php @@ -166,20 +166,21 @@ function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) { global $wpdb; $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A ); + $blog_list = array(); foreach ( (array) $blogs as $details ) { $blog_list[ $details['blog_id'] ] = $details; $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" ); } - unset( $blogs ); - $blogs = $blog_list; - if ( false == is_array( $blogs ) ) + if ( ! $blog_list ) { return array(); + } - if ( $num == 'all' ) - return array_slice( $blogs, $start, count( $blogs ) ); - else - return array_slice( $blogs, $start, $num ); + if ( $num == 'all' ) { + return array_slice( $blog_list, $start, count( $blog_list ) ); + } else { + return array_slice( $blog_list, $start, $num ); + } } /** diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php index 652b190962..6e3344e391 100644 --- a/wp-includes/ms-load.php +++ b/wp-includes/ms-load.php @@ -308,6 +308,8 @@ function get_site_by_path( $domain, $path, $segments = null ) { $path_segments = array_slice( $path_segments, 0, $segments ); } + $paths = array(); + while ( count( $path_segments ) ) { $paths[] = '/' . implode( '/', $path_segments ) . '/'; array_pop( $path_segments ); diff --git a/wp-includes/post.php b/wp-includes/post.php index c8963e6b2d..d8c8c55542 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -352,12 +352,16 @@ function get_children( $args = '', $output = OBJECT ) { if ( $output == OBJECT ) { return $kids; } elseif ( $output == ARRAY_A ) { - foreach ( (array) $kids as $kid ) + $weeuns = array(); + foreach ( (array) $kids as $kid ) { $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]); + } return $weeuns; } elseif ( $output == ARRAY_N ) { - foreach ( (array) $kids as $kid ) + $babes = array(); + foreach ( (array) $kids as $kid ) { $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID])); + } return $babes; } else { return $kids; @@ -1681,9 +1685,10 @@ function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) { if ( !isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) ) $object->labels['all_items'] = $object->labels['menu_name']; - foreach ( $nohier_vs_hier_defaults as $key => $value ) - $defaults[$key] = $object->hierarchical ? $value[1] : $value[0]; - + $defaults = array(); + foreach ( $nohier_vs_hier_defaults as $key => $value ) { + $defaults[$key] = $object->hierarchical ? $value[1] : $value[0]; + } $labels = array_merge( $defaults, $object->labels ); return (object)$labels; } @@ -2510,6 +2515,9 @@ function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) { $wildcards = array('', '%', '%/%'); if ( is_string($post_mime_types) ) $post_mime_types = array_map('trim', explode(',', $post_mime_types)); + + $wheres = array(); + foreach ( (array) $post_mime_types as $mime_type ) { $mime_type = preg_replace('/\s/', '', $mime_type); $slashpos = strpos($mime_type, '/'); @@ -5140,6 +5148,7 @@ function wp_mime_type_icon( $mime = 0 ) { wp_cache_add( 'icon_files', $icon_files, 'default', 600 ); } + $types = array(); // Icon basename - extension = MIME wildcard. foreach ( $icon_files as $file => $uri ) $types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file]; @@ -5513,9 +5522,11 @@ function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = if ( is_array($post_type) ) { $ptypes = $post_type; } elseif ( 'any' == $post_type ) { + $ptypes = array(); // Just use the post_types in the supplied posts. - foreach ( $posts as $post ) + foreach ( $posts as $post ) { $ptypes[] = $post->post_type; + } $ptypes = array_unique($ptypes); } else { $ptypes = array($post_type); diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 9bc167f08f..23595ef1a3 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -1288,6 +1288,7 @@ class WP_Rewrite { $trackbackindex = $index; //build a list from the rewritecode and queryreplace arrays, that will look something like //tagname=$matches[i] where i is the current $i + $queries = array(); for ( $i = 0; $i < $num_tokens; ++$i ) { if ( 0 < $i ) $queries[$i] = $queries[$i - 1] . '&'; @@ -1328,7 +1329,7 @@ class WP_Rewrite { $num_toks = preg_match_all('/%.+?%/', $struct, $toks); //get the 'tagname=$matches[i]' - $query = ( isset($queries) && is_array($queries) && !empty($num_toks) ) ? $queries[$num_toks - 1] : ''; + $query = ( ! empty( $num_toks ) && isset( $queries[$num_toks - 1] ) ) ? $queries[$num_toks - 1] : ''; //set up $ep_mask_specific which is used to match more specific URL types switch ( $dirs[$j] ) { diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 1d93f69047..7d49a543e7 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -3889,6 +3889,8 @@ function _pad_term_counts(&$terms, $taxonomy) { return; $term_items = array(); + $terms_by_id = array(); + $term_ids = array(); foreach ( (array) $terms as $key => $term ) { $terms_by_id[$term->term_id] = & $terms[$key]; diff --git a/wp-includes/theme.php b/wp-includes/theme.php index f8539e9f8f..4a8d342fde 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -406,6 +406,7 @@ function search_theme_directories( $force = false ) { $found_themes = array(); $wp_theme_directories = (array) $wp_theme_directories; + $relative_theme_roots = array(); // Set up maybe-relative, maybe-absolute array of theme directories. // We always want to return absolute, but we need to cache relative