Twenty Fourteen: Fix gallery posts in the ephemera widget. Props iamtakashi, fixes #25740.
git-svn-id: https://develop.svn.wordpress.org/trunk@25970 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bd5ac31911
commit
01a703070b
@ -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;
|
||||
?>
|
||||
|
||||
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
<?php if ( is_single() && $image ) : ?>
|
||||
<div class="featured-thumbnail">
|
||||
<?php echo wp_get_attachment_image( $image, 'featured-thumbnail-large' ); ?>
|
||||
</div>
|
||||
<?php elseif ( $image ) : ?>
|
||||
<a class="featured-thumbnail" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>">
|
||||
<?php echo wp_get_attachment_image( $image, 'featured-thumbnail-large' ); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php twentyfourteen_post_thumbnail(); ?>
|
||||
|
||||
<header class="entry-header">
|
||||
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
|
||||
|
@ -120,20 +120,40 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
|
||||
|
||||
<?php while ( $ephemera->have_posts() ) : $ephemera->the_post(); ?>
|
||||
<li>
|
||||
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
<article <?php post_class(); ?>>
|
||||
<div class="entry-content">
|
||||
<?php
|
||||
if ( has_post_format( 'gallery' ) ) :
|
||||
|
||||
if ( post_password_required() ) :
|
||||
the_content( __( 'Continue reading <span class="meta-nav">→</span>', '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(
|
||||
'post_parent' => get_post()->post_parent,
|
||||
'fields' => 'ids',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'inherit',
|
||||
'post_type' => 'attachment',
|
||||
'post_mime_type' => 'image',
|
||||
'numberposts' => 999,
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order ID'
|
||||
'orderby' => 'menu_order',
|
||||
'post_mime_type' => 'image',
|
||||
'post_parent' => get_the_ID(),
|
||||
'post_type' => 'attachment',
|
||||
) );
|
||||
endif;
|
||||
|
||||
$total_images = count( $images );
|
||||
|
||||
if ( has_post_thumbnail() ) :
|
||||
@ -142,8 +162,13 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
|
||||
$image = array_shift( $images );
|
||||
$featured_image = wp_get_attachment_image( $image, 'featured-thumbnail-formatted' );
|
||||
endif;
|
||||
|
||||
if ( ! empty ( $featured_image ) ) :
|
||||
?>
|
||||
<a href="<?php the_permalink(); ?>"><?php echo $featured_image; ?></a>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<p class="wp-caption-text">
|
||||
<?php
|
||||
printf( _n( 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photo</a>.', 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photos</a>.', $total_images, 'twentyfourteen' ),
|
||||
@ -153,6 +178,8 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
else :
|
||||
the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) );
|
||||
endif;
|
||||
|
Loading…
Reference in New Issue
Block a user