-function wp_widget_recent_comments_register() {
- $dims = array('width' => 320, 'height' => 90);
- $class = array('classname' => 'widget_recent_comments');
- wp_register_sidebar_widget('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments', $class);
- wp_register_widget_control('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments_control', $dims);
-
- if ( is_active_widget('wp_widget_recent_comments') )
- add_action('wp_head', 'wp_widget_recent_comments_style');
-}
-
-function wp_widget_rss($args, $number = 1) {
- require_once(ABSPATH . WPINC . '/rss.php');
- extract($args);
- $options = get_option('widget_rss');
- if ( isset($options['error']) && $options['error'] )
- return;
- $num_items = (int) $options[$number]['items'];
- $show_summary = $options[$number]['show_summary'];
- if ( empty($num_items) || $num_items < 1 || $num_items > 10 ) $num_items = 10;
- $url = $options[$number]['url'];
- while ( strstr($url, 'http') != $url )
- $url = substr($url, 1);
- if ( empty($url) )
- return;
- $rss = fetch_rss($url);
- $link = clean_url(strip_tags($rss->channel['link']));
- while ( strstr($link, 'http') != $link )
- $link = substr($link, 1);
- $desc = attribute_escape(strip_tags(html_entity_decode($rss->channel['description'], ENT_QUOTES)));
- $title = $options[$number]['title'];
- if ( empty($title) )
- $title = htmlentities(strip_tags($rss->channel['title']));
- if ( empty($title) )
- $title = $desc;
- if ( empty($title) )
- $title = __('Unknown Feed');
- $url = clean_url(strip_tags($url));
- if ( file_exists(dirname(__FILE__) . '/rss.png') )
- $icon = str_replace(ABSPATH, get_option('siteurl').'/', dirname(__FILE__)) . '/rss.png';
- else
- $icon = get_option('siteurl').'/wp-includes/images/rss.png';
- $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>";
-?>
- <?php echo $before_widget; ?>
- <?php $title ? print($before_title . $title . $after_title) : null; ?>
-<?php
- if ( is_array( $rss->items ) && !empty( $rss->items ) ) {
- $rss->items = array_slice($rss->items, 0, $num_items);
- echo '<ul>';
- foreach ($rss->items as $item ) {
- while ( strstr($item['link'], 'http') != $item['link'] )
- $item['link'] = substr($item['link'], 1);
- $link = clean_url(strip_tags($item['link']));
- $title = attribute_escape(strip_tags($item['title']));
- if ( empty($title) )
- $title = __('Untitled');
- $desc = '';
- if ( $show_summary ) {
- $summary = '<div class="rssSummary">' . $item['description'] . '</div>';
- } else {
- if ( isset( $item['description'] ) && is_string( $item['description'] ) )
- $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
- $summary = '';
- }
- echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
- }
- echo '</ul>';
- } else {
- echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';