Don't show already installed plugins in the Plugins dashboard widget. Props Viper007Bond. fixes #8781
git-svn-id: http://svn.automattic.com/wordpress/trunk@10738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3bf4ed1758
commit
98462ab1b6
@ -734,12 +734,48 @@ function wp_dashboard_plugins_output() {
|
|||||||
$new = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
|
$new = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
|
||||||
$updated = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/updated/' );
|
$updated = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/updated/' );
|
||||||
|
|
||||||
|
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 ) {
|
foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) {
|
||||||
if ( !$$feed->get_item_quantity() )
|
if ( !$$feed->get_item_quantity() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$items = $$feed->get_items(0, 5);
|
$items = $$feed->get_items(0, 5);
|
||||||
$item_key = array_rand($items);
|
|
||||||
|
// 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) )
|
||||||
|
continue 2;
|
||||||
|
|
||||||
|
$item_key = array_rand($items);
|
||||||
|
$item = $items[$item_key];
|
||||||
|
|
||||||
|
list($link, $frag) = explode( '#', $item->get_link() );
|
||||||
|
|
||||||
|
$link = clean_url($link);
|
||||||
|
if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
|
||||||
|
$slug = $matches[1];
|
||||||
|
else {
|
||||||
|
unset( $items[$item_key] );
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
// Eliminate some common badly formed plugin descriptions
|
||||||
while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
|
while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
|
||||||
@ -748,8 +784,6 @@ function wp_dashboard_plugins_output() {
|
|||||||
if ( !isset($items[$item_key]) )
|
if ( !isset($items[$item_key]) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$item = $items[$item_key];
|
|
||||||
|
|
||||||
// current bbPress feed item titles are: user on "topic title"
|
// current bbPress feed item titles are: user on "topic title"
|
||||||
if ( preg_match( '/"(.*)"/s', $item->get_title(), $matches ) )
|
if ( preg_match( '/"(.*)"/s', $item->get_title(), $matches ) )
|
||||||
$title = $matches[1];
|
$title = $matches[1];
|
||||||
@ -759,14 +793,6 @@ function wp_dashboard_plugins_output() {
|
|||||||
|
|
||||||
$description = wp_specialchars( strip_tags(html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) );
|
$description = wp_specialchars( strip_tags(html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) );
|
||||||
|
|
||||||
list($link, $frag) = explode( '#', $item->get_link() );
|
|
||||||
|
|
||||||
$link = clean_url($link);
|
|
||||||
if( preg_match('|/([^/]+?)/?$|', $link, $matches) )
|
|
||||||
$slug = $matches[1];
|
|
||||||
else
|
|
||||||
$slug = '';
|
|
||||||
|
|
||||||
$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
|
$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
|
||||||
'&TB_iframe=true&width=600&height=800';
|
'&TB_iframe=true&width=600&height=800';
|
||||||
|
|
||||||
@ -885,4 +911,4 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
|
|||||||
*/
|
*/
|
||||||
function wp_dashboard_empty() {}
|
function wp_dashboard_empty() {}
|
||||||
|
|
||||||
?>
|
?>
|
@ -212,8 +212,9 @@ $active_plugins = array();
|
|||||||
$inactive_plugins = array();
|
$inactive_plugins = array();
|
||||||
$recent_plugins = array();
|
$recent_plugins = array();
|
||||||
$recently_activated = (array) get_option('recently_activated');
|
$recently_activated = (array) get_option('recently_activated');
|
||||||
|
set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 );
|
||||||
|
|
||||||
//Clean out any plugins which were deactivated over a week ago.
|
// Clean out any plugins which were deactivated over a week ago.
|
||||||
foreach ( $recently_activated as $key => $time )
|
foreach ( $recently_activated as $key => $time )
|
||||||
if ( $time + (7*24*60*60) < time() ) //1 week
|
if ( $time + (7*24*60*60) < time() ) //1 week
|
||||||
unset($recently_activated[ $key ]);
|
unset($recently_activated[ $key ]);
|
||||||
@ -394,4 +395,4 @@ function print_plugin_actions($context) {
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
include('admin-footer.php');
|
include('admin-footer.php');
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user