### Eclipse Workspace Patch 1.0
#P wordpress-trunk
Index: wp-admin/includes/dashboard.php
===================================================================
--- wp-admin/includes/dashboard.php	(revision 15073)
+++ wp-admin/includes/dashboard.php	(working copy)
@@ -855,33 +855,56 @@
  * @since unknown
  */
 function wp_dashboard_plugins_output() {
-	$popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
-	$new     = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
-	$updated = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/updated/' );
+	// feeds configuration
+	$feeds = array(		
+		'popular' => array(
+			'url'   => 'http://wordpress.org/extend/plugins/rss/browse/popular/',
+			'label' => __('Most Popular'),
+			),
+		'new'     => array(
+			'url' => 'http://wordpress.org/extend/plugins/rss/browse/popular/',
+			'label' => __('Newest Plugins'),
+			),
+		'updated' => array(
+			'url' => 'http://wordpress.org/extend/plugins/rss/browse/popular/',
+			'label' => __('Recently Updated'),
+			),
+	);
 
-	if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
+	// get plugin slugs of installed plugins to compare against later
+	if ( false === ($plugin_slugs = get_transient( 'plugin_slugs' )) ) {
 		$plugin_slugs = array_keys( get_plugins() );
 		set_transient( 'plugin_slugs', $plugin_slugs, 86400 );
 	}
 
-	foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) {
-		if ( is_wp_error($$feed) || !$$feed->get_item_quantity() )
+	// Pick a random, non-installed plugin per feed
+	foreach ( $feeds as $feed_data ) {
+		$label = $feed_data['label'];
+
+		$feed  = fetch_feed( $feed_data['url'] );
+		if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() )
 			continue;
 
-		$items = $$feed->get_items(0, 5);
+		$items = $feed->get_items( 0, 5 );
 
 		// Pick a random, non-installed plugin
-		while ( true ) {
-			// Abort this foreach loop iteration if there's no plugins left of this type
-			if ( 0 == count($items) )
+		while( true ) {
+			if ( 0 == count( $items ) ) 
 				continue 2;
 
-			$item_key = array_rand($items);
-			$item = $items[$item_key];
+			$item_key = array_rand( $items );
+			$item     = $items[$item_key];
+			
+			// filter plugins with common badly formed descriptions
+			$description = $item->get_description();
+			if ( false !== strpos( $description, 'Plugin Name:' ) ) {
+				unset( $items[$item_key] );
+				continue;
+			}
 
-			list($link, $frag) = explode( '#', $item->get_link() );
-
-			$link = esc_url($link);
+			// filter plugins with common badly formed links 
+			list( $link, $frag ) = explode( '#', $item->get_link() );
+			$link                = esc_url( $link );
 			if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
 				$slug = $matches[1];
 			else {
@@ -889,44 +912,38 @@
 				continue;
 			}
 
-			// Is this random plugin's slug already installed? If so, try again.
-			reset( $plugin_slugs );
-			foreach ( $plugin_slugs as $plugin_slug ) {
-				if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
-					unset( $items[$item_key] );
-					continue 2;
-				}
+			// filter out already installed plugins
+			if ( in_array( $slug, $plugin_slugs ) ) {
+				unset( $items[$item_key] );
+				continue;
 			}
 
 			// If we get to this point, then the random plugin isn't installed and we can stop the while().
 			break;
 		}
 
-		// Eliminate some common badly formed plugin descriptions
-		while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
-			unset($items[$item_key]);
+		$title        = $item->get_title();
 
-		if ( !isset($items[$item_key]) )
-			continue;
-
 		// current bbPress feed item titles are: user on "topic title"
-		if ( preg_match( '/&quot;(.*)&quot;/s', $item->get_title(), $matches ) )
+		if ( preg_match( '/&quot;(.*)&quot;/s', $title, $matches ) )
 			$title = $matches[1];
-		else // but let's make it forward compatible if things change
-			$title = $item->get_title();
-		$title = esc_html( $title );
 
-		$description = esc_html( strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) );
+		$title        = esc_html( $title );
 
-		$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
-							'&amp;TB_iframe=true&amp;width=600&amp;height=800';
+		$description  = strip_tags( @html_entity_decode( $description ), ENT_QUOTES, get_option( 'blog_charset' ) );
+		$description  = esc_html( $description );
+		
+		$ilink_url    = 'plugin-install.php?tab=plugin-information&plugin=' . $slug;
+		$ilink_action = 'install-plugin_' . $slug;
+		$ilink_suffix = '&amp;TB_iframe=true&amp;width=600&amp;height=800';
+		$ilink        = wp_nonce_url( $ilink_url , $ilink_action ) . $ilink_suffix;
 
 		echo "<h4>$label</h4>\n";
 		echo "<h5><a href='$link'>$title</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
 		echo "<p>$description</p>\n";
 
-		$$feed->__destruct();
-		unset($$feed);
+		$feed->__destruct();
+		unset( $feed );
 	}
 }
 
