diff -r 490d5cc509ed -r cf61fcea0001 wp/wp-content/themes/twentyfourteen/inc/widgets.php --- a/wp/wp-content/themes/twentyfourteen/inc/widgets.php Tue Jun 09 11:14:17 2015 +0000 +++ b/wp/wp-content/themes/twentyfourteen/inc/widgets.php Mon Oct 14 17:39:30 2019 +0200 @@ -16,7 +16,6 @@ /** * The supported post formats. * - * @access private * @since Twenty Fourteen 1.0 * * @var array @@ -31,16 +30,39 @@ * @return Twenty_Fourteen_Ephemera_Widget */ public function __construct() { - parent::__construct( 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array( - 'classname' => 'widget_twentyfourteen_ephemera', - 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ), - ) ); + parent::__construct( + 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array( + 'classname' => '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. @@ -84,24 +106,26 @@ $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', + $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']; + $tmp_content_width = $GLOBALS['content_width']; $GLOBALS['content_width'] = 306; echo $args['before_widget']; @@ -112,61 +136,65 @@
    have_posts() ) : - $ephemera->the_post(); - $tmp_more = $GLOBALS['more']; - $GLOBALS['more'] = 0; + while ( $ephemera->have_posts() ) : + $ephemera->the_post(); + $tmp_more = $GLOBALS['more']; + $GLOBALS['more'] = 0; ?>
  1. > -
    - + →', 'twentyfourteen' ) ); - else : - $images = array(); + if ( post_password_required() ) : + the_content( __( 'Continue reading ', 'twentyfourteen' ) ); + else : + $images = array(); - $galleries = get_post_galleries( get_the_ID(), false ); - if ( isset( $galleries[0]['ids'] ) ) - $images = explode( ',', $galleries[0]['ids'] ); + $galleries = get_post_galleries( get_the_ID(), false ); + if ( isset( $galleries[0]['ids'] ) ) { + $images = explode( ',', $galleries[0]['ids'] ); + } - if ( ! $images ) : - $images = get_posts( array( - 'fields' => 'ids', - 'numberposts' => -1, - 'order' => 'ASC', - 'orderby' => 'menu_order', + if ( ! $images ) : + $images = get_posts( + array( + 'fields' => 'ids', + 'numberposts' => -1, + 'order' => 'ASC', + 'orderby' => 'menu_order', 'post_mime_type' => 'image', - 'post_parent' => get_the_ID(), - 'post_type' => 'attachment', - ) ); - endif; + 'post_parent' => get_the_ID(), + 'post_type' => 'attachment', + ) + ); + endif; - $total_images = count( $images ); + $total_images = count( $images ); - if ( has_post_thumbnail() ) : - $post_thumbnail = get_the_post_thumbnail(); + if ( has_post_thumbnail() ) : + $post_thumbnail = get_the_post_thumbnail(); elseif ( $total_images > 0 ) : $image = reset( $images ); $post_thumbnail = wp_get_attachment_image( $image, 'post-thumbnail' ); endif; - if ( ! empty ( $post_thumbnail ) ) : + if ( ! empty( $post_thumbnail ) ) : ?>

    - %2$s photo.', 'This gallery contains %2$s photos.', $total_images, 'twentyfourteen' ), - esc_url( get_permalink() ), - number_format_i18n( $total_images ) - ); - ?> + %2$s photo.', 'This gallery contains %2$s photos.', $total_images, 'twentyfourteen' ), + esc_url( get_permalink() ), + number_format_i18n( $total_images ) + ); + ?>

    →', 'twentyfourteen' ) ); @@ -176,20 +204,21 @@