Make WordPress Core


Ignore:
Timestamp:
02/21/2008 09:20:09 PM (17 years ago)
Author:
ryan
Message:

Dashboard widgets caching improvements from mdawaffe. see #5750

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/index-extra.php

    r6928 r6958  
    11<?php
    22require_once('admin.php');
     3require( 'includes/dashboard.php' );
    34require_once (ABSPATH . WPINC . '/rss.php');
    45
    56@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    67
    7 $widgets = get_option( 'dashboard_widget_options' );
    8 
    9 
    108switch ( $_GET['jax'] ) {
    119
    1210case 'incominglinks' :
    13 @extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
    14 $rss = @fetch_rss( $url );
    15 if ( isset($rss->items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results
    16 ?>
    17 
    18 <ul>
    19 <?php
    20 $rss->items = array_slice($rss->items, 0, $items);
    21 foreach ($rss->items as $item ) {
    22     $publisher = '';
    23     $site_link = '';
    24     $link = '';
    25     $content = '';
    26     $date = '';
    27     $link = clean_url( strip_tags( $item['link'] ) );
    28 
    29     if ( isset( $item['author_uri'] ) )
    30         $site_link = clean_url( strip_tags( $item['author_uri'] ) );
    31 
    32     if ( !$publisher = wp_specialchars( strip_tags( isset($item['dc']['publisher']) ? $item['dc']['publisher'] : $item['author_name'] ) ) )
    33         $publisher = __( 'Somebody' );
    34     if ( $site_link )
    35         $publisher = "<a href='$site_link'>$publisher</a>";
    36     else
    37         $publisher = "<strong>$publisher</strong>";
    38 
    39     if ( isset($item['description']) )
    40         $content = $item['description'];
    41     elseif ( isset($item['summary']) )
    42         $content = $item['summary'];
    43     elseif ( isset($item['atom_content']) )
    44         $content = $item['atom_content'];
    45     else
    46         $content = __( 'something' );
    47     $content = strip_tags( $content );
    48     if ( 50 < strlen($content) )
    49         $content = substr($content, 0, 50) . ' ...';
    50     $content = wp_specialchars( $content );
    51     if ( $link )
    52         $text = _c( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"|feed_display' );
    53     else
    54         $text = _c( '%1$s linked here saying, "%3$s"|feed_display' );
    55 
    56     if ( $show_date ) {
    57         if ( $show_author || $show_summary )
    58             $text .= _c( ' on %4$s|feed_display' );
    59         $date = wp_specialchars( strip_tags( isset($item['pubdate']) ? $item['pubdate'] : $item['published'] ) );
    60         $date = strtotime( $date );
    61         $date = gmdate( get_option( 'date_format' ), $date );
    62     }
    63 
    64 ?>
    65     <li><?php printf( _c( "$text|feed_display" ), $publisher, $link, $content, $date ); ?></li>
    66 <?php } ?>
    67 </ul>
    68 <?php
    69 } else {
    70 ?>
    71 <p><?php _e('No incoming links found... yet.'); ?></p>
    72 <?php
    73 }
    74 break;
     11    wp_dashboard_incoming_links_output();
     12    break;
    7513
    7614case 'devnews' :
    77 wp_widget_rss_output( $widgets['dashboard_primary'] );
    78 break;
     15    wp_dashboard_rss_output( 'dashboard_primary' );
     16    break;
    7917
    8018case 'planetnews' :
    81 extract( $widgets['dashboard_secondary'], EXTR_SKIP );
    82 $rss = @fetch_rss( $url );
    83 if ( isset($rss->items) && 0 != count($rss->items) ) {
    84 ?>
    85 <ul>
    86 <?php
    87 $rss->items = array_slice($rss->items, 0, $items);
    88 foreach ($rss->items as $item ) {
    89 $title = wp_specialchars($item['title']);
    90 $author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] );
    91 $post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] );
    92 ?>
    93 <li><a href='<?php echo wp_filter_kses($item['link']); ?>'><span class="post"><?php echo $post; ?></span><span class="hidden"> - </span><cite><?php echo $author; ?></cite></a></li>
    94 <?php
    95     }
    96 ?>
    97 </ul>
    98 <br class="clear" />
    99 <?php
    100 }
    101 break;
     19    wp_dashboard_secondary_output();
     20    break;
    10221
    10322case '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;
     23    wp_dashboard_plugins_output();
     24    break;
    14925
    15026}
Note: See TracChangeset for help on using the changeset viewer.