diff --git a/src/wp-content/themes/twentyfourteen/content-gallery.php b/src/wp-content/themes/twentyfourteen/content-gallery.php index e56909aabc..fc3639f8bb 100644 --- a/src/wp-content/themes/twentyfourteen/content-gallery.php +++ b/src/wp-content/themes/twentyfourteen/content-gallery.php @@ -6,34 +6,10 @@ * @subpackage Twenty_Fourteen * @since Twenty Fourteen 1.0 */ - -if ( has_post_thumbnail() ) : - $image = get_post_thumbnail_id(); -else : - $images = get_posts( array( - 'post_parent' => get_the_ID(), - 'fields' => 'ids', - 'numberposts' => 1, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => 'ASC', - 'orderby' => 'menu_order ID', - ) ); - $image = array_shift( $images ); -endif; ?>
> - - - - - - - +
diff --git a/src/wp-content/themes/twentyfourteen/inc/widgets.php b/src/wp-content/themes/twentyfourteen/inc/widgets.php index 1c9adcaa43..a51430b9d6 100644 --- a/src/wp-content/themes/twentyfourteen/inc/widgets.php +++ b/src/wp-content/themes/twentyfourteen/inc/widgets.php @@ -120,39 +120,66 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget { have_posts() ) : $ephemera->the_post(); ?>
  • -
    > +
    >
    get_post()->post_parent, - 'fields' => 'ids', - 'numberposts' => -1, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => 'ASC', - 'orderby' => 'menu_order ID' - ) ); - $total_images = count( $images ); - if ( has_post_thumbnail() ) : - $featured_image = get_the_post_thumbnail( get_the_ID(), 'featured-thumbnail-formatted' ); - elseif ( $total_images > 0 ) : - $image = array_shift( $images ); - $featured_image = wp_get_attachment_image( $image, 'featured-thumbnail-formatted' ); - endif; + if ( post_password_required() ) : + the_content( __( 'Continue reading ', 'twentyfourteen' ) ); + else : + $images = array(); + + if ( function_exists( 'get_post_galleries' ) ) { + $galleries = get_post_galleries( get_the_ID(), false ); + if ( isset( $galleries[0]['ids'] ) ) + $images = explode( ',', $galleries[0]['ids'] ); + } else { + $pattern = get_shortcode_regex(); + preg_match( "/$pattern/s", get_the_content(), $match ); + $atts = shortcode_parse_atts( $match[3] ); + if ( isset( $atts['ids'] ) ) + $images = explode( ',', $atts['ids'] ); + } + + if ( ! $images ) : + $images = get_posts( array( + 'fields' => 'ids', + 'numberposts' => 999, + 'order' => 'ASC', + 'orderby' => 'menu_order', + 'post_mime_type' => 'image', + 'post_parent' => get_the_ID(), + 'post_type' => 'attachment', + ) ); + endif; + + $total_images = count( $images ); + + if ( has_post_thumbnail() ) : + $featured_image = get_the_post_thumbnail( get_the_ID(), 'featured-thumbnail-formatted' ); + elseif ( $total_images > 0 ) : + $image = array_shift( $images ); + $featured_image = wp_get_attachment_image( $image, 'featured-thumbnail-formatted' ); + endif; + + if ( ! empty ( $featured_image ) ) : ?> - -

    + + +

    + %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' ) ); endif;