'widget_twentyfourteen_ephemera', 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ), 'customize_selective_refresh' => true, ) ); if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); } } /** * Enqueue scripts. * * @since Twenty Fourteen 1.7 */ public function enqueue_scripts() { /** This filter is documented in wp-includes/media.php */ $audio_library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' ); /** This filter is documented in wp-includes/media.php */ $video_library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' ); if ( in_array( 'mediaelement', array( $video_library, $audio_library ), true ) ) { wp_enqueue_style( 'wp-mediaelement' ); wp_enqueue_script( 'mediaelement-vimeo' ); wp_enqueue_script( 'wp-mediaelement' ); } } /** * Output the HTML for this widget. * * @access public * @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. */ public function widget( $args, $instance ) { $format = isset( $instance['format'] ) && in_array( $instance['format'], $this->formats ) ? $instance['format'] : 'aside'; switch ( $format ) { case 'image': $format_string = __( 'Images', 'twentyfourteen' ); $format_string_more = __( 'More images', 'twentyfourteen' ); break; case 'video': $format_string = __( 'Videos', 'twentyfourteen' ); $format_string_more = __( 'More videos', 'twentyfourteen' ); break; case 'audio': $format_string = __( 'Audio', 'twentyfourteen' ); $format_string_more = __( 'More audio', 'twentyfourteen' ); break; case 'quote': $format_string = __( 'Quotes', 'twentyfourteen' ); $format_string_more = __( 'More quotes', 'twentyfourteen' ); break; case 'link': $format_string = __( 'Links', 'twentyfourteen' ); $format_string_more = __( 'More links', 'twentyfourteen' ); break; case 'gallery': $format_string = __( 'Galleries', 'twentyfourteen' ); $format_string_more = __( 'More galleries', 'twentyfourteen' ); break; case 'aside': default: $format_string = __( 'Asides', 'twentyfourteen' ); $format_string_more = __( 'More asides', 'twentyfourteen' ); break; } $number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $format_string : $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 $args['before_widget']; ?>