function widget( $args, $instance ) {
extract($args);
- $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
- $text = apply_filters( 'widget_text', $instance['text'] );
+ $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );
+ $text = apply_filters( 'widget_text', $instance['text'], $instance );
echo $before_widget;
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
<div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
if ( current_user_can('unfiltered_html') )
$instance['text'] = $new_instance['text'];
else
- $instance['text'] = wp_filter_post_kses( $new_instance['text'] );
+ $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
$instance['filter'] = isset($new_instance['filter']);
return $instance;
}
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
- <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked($instance['filter']); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs.'); ?></label></p>
+ <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs.'); ?></label></p>
<?php
}
}
//Defaults
$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
$title = esc_attr( $instance['title'] );
- $count = (bool) $instance['count'];
- $hierarchical = (bool) $instance['hierarchical'];
- $dropdown = (bool) $instance['dropdown'];
+ $count = isset($instance['count']) ? (bool) $instance['count'] :false;
+ $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
+ $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
}
function form( $instance ) {
- $title = esc_attr($instance['title']);
- if ( !$number = (int) $instance['number'] )
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
+ if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
$number = 5;
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
add_action( 'wp_head', array(&$this, 'recent_comments_style') );
add_action( 'comment_post', array(&$this, 'flush_widget_cache') );
- add_action( 'wp_set_comment_status', array(&$this, 'flush_widget_cache') );
+ add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') );
}
function recent_comments_style() { ?>
$number = 15;
if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15");
+ $comments = $wpdb->get_results("SELECT $wpdb->comments.* FROM $wpdb->comments JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_status = 'publish' ORDER BY comment_date_gmt DESC LIMIT 15");
wp_cache_add( 'recent_comments', $comments, 'widget' );
}
echo $before_title . $title . $after_title;
wp_widget_rss_output( $rss, $instance );
echo $after_widget;
+ $rss->__destruct();
+ unset($rss);
}
function update($new_instance, $old_instance) {
if ( is_wp_error($rss) ) {
if ( is_admin() || current_user_can('manage_options') )
echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
-
return;
}
if ( !$rss->get_item_quantity() ) {
echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
+ $rss->__destruct();
+ unset($rss);
return;
}
}
}
echo '</ul>';
+ $rss->__destruct();
+ unset($rss);
}
$link = esc_url(strip_tags($rss->get_permalink()));
while ( stristr($link, 'http') != $link )
$link = substr($link, 1);
+
+ $rss->__destruct();
+ unset($rss);
}
}
function form( $instance ) {
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" /></p>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
<?php
}
}