summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'themes/twentyfourteen/inc/widgets.php')
-rw-r--r--themes/twentyfourteen/inc/widgets.php151
1 files changed, 79 insertions, 72 deletions
diff --git a/themes/twentyfourteen/inc/widgets.php b/themes/twentyfourteen/inc/widgets.php
index 533f34a5..64118b5e 100644
--- a/themes/twentyfourteen/inc/widgets.php
+++ b/themes/twentyfourteen/inc/widgets.php
@@ -16,7 +16,6 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
/**
* The supported post formats.
*
- * @access private
* @since Twenty Fourteen 1.0
*
* @var array
@@ -31,11 +30,13 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
* @return Twenty_Fourteen_Ephemera_Widget
*/
public function __construct() {
- parent::__construct( 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array(
- 'classname' => 'widget_twentyfourteen_ephemera',
- 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ),
- 'customize_selective_refresh' => true,
- ) );
+ parent::__construct(
+ 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array(
+ 'classname' => 'widget_twentyfourteen_ephemera',
+ 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ),
+ 'customize_selective_refresh' => true,
+ )
+ );
if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -62,7 +63,6 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
/**
* Output the HTML for this widget.
*
- * @access public
* @since Twenty Fourteen 1.0
*
* @param array $args An array of standard parameters for widgets in this theme.
@@ -106,24 +106,26 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
$number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] );
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $format_string : $instance['title'], $instance, $this->id_base );
- $ephemera = new WP_Query( array(
- 'order' => 'DESC',
- 'posts_per_page' => $number,
- 'no_found_rows' => true,
- 'post_status' => 'publish',
- 'post__not_in' => get_option( 'sticky_posts' ),
- 'tax_query' => array(
- array(
- 'taxonomy' => 'post_format',
- 'terms' => array( "post-format-$format" ),
- 'field' => 'slug',
- 'operator' => 'IN',
+ $ephemera = new WP_Query(
+ array(
+ 'order' => 'DESC',
+ 'posts_per_page' => $number,
+ 'no_found_rows' => true,
+ 'post_status' => 'publish',
+ 'post__not_in' => get_option( 'sticky_posts' ),
+ 'tax_query' => array(
+ array(
+ 'taxonomy' => 'post_format',
+ 'terms' => array( "post-format-$format" ),
+ 'field' => 'slug',
+ 'operator' => 'IN',
+ ),
),
- ),
- ) );
+ )
+ );
if ( $ephemera->have_posts() ) :
- $tmp_content_width = $GLOBALS['content_width'];
+ $tmp_content_width = $GLOBALS['content_width'];
$GLOBALS['content_width'] = 306;
echo $args['before_widget'];
@@ -134,61 +136,65 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
<ol>
<?php
- while ( $ephemera->have_posts() ) :
- $ephemera->the_post();
- $tmp_more = $GLOBALS['more'];
- $GLOBALS['more'] = 0;
+ while ( $ephemera->have_posts() ) :
+ $ephemera->the_post();
+ $tmp_more = $GLOBALS['more'];
+ $GLOBALS['more'] = 0;
?>
<li>
<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">&rarr;</span>', 'twentyfourteen' ) );
- else :
- $images = array();
-
- $galleries = get_post_galleries( get_the_ID(), false );
- if ( isset( $galleries[0]['ids'] ) )
- $images = explode( ',', $galleries[0]['ids'] );
-
- if ( ! $images ) :
- $images = get_posts( array(
- 'fields' => 'ids',
- 'numberposts' => -1,
- 'order' => 'ASC',
- 'orderby' => 'menu_order',
+ <div class="entry-content">
+ <?php
+ if ( has_post_format( 'gallery' ) ) :
+
+ if ( post_password_required() ) :
+ the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ) );
+ else :
+ $images = array();
+
+ $galleries = get_post_galleries( get_the_ID(), false );
+ if ( isset( $galleries[0]['ids'] ) ) {
+ $images = explode( ',', $galleries[0]['ids'] );
+ }
+
+ if ( ! $images ) :
+ $images = get_posts(
+ array(
+ 'fields' => 'ids',
+ 'numberposts' => -1,
+ 'order' => 'ASC',
+ 'orderby' => 'menu_order',
'post_mime_type' => 'image',
- 'post_parent' => get_the_ID(),
- 'post_type' => 'attachment',
- ) );
- endif;
+ 'post_parent' => get_the_ID(),
+ 'post_type' => 'attachment',
+ )
+ );
+ endif;
- $total_images = count( $images );
+ $total_images = count( $images );
- if ( has_post_thumbnail() ) :
- $post_thumbnail = get_the_post_thumbnail();
+ if ( has_post_thumbnail() ) :
+ $post_thumbnail = get_the_post_thumbnail();
elseif ( $total_images > 0 ) :
$image = reset( $images );
$post_thumbnail = wp_get_attachment_image( $image, 'post-thumbnail' );
endif;
- if ( ! empty ( $post_thumbnail ) ) :
+ if ( ! empty( $post_thumbnail ) ) :
?>
<a href="<?php the_permalink(); ?>"><?php echo $post_thumbnail; ?></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' ),
- esc_url( get_permalink() ),
- number_format_i18n( $total_images )
- );
- ?>
+ <?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' ),
+ esc_url( get_permalink() ),
+ number_format_i18n( $total_images )
+ );
+ ?>
</p>
<?php
- endif;
+ endif;
else :
the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ) );
@@ -198,20 +204,21 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
<header class="entry-header">
<div class="entry-meta">
- <?php
- if ( ! has_post_format( 'link' ) ) :
- the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );
- endif;
+ <?php
+ if ( ! has_post_format( 'link' ) ) :
+ the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );
+ endif;
- 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>',
- esc_url( get_permalink() ),
- esc_attr( get_the_date( 'c' ) ),
- esc_html( get_the_date() ),
- esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
- get_the_author()
- );
+ 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>',
+ esc_url( get_permalink() ),
+ esc_attr( get_the_date( 'c' ) ),
+ esc_html( get_the_date() ),
+ esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
+ get_the_author()
+ );
- if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) :
+ if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) :
?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span>
<?php endif; ?>