'widget_twentyfourteen_ephemera', 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts', 'twentyfourteen' ), ) ); /* * @todo http://core.trac.wordpress.org/ticket/23257: Add plural versions of Post Format strings */ $this->format_strings = array( 'aside' => __( 'Asides', 'twentyfourteen' ), 'image' => __( 'Images', 'twentyfourteen' ), 'video' => __( 'Videos', 'twentyfourteen' ), 'audio' => __( 'Audio', 'twentyfourteen' ), 'quote' => __( 'Quotes', 'twentyfourteen' ), 'link' => __( 'Links', 'twentyfourteen' ), 'gallery' => __( 'Galleries', 'twentyfourteen' ), ); 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' ) ); } /** * Output the HTML for this widget. * * @since Twenty Fourteen 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. * @return void Echoes its output. */ public function widget( $args, $instance ) { // If called directly, assign an unique index for caching. if ( -1 == $this->number ) { static $num = -1; $this->_set( --$num ); } $content = get_transient( $this->id ); if ( false !== $content ) { echo $content; return; } ob_start(); extract( $args, EXTR_SKIP ); $format = $instance['format']; $number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $this->format_strings[ $format ] : $instance['title'], $instance, $this->id_base ); $ephemera = new WP_Query( array( 'order' => 'DESC', 'posts_per_page' => $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-$format" ), 'field' => 'slug', 'operator' => 'IN', ), ), ) ); if ( $ephemera->have_posts() ) : $tmp_content_width = $GLOBALS['content_width']; $GLOBALS['content_width'] = 306; echo $before_widget; ?>