'widget_twentyeleven_ephemera', 'description' => __( 'Use this widget to list your recent Aside, Status, Quote, and Link posts', 'twentyeleven' ), 'customize_selective_refresh' => true, ) ); $this->alt_option_name = 'widget_twentyeleven_ephemera'; 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' ) ); } /** * PHP4 constructor. * * @since Twenty Eleven 1.0 * @deprecated Twenty Eleven 2.2 */ public function Twenty_Eleven_Ephemera_Widget() { self::__construct(); } /** * Outputs the HTML for this widget. * * @since Twenty Eleven 1.0 * * @param array $args An array of standard parameters for widgets in this theme. * @param array $instance An array of settings for this widget instance. */ public function widget( $args, $instance ) { $cache = wp_cache_get( 'widget_twentyeleven_ephemera', 'widget' ); if ( ! is_array( $cache ) ) { $cache = array(); } if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = null; } if ( ! is_customize_preview() && isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } ob_start(); /** This filter is documented in wp-includes/default-widgets.php */ $args['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Ephemera', 'twentyeleven' ) : $instance['title'], $instance, $this->id_base ); if ( ! isset( $instance['number'] ) ) { $instance['number'] = '10'; } $args['number'] = absint( $instance['number'] ); if ( ! $args['number'] ) { $args['number'] = 10; } $ephemera_args = array( 'order' => 'DESC', 'posts_per_page' => $args['number'], 'no_found_rows' => true, 'post_status' => 'publish', 'post__not_in' => get_option( 'sticky_posts' ), 'tax_query' => array( array( 'taxonomy' => 'post_format', 'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-status', 'post-format-quote' ), 'field' => 'slug', 'operator' => 'IN', ), ), ); $ephemera = new WP_Query( $ephemera_args ); if ( $ephemera->have_posts() ) : echo $args['before_widget']; echo $args['before_title']; echo $args['title']; echo $args['after_title']; ?>
    have_posts() ) : $ephemera->the_post(); ?>
  1. comments →', 'twentyeleven' ), __( '1 comment →', 'twentyeleven' ), __( '% comments →', 'twentyeleven' ) ); ?>
  2.   comments →', 'twentyeleven' ), __( '1 comment →', 'twentyeleven' ), __( '% comments →', 'twentyeleven' ) ); ?>
flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset( $alloptions['widget_twentyeleven_ephemera'] ) ) { delete_option( 'widget_twentyeleven_ephemera' ); } return $instance; } /** * Flush widget cache. * * @since Twenty Eleven 1.0 */ public function flush_widget_cache() { wp_cache_delete( 'widget_twentyeleven_ephemera', 'widget' ); } /** * Set up the widget form. * * Displays the form for this widget on the Widgets page of the WP Admin area. * * @since Twenty Eleven 1.0 * * @param array $instance The settings for the particular instance of the widget. */ public function form( $instance ) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 10; ?>