- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfourteen/inc/widgets.php
r41198 r42343 32 32 */ 33 33 public function __construct() { 34 parent::__construct( 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array( 35 'classname' => 'widget_twentyfourteen_ephemera', 36 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ), 37 'customize_selective_refresh' => true, 38 ) ); 34 parent::__construct( 35 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array( 36 'classname' => 'widget_twentyfourteen_ephemera', 37 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ), 38 'customize_selective_refresh' => true, 39 ) 40 ); 39 41 40 42 if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) { … … 107 109 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $format_string : $instance['title'], $instance, $this->id_base ); 108 110 109 $ephemera = new WP_Query( array( 110 'order' => 'DESC', 111 'posts_per_page' => $number, 112 'no_found_rows' => true, 113 'post_status' => 'publish', 114 'post__not_in' => get_option( 'sticky_posts' ), 115 'tax_query' => array( 116 array( 117 'taxonomy' => 'post_format', 118 'terms' => array( "post-format-$format" ), 119 'field' => 'slug', 120 'operator' => 'IN', 111 $ephemera = new WP_Query( 112 array( 113 'order' => 'DESC', 114 'posts_per_page' => $number, 115 'no_found_rows' => true, 116 'post_status' => 'publish', 117 'post__not_in' => get_option( 'sticky_posts' ), 118 'tax_query' => array( 119 array( 120 'taxonomy' => 'post_format', 121 'terms' => array( "post-format-$format" ), 122 'field' => 'slug', 123 'operator' => 'IN', 124 ), 121 125 ), 122 ) ,123 ) );126 ) 127 ); 124 128 125 129 if ( $ephemera->have_posts() ) : 126 $tmp_content_width = $GLOBALS['content_width'];130 $tmp_content_width = $GLOBALS['content_width']; 127 131 $GLOBALS['content_width'] = 306; 128 132 … … 135 139 136 140 <?php 137 138 139 $tmp_more= $GLOBALS['more'];140 141 while ( $ephemera->have_posts() ) : 142 $ephemera->the_post(); 143 $tmp_more = $GLOBALS['more']; 144 $GLOBALS['more'] = 0; 141 145 ?> 142 146 <li> 143 147 <article <?php post_class(); ?>> 144 <div class="entry-content"> 145 <?php 146 if ( has_post_format( 'gallery' ) ) : 147 148 if ( post_password_required() ) : 149 the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); 150 else : 151 $images = array(); 152 153 $galleries = get_post_galleries( get_the_ID(), false ); 154 if ( isset( $galleries[0]['ids'] ) ) 155 $images = explode( ',', $galleries[0]['ids'] ); 156 157 if ( ! $images ) : 158 $images = get_posts( array( 159 'fields' => 'ids', 160 'numberposts' => -1, 161 'order' => 'ASC', 162 'orderby' => 'menu_order', 148 <div class="entry-content"> 149 <?php 150 if ( has_post_format( 'gallery' ) ) : 151 152 if ( post_password_required() ) : 153 the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); 154 else : 155 $images = array(); 156 157 $galleries = get_post_galleries( get_the_ID(), false ); 158 if ( isset( $galleries[0]['ids'] ) ) { 159 $images = explode( ',', $galleries[0]['ids'] ); 160 } 161 162 if ( ! $images ) : 163 $images = get_posts( 164 array( 165 'fields' => 'ids', 166 'numberposts' => -1, 167 'order' => 'ASC', 168 'orderby' => 'menu_order', 163 169 'post_mime_type' => 'image', 164 'post_parent' => get_the_ID(), 165 'post_type' => 'attachment', 166 ) ); 167 endif; 168 169 $total_images = count( $images ); 170 171 if ( has_post_thumbnail() ) : 172 $post_thumbnail = get_the_post_thumbnail(); 170 'post_parent' => get_the_ID(), 171 'post_type' => 'attachment', 172 ) 173 ); 174 endif; 175 176 $total_images = count( $images ); 177 178 if ( has_post_thumbnail() ) : 179 $post_thumbnail = get_the_post_thumbnail(); 173 180 elseif ( $total_images > 0 ) : 174 181 $image = reset( $images ); … … 176 183 endif; 177 184 178 if ( ! empty 185 if ( ! empty( $post_thumbnail ) ) : 179 186 ?> 180 187 <a href="<?php the_permalink(); ?>"><?php echo $post_thumbnail; ?></a> 181 188 <?php endif; ?> 182 189 <p class="wp-caption-text"> 183 <?php 184 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' ), 185 esc_url( get_permalink() ), 186 number_format_i18n( $total_images ) 187 ); 188 ?> 190 <?php 191 printf( 192 _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' ), 193 esc_url( get_permalink() ), 194 number_format_i18n( $total_images ) 195 ); 196 ?> 189 197 </p> 190 198 <?php 191 199 endif; 192 200 193 201 else : … … 199 207 <header class="entry-header"> 200 208 <div class="entry-meta"> 201 <?php 202 if ( ! has_post_format( 'link' ) ) : 203 the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' ); 204 endif; 205 206 printf( '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>', 207 esc_url( get_permalink() ), 208 esc_attr( get_the_date( 'c' ) ), 209 esc_html( get_the_date() ), 210 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), 211 get_the_author() 212 ); 213 214 if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : 209 <?php 210 if ( ! has_post_format( 'link' ) ) : 211 the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' ); 212 endif; 213 214 printf( 215 '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>', 216 esc_url( get_permalink() ), 217 esc_attr( get_the_date( 'c' ) ), 218 esc_html( get_the_date() ), 219 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), 220 get_the_author() 221 ); 222 223 if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : 215 224 ?> 216 225 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span>
Note: See TracChangeset
for help on using the changeset viewer.