'widget_recent_entries', 'description' => __( "The most recent posts on your blog") ); $this->WP_Widget('recent-posts', __('Recent Posts'), $widget_ops); $this->alt_option_name = 'widget_recent_entries'; add_action( 'save_post', array(&$this, 'flush_widget_cache') ); add_action( 'deleted_post', array(&$this, 'flush_widget_cache') ); add_action( 'switch_theme', array(&$this, 'flush_widget_cache') ); } function widget($args, $instance) { $cache = wp_cache_get('widget_recent_posts', 'widget'); if ( !is_array($cache) ) $cache = array(); if ( isset($cache[$args['widget_id']]) ) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title']); if ( !$number = (int) $instance['number'] ) $number = 10; else if ( $number < 1 ) $number = 1; else if ( $number > 15 ) $number = 15; $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); if ($r->have_posts()) : ?> flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['widget_recent_entries']) ) delete_option('widget_recent_entries'); return $instance; } function flush_widget_cache() { wp_cache_delete('widget_recent_posts', 'widget'); } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; if ( !isset($instance['number']) || !$number = (int) $instance['number'] ) $number = 5; ?>


'', 'count' => $this->count, 'hierarchical' => $this->hierarchical, 'dropdown' => $this->dropdown ); if ( !empty($_POST['ace-recent-posts-submit']) ) { $options['title'] = trim(strip_tags(stripslashes($_POST['ace-recent-posts-title']))); $options['number'] = (int) $_POST['ace-recent-posts-number']; if ($options['number'] > 15) $options['number'] = 15;//The limit update_option('ace_widget_recent_posts', $options); } $title = attribute_escape( $options['title'] ); $number = (int) $options['number']; ?>


'', 'number' => $this->number ); $cats_to_exclude = ''; $title = empty($options['title']) ? __('Recent Posts') : apply_filters('widget_title', $options['title']); $number = $options['number']; /* Here comes ACE patch ;) */ /** * If we got categories to exclude, we want negative values of them * because WP_Query requires negative values, in a comma separeted list * to the 'cat' value. */ if (!empty($cats_to_exclude)) { $cats = array(); foreach(explode(',',$cats_to_exclude) as $category ) { $cats[]=0-$category; } /** * Yes, we overwrite here. */ $cats_to_exclude = implode(",",$cats); } /** * Suppress filters is IMPORTANT * * This widget now is better than the original. * Not joking ;) */ $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish','cat'=>$cats_to_exclude,'suppress_filters'=>1)); if ($r->have_posts()) : ?>