- Timestamp:
- 10/28/2013 05:52:45 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfourteen/inc/widgets.php
r25855 r25970 121 121 <?php while ( $ephemera->have_posts() ) : $ephemera->the_post(); ?> 122 122 <li> 123 <article id="post-<?php the_ID(); ?>"<?php post_class(); ?>>123 <article <?php post_class(); ?>> 124 124 <div class="entry-content"> 125 125 <?php 126 126 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 ); 138 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' ); 127 128 if ( post_password_required() ) : 129 the_content( __( 'Continue reading <span class="meta-nav">→</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 ) ) : 167 ?> 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> 180 <?php 144 181 endif; 145 ?> 146 <a href="<?php the_permalink(); ?>"><?php echo $featured_image; ?></a> 147 <p class="wp-caption-text"> 148 <?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 182 156 183 else : 157 184 the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) );
Note: See TracChangeset
for help on using the changeset viewer.