Make WordPress Core

Ticket #25740: 25740.diff

File 25740.diff, 5.3 KB (added by iamtakashi, 11 years ago)
  • wp-content/themes/twentyfourteen/content-gallery.php

     
    66 * @subpackage Twenty_Fourteen
    77 * @since Twenty Fourteen 1.0
    88 */
    9 
    10 if ( has_post_thumbnail() ) :
    11         $image = get_post_thumbnail_id();
    12 else :
    13         $images = get_posts( array(
    14                 'post_parent'    => get_the_ID(),
    15                 'fields'         => 'ids',
    16                 'numberposts'    => 1,
    17                 'post_status'    => 'inherit',
    18                 'post_type'      => 'attachment',
    19                 'post_mime_type' => 'image',
    20                 'order'          => 'ASC',
    21                 'orderby'        => 'menu_order ID',
    22         ) );
    23         $image = array_shift( $images );
    24 endif;
    259?>
    2610
    2711<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    28         <?php if ( is_single() && $image ) : ?>
    29         <div class="featured-thumbnail">
    30                 <?php echo wp_get_attachment_image( $image, 'featured-thumbnail-large' ); ?>
    31         </div>
    32         <?php elseif ( $image ) : ?>
    33         <a class="featured-thumbnail" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>">
    34                 <?php echo wp_get_attachment_image( $image, 'featured-thumbnail-large' ); ?>
    35         </a>
    36         <?php endif; ?>
     12        <?php twentyfourteen_post_thumbnail(); ?>
    3713
    3814        <header class="entry-header">
    3915                <?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
  • wp-content/themes/twentyfourteen/inc/widgets.php

     
    120120
    121121                                <?php while ( $ephemera->have_posts() ) : $ephemera->the_post(); ?>
    122122                                <li>
    123                                 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     123                                <article <?php post_class(); ?>>
    124124                                        <div class="entry-content">
    125125                                                <?php
    126126                                                        if ( has_post_format( 'gallery' ) ) :
    127                                                                 $images = get_posts( array(
    128                                                                         'post_parent'    => get_post()->post_parent,
    129                                                                         'fields'         => 'ids',
    130                                                                         'numberposts'    => -1,
    131                                                                         'post_status'    => 'inherit',
    132                                                                         'post_type'      => 'attachment',
    133                                                                         'post_mime_type' => 'image',
    134                                                                         'order'          => 'ASC',
    135                                                                         'orderby'        => 'menu_order ID'
    136                                                                 ) );
    137                                                                 $total_images = count( $images );
    138127
    139                                                                 if ( has_post_thumbnail() ) :
    140                                                                         $featured_image = get_the_post_thumbnail( get_the_ID(), 'featured-thumbnail-formatted' );
    141                                                                 elseif ( $total_images > 0 ) :
    142                                                                         $image          = array_shift( $images );
    143                                                                         $featured_image = wp_get_attachment_image( $image, 'featured-thumbnail-formatted' );
    144                                                                 endif;
     128                                                                if ( post_password_required() ) :
     129                                                                        the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ) );
     130                                                                else :
     131                                                                        $images = array();
     132
     133                                                                        if ( function_exists( 'get_post_galleries' ) ) {
     134                                                                                $galleries = get_post_galleries( get_the_ID(), false );
     135                                                                                if ( isset( $galleries[0]['ids'] ) )
     136                                                                                        $images = explode( ',', $galleries[0]['ids'] );
     137                                                                        } else {
     138                                                                                $pattern = get_shortcode_regex();
     139                                                                                preg_match( "/$pattern/s", get_the_content(), $match );
     140                                                                                $atts = shortcode_parse_atts( $match[3] );
     141                                                                                if ( isset( $atts['ids'] ) )
     142                                                                                        $images = explode( ',', $atts['ids'] );
     143                                                                        }
     144
     145                                                                        if ( ! $images ) :
     146                                                                                $images = get_posts( array(
     147                                                                                        'fields'         => 'ids',
     148                                                                                        'numberposts'    => 999,
     149                                                                                        'order'          => 'ASC',
     150                                                                                        'orderby'        => 'menu_order',
     151                                                                                        'post_mime_type' => 'image',
     152                                                                                        'post_parent'    => get_the_ID(),
     153                                                                                        'post_type'      => 'attachment',
     154                                                                                ) );
     155                                                                        endif;
     156
     157                                                                        $total_images = count( $images );
     158
     159                                                                        if ( has_post_thumbnail() ) :
     160                                                                                $featured_image = get_the_post_thumbnail( get_the_ID(), 'featured-thumbnail-formatted' );
     161                                                                        elseif ( $total_images > 0 ) :
     162                                                                                $image          = array_shift( $images );
     163                                                                                $featured_image = wp_get_attachment_image( $image, 'featured-thumbnail-formatted' );
     164                                                                        endif;
     165
     166                                                                        if ( ! empty ( $featured_image ) ) :
    145167                                                ?>
    146                                                 <a href="<?php the_permalink(); ?>"><?php echo $featured_image; ?></a>
    147                                                 <p class="wp-caption-text">
     168                                                                        <a href="<?php the_permalink(); ?>"><?php echo $featured_image; ?></a>
     169                                                                <?php
     170                                                                        endif;
     171                                                                ?>
     172                                                                        <p class="wp-caption-text">
     173                                                                        <?php
     174                                                                                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' ),
     175                                                                                        esc_url( get_permalink() ),
     176                                                                                        number_format_i18n( $total_images )
     177                                                                                );
     178                                                                        ?>
     179                                                                        </p>
    148180                                                        <?php
    149                                                                 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' ),
    150                                                                         esc_url( get_permalink() ),
    151                                                                         number_format_i18n( $total_images )
    152                                                                 );
    153                                                         ?>
    154                                                 </p>
    155                                                 <?php
     181                                                                endif;
     182
    156183                                                        else :
    157184                                                                the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ) );
    158185                                                        endif;