| | 102 | |
| | 103 | case 'plugins' : |
| | 104 | $popular = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/popular/' ); |
| | 105 | $new = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/new/' ); |
| | 106 | $updated = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/updated/' ); |
| | 107 | |
| | 108 | foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) : |
| | 109 | if ( !isset($$feed->items) || 0 == count($$feed->items) ) |
| | 110 | continue; |
| | 111 | |
| | 112 | $$feed->items = array_slice($$feed->items, 0, 5); |
| | 113 | $item_key = array_rand($$feed->items); |
| | 114 | |
| | 115 | // Eliminate some common badly formed plugin descriptions |
| | 116 | while ( ( null !== $item_key = array_rand($$feed->items) ) && false !== strpos( $$feed->items[$item_key]['description'], 'Plugin Name:' ) ) |
| | 117 | unset($$feed->items[$item_key]); |
| | 118 | |
| | 119 | if ( !isset($$feed->items[$item_key]) ) |
| | 120 | continue; |
| | 121 | |
| | 122 | $item = $$feed->items[$item_key]; |
| | 123 | |
| | 124 | // current bbPress feed item titles are: user on "topic title" |
| | 125 | if ( preg_match( '/"(.*)"/s', $item['title'], $matches ) ) |
| | 126 | $title = $matches[1]; |
| | 127 | else // but let's make it forward compatible if things change |
| | 128 | $title = $item['title']; |
| | 129 | $title = wp_specialchars( $title ); |
| | 130 | |
| | 131 | $description = wp_specialchars( strip_tags(html_entity_decode($item['description'], ENT_QUOTES)) ); |
| | 132 | |
| | 133 | list($link, $frag) = explode( '#', $item['link'] ); |
| | 134 | |
| | 135 | $link = clean_url($link); |
| | 136 | $dlink = rtrim($link, '/') . '/download/'; |
| | 137 | |
| | 138 | ?> |
| | 139 | |
| | 140 | <h4><?php echo $label; ?></h4> |
| | 141 | <h5><a href="<?php echo $link; ?>"><?php echo $title; ?></a></h5> <span>(<a href="<?php echo $dlink; ?>"><?php _e( 'Download' ); ?></a>)</span> |
| | 142 | |
| | 143 | <p><?php echo $description; ?></p> |
| | 144 | |
| | 145 | <?php |
| | 146 | |
| | 147 | endforeach; |
| | 148 | break; |
| | 149 | |