Make WordPress Core


Ignore:
Timestamp:
12/22/2011 09:57:21 PM (12 years ago)
Author:
ryan
Message:

Remove Plugins dashboard widget. fixes #19573

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/dashboard.php

    r19596 r19628  
    7070        wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
    7171    }
    72 
    73     // WP Plugins Widget
    74     if ( ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) )
    75         wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
    7672
    7773    // QuickPress Widget
     
    932928        $rss->__destruct();
    933929        unset($rss);
    934     }
    935 }
    936 
    937 function wp_dashboard_plugins() {
    938     wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array(
    939         'http://wordpress.org/extend/plugins/rss/browse/popular/',
    940         'http://wordpress.org/extend/plugins/rss/browse/new/',
    941         'http://wordpress.org/extend/plugins/rss/browse/updated/'
    942     ) );
    943 }
    944 
    945 /**
    946  * Display plugins most popular, newest plugins, and recently updated widget text.
    947  *
    948  * @since 2.5.0
    949  */
    950 function wp_dashboard_plugins_output() {
    951     $popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
    952     $new     = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
    953     $updated = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/updated/' );
    954 
    955     if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
    956         $plugin_slugs = array_keys( get_plugins() );
    957         set_transient( 'plugin_slugs', $plugin_slugs, 86400 );
    958     }
    959 
    960     foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) {
    961         if ( is_wp_error($$feed) || !$$feed->get_item_quantity() )
    962             continue;
    963 
    964         $items = $$feed->get_items(0, 5);
    965 
    966         // Pick a random, non-installed plugin
    967         while ( true ) {
    968             // Abort this foreach loop iteration if there's no plugins left of this type
    969             if ( 0 == count($items) )
    970                 continue 2;
    971 
    972             $item_key = array_rand($items);
    973             $item = $items[$item_key];
    974 
    975             list($link, $frag) = explode( '#', $item->get_link() );
    976 
    977             $link = esc_url($link);
    978             if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
    979                 $slug = $matches[1];
    980             else {
    981                 unset( $items[$item_key] );
    982                 continue;
    983             }
    984 
    985             // Is this random plugin's slug already installed? If so, try again.
    986             reset( $plugin_slugs );
    987             foreach ( $plugin_slugs as $plugin_slug ) {
    988                 if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
    989                     unset( $items[$item_key] );
    990                     continue 2;
    991                 }
    992             }
    993 
    994             // If we get to this point, then the random plugin isn't installed and we can stop the while().
    995             break;
    996         }
    997 
    998         // Eliminate some common badly formed plugin descriptions
    999         while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
    1000             unset($items[$item_key]);
    1001 
    1002         if ( !isset($items[$item_key]) )
    1003             continue;
    1004 
    1005         // current bbPress feed item titles are: user on "topic title"
    1006         if ( preg_match( '/"(.*)"/s', $item->get_title(), $matches ) )
    1007             $title = $matches[1];
    1008         else // but let's make it forward compatible if things change
    1009             $title = $item->get_title();
    1010         $title = esc_html( $title );
    1011 
    1012         $description = esc_html( strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) );
    1013 
    1014         $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
    1015                             '&TB_iframe=true&width=600&height=800';
    1016 
    1017         echo "<h4>$label</h4>\n";
    1018         echo "<h5><a href='$link'>$title</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
    1019         echo "<p>$description</p>\n";
    1020 
    1021         $$feed->__destruct();
    1022         unset($$feed);
    1023930    }
    1024931}
Note: See TracChangeset for help on using the changeset viewer.