Make WordPress Core

Ticket #8781: 8781.4.patch

File 8781.4.patch, 5.1 KB (added by Viper007Bond, 15 years ago)

Code improvements care of rmccue and DD32

  • wp-admin/includes/dashboard.php

     
    708708        $new     = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
    709709        $updated = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/updated/' );
    710710
     711        $plugin_slugs = get_option( 'plugin_slugs' );
     712        if ( !is_array($plugin_slugs) ) {
     713                $all_plugins = get_plugins();
     714                $plugin_slugs = array();
     715                foreach ( $all_plugins as $slug => $plugin )
     716                        $plugin_slugs[] = $slug;
     717                update_option( 'plugin_slugs', $plugin_slugs );
     718        }
     719
    711720        foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) {
    712721                if ( !isset($$feed->items) || 0 == count($$feed->items) )
    713722                        continue;
    714723
    715724                $$feed->items = array_slice($$feed->items, 0, 5);
    716                 $item_key = array_rand($$feed->items);
    717725
     726                // Pick a random, non-installed plugin
     727                unset( $item );
     728                while ( empty($item) ) {
     729                        // Abort entirely if there's no items left for this part
     730                        if ( 0 == count($$feed->items) )
     731                                continue 2;
     732
     733                        $item_key = array_rand($$feed->items);
     734                        $item = $$feed->items[$item_key];
     735
     736                        list($link, $frag) = explode( '#', $item['link'] );
     737
     738                        $link = clean_url($link);
     739                        if( preg_match('|/([^/]+?)/?$|', $link, $matches) )
     740                                $slug = $matches[1];
     741                        else
     742                                $slug = '';
     743
     744                        // Check to see if this random plugin is already installed. If so, try a different one.
     745                        reset( $plugin_slugs );
     746                        foreach ( $plugin_slugs as $plugin_slug ) {
     747                                if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
     748                                        unset( $item, $$feed->items[$item_key] );
     749                                        continue 2;
     750                                }
     751                        }
     752
     753                        // We can stop looping as this random plugin isn't installed
     754                        break;
     755                }
     756
    718757                // Eliminate some common badly formed plugin descriptions
    719758                while ( ( null !== $item_key = array_rand($$feed->items) ) && false !== strpos( $$feed->items[$item_key]['description'], 'Plugin Name:' ) )
    720759                        unset($$feed->items[$item_key]);
     
    722761                if ( !isset($$feed->items[$item_key]) )
    723762                        continue;
    724763
    725                 $item = $$feed->items[$item_key];
    726 
    727764                // current bbPress feed item titles are: user on "topic title"
    728765                if ( preg_match( '/"(.*)"/s', $item['title'], $matches ) )
    729766                        $title = $matches[1];
     
    733770
    734771                $description = wp_specialchars( strip_tags(html_entity_decode($item['description'], ENT_QUOTES)) );
    735772
    736                 list($link, $frag) = explode( '#', $item['link'] );
    737 
    738                 $link = clean_url($link);
    739                 if( preg_match('|/([^/]+?)/?$|', $link, $matches) )
    740                         $slug = $matches[1];
    741                 else
    742                         $slug = '';
    743 
    744773                $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
    745774                                                        '&TB_iframe=true&width=600&height=800';
    746775
  • wp-admin/includes/schema.php

     
    302302        add_option('update_core', array());
    303303        add_option('dismissed_update_core', array());
    304304
     305        // 2.7.1
     306        add_option('plugin_slugs', '', '', 'no');
     307
    305308        // Delete unused options
    306309        $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins');
    307310        foreach ($unusedoptions as $option) :
  • wp-admin/plugins.php

     
    213213$recent_plugins = array();
    214214$recently_activated = (array) get_option('recently_activated');
    215215
    216 //Clean out any plugins which were deactivated over a week ago.
     216// Update the slug cache
     217$plugin_slugs = array();
     218foreach ( $plugin_slugs as $slug => $plugin )
     219        $plugin_slugs[] = $slug;
     220update_option( 'plugin_slugs', $plugin_slugs );
     221
     222// Clean out any plugins which were deactivated over a week ago.
    217223foreach ( $recently_activated as $key => $time )
    218224        if ( $time + (7*24*60*60) < time() ) //1 week
    219225                unset($recently_activated[ $key ]);