WordPress.org

Make WordPress Core

Changeset 6705


Ignore:
Timestamp:
02/02/2008 07:57:51 AM (10 years ago)
Author:
ryan
Message:

New dashboard from mdawaffe. see #5750

Location:
trunk
Files:
1 added
7 edited

Legend:

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

    r6385 r6705  
    252252    populate_roles_210();
    253253    populate_roles_230();
     254    populate_roles_250();
    254255}
    255256
     
    391392}
    392393
     394function populate_roles_250() {
     395    $role = get_role( 'administrator' );
     396
     397    if ( !empty( $role ) ) {
     398        $role->add_cap( 'edit_dashboard' );
     399    }
     400}
     401
    393402?>
  • trunk/wp-admin/includes/upgrade.php

    r6385 r6705  
    198198    if ( $wp_current_db_version < 6124 )
    199199        upgrade_230_old_tables();
     200
     201    if ( $wp_current_db_version < 6689 )
     202        upgrade_250();
    200203
    201204    maybe_disable_automattic_widgets();
     
    716719}
    717720
     721
     722function upgrade_250() {
     723    global $wp_current_db_version;
     724
     725    if ( $wp_current_db_version < 6689 ) {
     726        populate_roles_250();
     727    }
     728}
    718729
    719730// The functions we use to actually do stuff
  • trunk/wp-admin/index-extra.php

    r6431 r6705  
    55@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    66
     7$widgets = get_option( 'dashboard_widget_options' );
     8
     9
    710switch ( $_GET['jax'] ) {
    811
    912case 'incominglinks' :
    10 
    11 $rss_feed = apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) );
    12 
    13 
    14 $rss = @fetch_rss( $rss_feed );
     13@extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
     14$rss = @fetch_rss( $url );
    1515if ( isset($rss->items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results
    1616?>
     
    1818<ul>
    1919<?php
    20 $rss->items = array_slice($rss->items, 0, 10);
     20$rss->items = array_slice($rss->items, 0, $items);
    2121foreach ($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
    2264?>
    23     <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wptexturize(wp_specialchars($item['title'])); ?></a></li>
     65    <li><?php printf( _c( "$text|feed_display" ), $publisher, $link, $content, $date ); ?></li>
    2466<?php } ?>
    2567</ul>
     
    3375
    3476case 'devnews' :
    35 $rss = @fetch_rss(apply_filters( 'dashboard_primary_feed', 'http://wordpress.org/development/feed/' ));
    36 if ( isset($rss->items) && 0 != count($rss->items) ) {
    37 
    38 $rss->items = array_slice($rss->items, 0, 2);
    39 foreach ($rss->items as $item ) {
    40 ?>
    41 <h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> <?php gmdate( 'Y/m/d', strtotime( $item['pubdate'] ) ); ?></h4>
    42 <p><?php echo $item['description']; ?></p>
    43 <?php
    44     }
    45 }
    46 ?>
    47 
    48 <?php
     77wp_widget_rss_output( $widgets['dashboard_primary'] );
    4978break;
    5079
    5180case 'planetnews' :
    52 $rss = @fetch_rss(apply_filters( 'dashboard_secondary_feed', 'http://planet.wordpress.org/feed/' ));
     81extract( $widgets['dashboard_secondary'], EXTR_SKIP );
     82$rss = @fetch_rss( $url );
    5383if ( isset($rss->items) && 0 != count($rss->items) ) {
    5484?>
    55 <h3><?php echo apply_filters( 'dashboard_secondary_title', __('Other WordPress News') ); ?></h3>
    5685<ul>
    5786<?php
    58 $rss->items = array_slice($rss->items, 0, 20);
     87$rss->items = array_slice($rss->items, 0, $items);
    5988foreach ($rss->items as $item ) {
    6089$title = wp_specialchars($item['title']);
     
    6796?>
    6897</ul>
    69 <p class="readmore"><a href="<?php echo apply_filters( 'dashboard_secondary_link', 'http://planet.wordpress.org/' ); ?>"><?php _e('Read more &raquo;'); ?></a></p>
    7098<?php
    7199}
  • trunk/wp-admin/index.php

    r6484 r6705  
    11<?php
     2
    23require_once('admin.php');
     4
     5require( './includes/dashboard.php' );
     6
     7wp_dashboard_setup();
    38
    49function index_js() {
     
    611<script type="text/javascript">
    712    jQuery(function() {
    8         jQuery('#incominglinks').load('index-extra.php?jax=incominglinks');
    9         jQuery('#devnews').load('index-extra.php?jax=devnews');
    10 //      jQuery('#planetnews').load('index-extra.php?jax=planetnews');
     13        jQuery('#dashboard_incoming_links div.dashboard-widget-content').not( '.dashboard-widget-control' ).load('index-extra.php?jax=incominglinks');
     14        jQuery('#dashboard_primary div.dashboard-widget-content').not( '.dashboard-widget-control' ).load('index-extra.php?jax=devnews');
     15        jQuery('#dashboard_secondary div.dashboard-widget-content').not( '.dashboard-widget-control' ).load('index-extra.php?jax=planetnews');
     16        jQuery('#dashboard_plugins div.dashboard-widget-content').not( '.dashboard-widget-control' ).html( 'TODO' );
    1117    });
    1218</script>
     
    7884?>
    7985<p><?php printf( __( 'You are using %1$s theme with %2$s.' ), $ct->title, "<a href='widgets.php'>$widgets_text</a>" ); ?> <a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a> You're using BetaPress TODO.</p>
    80 <p>
    8186<?php do_action( 'rightnow_end' ); ?>
    8287<?php do_action( 'activity_box_end' ); ?>
    83 </div>
     88</div><!-- rightnow -->
    8489
    85 <div id="dashboard-widgets">
     90<?php wp_dashboard(); ?>
    8691
    87 <div class="dashboard-widget">
    88 <div class="dashboard-widget-edit"><a href=""><?php _e('See All'); ?></a> | <a href=""><?php _e('Edit'); ?></a></div>
    89 <h3>Recent Comments</h3>
     92</div><!-- wrap -->
    9093
    91 <?php
    92 $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5");
    93 $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
    94 
    95 if ( $comments || $numcomments ) :
    96 ?>
    97 
    98 <?php if ( $numcomments ) : ?>
    99 <p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s) &raquo;'), number_format_i18n($numcomments) ); ?></a></strong></p>
    100 <?php endif; ?>
    101 
    102 <ul>
    103 <?php
    104 if ( $comments ) {
    105 foreach ($comments as $comment) {
    106     echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
    107     edit_comment_link(__("Edit"), ' <small>(', ')</small>');
    108     echo '</li>';
    109 }
    110 }
    111 ?>
    112 </ul>
    113 <?php endif; ?>
    114 </div>
    115 
    116 
    117 <div class="dashboard-widget">
    118 <?php
    119 $more_link = apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) );
    120 ?>
    121 <div class="dashboard-widget-edit"><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('See All'); ?></a> | <a href=""><?php _e('Edit'); ?></a></div>
    122 <h3><?php _e('Incoming Links'); ?></h3>
    123 
    124 <div id="incominglinks"></div>
    125 </div>
    126 
    127 <div class="dashboard-widget">
    128 <?php
    129 $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5");
    130 ?>
    131 <div class="dashboard-widget-edit"><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('See All'); ?></a> | <a href=""><?php _e('Edit'); ?></a></div>
    132 <h3>Recent Posts</h3>
    133 
    134 <ul>
    135 <?php
    136 foreach ($recentposts as $post) {
    137     if ($post->post_title == '')
    138         $post->post_title = sprintf(__('Post #%s'), $post->ID);
    139     echo "<li><a href='post.php?action=edit&amp;post=$post->ID'>";
    140     the_title();
    141     echo '</a></li>';
    142 }
    143 ?>
    144 </ul>
    145 </div>
    146 
    147 <div class="dashboard-widget">
    148 <div class="dashboard-widget-edit"><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('See All'); ?></a> | <a href=""><?php _e('Edit'); ?></a> | <a href=""><?php _e('RSS'); ?></a></div>
    149 <h3><?php echo apply_filters( 'dashboard_primary_title', __('Blog') ); ?></h3>
    150 
    151 <div id="devnews"></div>
    152 </div>
    153 
    154 <?php do_action( 'dashboard_widgets' ); ?>
    155 
    156 <p><a href=""><?php _e('Customize this page'); ?></a>.</p>
    157 
    158 </div>
    159 
    160 
    161 <div id="planetnews"></div>
    162 
    163 <div style="clear: both">&nbsp;
    164 <br clear="all" />
    165 </div>
    166 </div>
    167 
    168 <?php
    169 require('./admin-footer.php');
    170 ?>
     94<?php require('./admin-footer.php'); ?>
  • trunk/wp-admin/wp-admin.css

    r6694 r6705  
    10181018    color: #999;
    10191019    position: relative;
    1020     margin-top: -75px;
     1020//  margin-top: -75px;
    10211021}
    10221022
  • trunk/wp-includes/version.php

    r6554 r6705  
    1717 * @global int $wp_db_version
    1818 */
    19 $wp_db_version = 6124;
     19$wp_db_version = 6689;
    2020
    2121?>
  • trunk/wp-includes/widgets.php

    r6687 r6705  
    222222    $did_one = false;
    223223    foreach ( $sidebars_widgets[$index] as $id ) {
    224         $callback = $wp_registered_widgets[$id]['callback'];
    225 
    226         $params = array_merge(array($sidebar), (array) $wp_registered_widgets[$id]['params']);
     224        $params = array_merge(
     225            array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
     226            (array) $wp_registered_widgets[$id]['params']
     227        );
    227228
    228229        // Substitute HTML id and class attributes into before_widget
     
    236237        $classname_ = ltrim($classname_, '_');
    237238        $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_);
     239
     240        $params = apply_filters( 'dynamic_sidebar_params', $params );
     241
     242        $callback = $wp_registered_widgets[$id]['callback'];
    238243
    239244        if ( is_callable($callback) ) {
     
    10041009        return;
    10051010
    1006     $num_items = (int) $options[$number]['items'];
    1007     $show_summary = $options[$number]['show_summary'];
    1008     if ( empty($num_items) || $num_items < 1 || $num_items > 10 ) $num_items = 10;
    10091011    $url = $options[$number]['url'];
    10101012    while ( strstr($url, 'http') != $url )
     
    10331035        $icon = get_option('siteurl').'/wp-includes/images/rss.png';
    10341036    $title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>";
    1035 ?>
    1036         <?php echo $before_widget; ?>
    1037             <?php $title ? print($before_title . $title . $after_title) : null; ?>
    1038 <?php
     1037
     1038    echo $before_widget;
     1039    echo $before_title . $title . $after_title;
     1040
     1041    wp_widget_rss_output( $rss, $options[$number] );
     1042
     1043    echo $after_widget;
     1044}
     1045
     1046function wp_widget_rss_output( $rss, $args = null ) {
     1047    if ( is_string( $rss ) ) {
     1048        require_once(ABSPATH . WPINC . '/rss.php');
     1049        if ( !$rss = fetch_rss($rss) )
     1050            return;
     1051    } elseif ( is_array($rss) && isset($rss['url']) ) {
     1052        require_once(ABSPATH . WPINC . '/rss.php');
     1053        $args = $rss;
     1054        if ( !$rss = fetch_rss($rss['url']) )
     1055            return;
     1056    } elseif ( !is_object($rss) ) {
     1057        return;
     1058    }
     1059
     1060    extract( $args, EXTR_SKIP );
     1061
     1062    $items = (int) $items;
     1063    if ( $items < 1 || 20 < $items )
     1064        $items = 10;
     1065    $show_summary  = (int) $show_summary;
     1066    $show_author   = (int) $show_author;
     1067    $show_date     = (int) $show_date;
     1068
    10391069    if ( is_array( $rss->items ) && !empty( $rss->items ) ) {
    1040         $rss->items = array_slice($rss->items, 0, $num_items);
     1070        $rss->items = array_slice($rss->items, 0, $items);
    10411071        echo '<ul>';
    10421072        foreach ($rss->items as $item ) {
     
    10481078                $title = __('Untitled');
    10491079            $desc = '';
    1050             if ( $show_summary ) {
    1051                 $summary = '<div class="rssSummary">' . $item['description'] . '</div>';
    1052             } else {
    10531080                if ( isset( $item['description'] ) && is_string( $item['description'] ) )
    10541081                    $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
     1082                elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
     1083                    $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES))));
     1084
     1085            $summary = '';
     1086            if ( isset( $item['description'] ) && is_string( $item['description'] ) )
     1087                $summary = $item['description'];
     1088            elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
     1089                $summary = $item['summary'];
     1090
     1091            $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($summary, ENT_QUOTES))));
     1092
     1093            if ( $show_summary ) {
     1094                $desc = '';
     1095                $summary = wp_specialchars( $summary );
     1096                $summary = "<div class='rssSummary'>$summary</div>";
     1097            } else {
    10551098                $summary = '';
    10561099            }
    1057             echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
     1100
     1101            $date = '';
     1102            if ( $show_date ) {
     1103                if ( isset($item['pubdate']) )
     1104                    $date = $item['pubdate'];
     1105                elseif ( isset($item['published']) )
     1106                    $date = $item['published'];
     1107
     1108                if ( $date ) {
     1109                    if ( $date_stamp = strtotime( $date ) )
     1110                        $date = '<span class="rss-date">' . gmdate( get_option( 'date_format' ), $date_stamp ) . '</span>';
     1111                    else
     1112                        $date = '';
     1113                }
     1114            }
     1115
     1116            $author = '';
     1117            if ( $show_author ) {
     1118                if ( isset($item['dc']['creator']) )
     1119                    $author = ' <cite>' . wp_specialchars( strip_tags( $item['dc']['creator'] ) ) . '</cite>';
     1120                elseif ( isset($item['author_name']) )
     1121                    $author = ' <cite>' . wp_specialchars( strip_tags( $item['author_name'] ) ) . '</cite>';
     1122            }
     1123
     1124            echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
    10581125        }
    10591126        echo '</ul>';
     
    10611128        echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
    10621129    }
    1063 
    1064     echo $after_widget;
    10651130}
    10661131
     
    10831148            $urls[$option['url']] = true;
    10841149
    1085     if ( !$updated && !empty($_POST['sidebar']) ) {
     1150    if ( !$updated && 'POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['sidebar']) ) {
    10861151        $sidebar = (string) $_POST['sidebar'];
    10871152
     
    11001165
    11011166        foreach( (array) $_POST['widget-rss'] as $widget_number => $widget_rss ) {
    1102             $items = (int) $widget_rss['items'];
    1103             if ( $items < 1 )
    1104                 $items = 10;
    1105             $url = sanitize_url(strip_tags(stripslashes($widget_rss['url'])));
    1106             $title = trim(strip_tags(stripslashes($widget_rss['title'])));
    1107 
    1108             if ( !isset($urls[$url]) ) {
    1109                 require_once(ABSPATH . WPINC . '/rss.php');
    1110                 $rss = fetch_rss($url);
    1111                 $error = false;
    1112                 if ( !is_object($rss) ) {
    1113                     $url = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1);
    1114                     $error = sprintf(__('Error in RSS %1$d'), $widget_number );
    1115                 }
    1116             }
    1117             $options[$widget_number] = compact( 'title', 'url', 'items', 'error' );
     1167            $widget_rss = stripslashes_deep( $widget_rss );
     1168            $url = sanitize_url(strip_tags($widget_rss['url']));
     1169            $options[$widget_number] = wp_widget_rss_process( $widget_rss, !isset($urls[$url]) );
    11181170        }
    11191171
     
    11281180        $error = false;
    11291181        $number = '%i%';
     1182        $show_summary = 0;
     1183        $show_author = 0;
     1184        $show_date = 0;
    11301185    } else {
    1131         $title = attribute_escape($options[$number]['title']);
    1132         $url = attribute_escape($options[$number]['url']);
    1133         $items = (int) $options[$number]['items'];
    1134         if ( $items < 1 )
    1135             $items = 10;
    1136         $error = $options[$number]['error'];
    1137     }
    1138 
    1139 ?>
    1140             <p>
    1141                 <label for="rss-url-<?php echo $number; ?>"><?php _e('Enter the RSS feed URL here:'); ?>
    1142                     <input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>" />
    1143                 </label>
    1144             </p>
    1145             <p>
    1146                 <label for="rss-title-<?php echo $number; ?>"><?php _e('Give the feed a title (optional):'); ?>
    1147                     <input class="widefat" id="rss-title-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" />
    1148                 </label>
    1149             </p>
    1150             <p>
    1151                 <label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?>
    1152                     <select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]">
    1153                         <?php
    1154                             for ( $i = 1; $i <= 10; ++$i )
    1155                                 echo "<option value='$i' " . ( $items == $i ? "selected='selected'" : '' ) . ">$i</option>";
    1156                         ?>
    1157                     </select>
    1158                 </label>
    1159             </p>
    1160             <input type="hidden" id="rss-submit-<?php echo $number; ?>" name="rss-submit-<?php echo $number; ?>" value="1" />
    1161 <?php
     1186        extract( $options[$number] );
     1187    }
     1188
     1189    wp_widget_rss_form( compact( 'number', 'title', 'url', 'items', 'error', 'show_summary', 'show_author', 'show_date' ) );
     1190}
     1191
     1192function wp_widget_rss_form( $args, $inputs = null ) {
     1193    $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
     1194    $inputs = wp_parse_args( $inputs, $default_inputs );
     1195    extract( $args );
     1196    $number = attribute_escape( $number );
     1197    $title  = attribute_escape( $title );
     1198    $url    = attribute_escape( $url );
     1199    $items  = (int) $items;
     1200    if ( $items < 1 || 20 < $items )
     1201        $items  = 10;
     1202    $show_summary   = (int) $show_summary;
     1203    $show_author    = (int) $show_author;
     1204    $show_date      = (int) $show_date;
     1205
     1206    if ( $inputs['url'] ) :
     1207?>
     1208    <p>
     1209        <label for="rss-url-<?php echo $number; ?>"><?php _e('Enter the RSS feed URL here:'); ?>
     1210            <input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>" />
     1211        </label>
     1212    </p>
     1213<?php endif; if ( $inputs['title'] ) : ?>
     1214    <p>
     1215        <label for="rss-title-<?php echo $number; ?>"><?php _e('Give the feed a title (optional):'); ?>
     1216            <input class="widefat" id="rss-title-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" />
     1217        </label>
     1218    </p>
     1219<?php endif; if ( $inputs['items'] ) : ?>
     1220    <p>
     1221        <label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?>
     1222            <select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]">
     1223                <?php
     1224                    for ( $i = 1; $i <= 20; ++$i )
     1225                        echo "<option value='$i' " . ( $items == $i ? "selected='selected'" : '' ) . ">$i</option>";
     1226                ?>
     1227            </select>
     1228        </label>
     1229    </p>
     1230<?php endif; if ( $inputs['show_summary'] ) : ?>
     1231    <p>
     1232        <label for="rss-show-summary-<?php echo $number; ?>">
     1233            <input id="rss-show-summary-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_summary]" type="checkbox" value="1" <?php if ( $show_summary ) echo 'checked="checked"'; ?>/>
     1234            <?php _e('Display item content?'); ?>
     1235        </label>
     1236    </p>
     1237<?php endif; if ( $inputs['show_author'] ) : ?>
     1238    <p>
     1239        <label for="rss-show-author-<?php echo $number; ?>">
     1240            <input id="rss-show-author-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_author]" type="checkbox" value="1" <?php if ( $show_author ) echo 'checked="checked"'; ?>/>
     1241            <?php _e('Display item author if available?'); ?>
     1242        </label>
     1243    </p>
     1244<?php endif; if ( $inputs['show_date'] ) : ?>
     1245    <p>
     1246        <label for="rss-show-date-<?php echo $number; ?>">
     1247            <input id="rss-show-date-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_date]" type="checkbox" value="1" <?php if ( $show_date ) echo 'checked="checked"'; ?>/>
     1248            <?php _e('Display item date?'); ?>
     1249        </label>
     1250    </p>
     1251    <input type="hidden" id="rss-submit-<?php echo $number; ?>" name="rss-submit-<?php echo $number; ?>" value="1" />
     1252<?php
     1253    endif;
     1254    foreach ( array_keys($default_inputs) as $input ) :
     1255        if ( 'hidden' === $inputs[$input] ) :
     1256            $id = str_replace( '_', '-', $input );
     1257?>
     1258    <input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][<?php echo $input; ?>]" value="<?php echo $$input; ?>" />
     1259<?php
     1260        endif;
     1261    endforeach;
     1262}
     1263
     1264// Expects unescaped data
     1265function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
     1266    $items = (int) $widget_rss['items'];
     1267    if ( $items < 1 || 20 < $items )
     1268        $items = 10;
     1269    $url           = sanitize_url(strip_tags( $widget_rss['url'] ));
     1270    $title         = trim(strip_tags( $widget_rss['title'] ));
     1271    $show_summary  = (int) $widget_rss['show_summary'];
     1272    $show_author   = (int) $widget_rss['show_author'];
     1273    $show_date     = (int) $widget_rss['show_date'];
     1274
     1275    if ( $check_feed ) {
     1276        require_once(ABSPATH . WPINC . '/rss.php');
     1277        $rss = fetch_rss($url);
     1278        $error = false;
     1279        $link = '';
     1280        if ( !is_object($rss) ) {
     1281            $url = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1);
     1282            $error = sprintf(__('Error in RSS %1$d'), $widget_number );
     1283        } else {
     1284            $link = clean_url(strip_tags($rss->channel['link']));
     1285            while ( strstr($link, 'http') != $link )
     1286                $link = substr($link, 1);           
     1287        }
     1288    }
     1289
     1290    return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
    11621291}
    11631292
Note: See TracChangeset for help on using the changeset viewer.