summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'themes/twentyfifteen/inc')
-rw-r--r--themes/twentyfifteen/inc/back-compat.php8
-rw-r--r--themes/twentyfifteen/inc/custom-header.php70
-rw-r--r--themes/twentyfifteen/inc/customizer.php358
-rw-r--r--themes/twentyfifteen/inc/template-tags.php319
4 files changed, 400 insertions, 355 deletions
diff --git a/themes/twentyfifteen/inc/back-compat.php b/themes/twentyfifteen/inc/back-compat.php
index 73cd44d1..2f828d6e 100644
--- a/themes/twentyfifteen/inc/back-compat.php
+++ b/themes/twentyfifteen/inc/back-compat.php
@@ -44,9 +44,11 @@ function twentyfifteen_upgrade_notice() {
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_customize() {
- wp_die( sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ), '', array(
- 'back_link' => true,
- ) );
+ wp_die(
+ sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ), '', array(
+ 'back_link' => true,
+ )
+ );
}
add_action( 'load-customize.php', 'twentyfifteen_customize' );
diff --git a/themes/twentyfifteen/inc/custom-header.php b/themes/twentyfifteen/inc/custom-header.php
index 10d0ef1a..5f90789f 100644
--- a/themes/twentyfifteen/inc/custom-header.php
+++ b/themes/twentyfifteen/inc/custom-header.php
@@ -13,8 +13,8 @@
* @uses twentyfifteen_header_style()
*/
function twentyfifteen_custom_header_setup() {
- $color_scheme = twentyfifteen_get_color_scheme();
- $default_text_color = trim( $color_scheme[4], '#' );
+ $color_scheme = twentyfifteen_get_color_scheme();
+ $default_text_color = trim( $color_scheme[4], '#' );
/**
* Filter Twenty Fifteen custom-header support arguments.
@@ -31,12 +31,16 @@ function twentyfifteen_custom_header_setup() {
* displayed on the blog.
* }
*/
- add_theme_support( 'custom-header', apply_filters( 'twentyfifteen_custom_header_args', array(
- 'default-text-color' => $default_text_color,
- 'width' => 954,
- 'height' => 1300,
- 'wp-head-callback' => 'twentyfifteen_header_style',
- ) ) );
+ add_theme_support(
+ 'custom-header', apply_filters(
+ 'twentyfifteen_custom_header_args', array(
+ 'default-text-color' => $default_text_color,
+ 'width' => 954,
+ 'height' => 1300,
+ 'wp-head-callback' => 'twentyfifteen_header_style',
+ )
+ )
+ );
}
add_action( 'after_setup_theme', 'twentyfifteen_custom_header_setup' );
@@ -53,10 +57,10 @@ function twentyfifteen_hex2rgb( $color ) {
$color = trim( $color, '#' );
if ( strlen( $color ) == 3 ) {
- $r = hexdec( substr( $color, 0, 1 ).substr( $color, 0, 1 ) );
- $g = hexdec( substr( $color, 1, 1 ).substr( $color, 1, 1 ) );
- $b = hexdec( substr( $color, 2, 1 ).substr( $color, 2, 1 ) );
- } else if ( strlen( $color ) == 6 ) {
+ $r = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) );
+ $g = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) );
+ $b = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) );
+ } elseif ( strlen( $color ) == 6 ) {
$r = hexdec( substr( $color, 0, 2 ) );
$g = hexdec( substr( $color, 2, 2 ) );
$b = hexdec( substr( $color, 4, 2 ) );
@@ -64,29 +68,33 @@ function twentyfifteen_hex2rgb( $color ) {
return array();
}
- return array( 'red' => $r, 'green' => $g, 'blue' => $b );
+ return array(
+ 'red' => $r,
+ 'green' => $g,
+ 'blue' => $b,
+ );
}
if ( ! function_exists( 'twentyfifteen_header_style' ) ) :
-/**
- * Styles the header image and text displayed on the blog.
- *
- * @since Twenty Fifteen 1.0
- *
- * @see twentyfifteen_custom_header_setup()
- */
-function twentyfifteen_header_style() {
- $header_image = get_header_image();
+ /**
+ * Styles the header image and text displayed on the blog.
+ *
+ * @since Twenty Fifteen 1.0
+ *
+ * @see twentyfifteen_custom_header_setup()
+ */
+ function twentyfifteen_header_style() {
+ $header_image = get_header_image();
- // If no custom options for text are set, let's bail.
- if ( empty( $header_image ) && display_header_text() ) {
- return;
- }
+ // If no custom options for text are set, let's bail.
+ if ( empty( $header_image ) && display_header_text() ) {
+ return;
+ }
- // If we get this far, we have custom styles. Let's do this.
- ?>
- <style type="text/css" id="twentyfifteen-header-css">
- <?php
+ // If we get this far, we have custom styles. Let's do this.
+ ?>
+ <style type="text/css" id="twentyfifteen-header-css">
+ <?php
// Short header for when there is no Custom Header and Header Text is hidden.
if ( empty( $header_image ) && ! display_header_text() ) :
?>
@@ -182,7 +190,7 @@ function twentyfifteen_header_style() {
<?php endif; ?>
</style>
<?php
-}
+ }
endif; // twentyfifteen_header_style
/**
diff --git a/themes/twentyfifteen/inc/customizer.php b/themes/twentyfifteen/inc/customizer.php
index c31c57e8..9cc00a8a 100644
--- a/themes/twentyfifteen/inc/customizer.php
+++ b/themes/twentyfifteen/inc/customizer.php
@@ -21,61 +21,81 @@ function twentyfifteen_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
if ( isset( $wp_customize->selective_refresh ) ) {
- $wp_customize->selective_refresh->add_partial( 'blogname', array(
- 'selector' => '.site-title a',
- 'container_inclusive' => false,
- 'render_callback' => 'twentyfifteen_customize_partial_blogname',
- ) );
- $wp_customize->selective_refresh->add_partial( 'blogdescription', array(
- 'selector' => '.site-description',
- 'container_inclusive' => false,
- 'render_callback' => 'twentyfifteen_customize_partial_blogdescription',
- ) );
+ $wp_customize->selective_refresh->add_partial(
+ 'blogname', array(
+ 'selector' => '.site-title a',
+ 'container_inclusive' => false,
+ 'render_callback' => 'twentyfifteen_customize_partial_blogname',
+ )
+ );
+ $wp_customize->selective_refresh->add_partial(
+ 'blogdescription', array(
+ 'selector' => '.site-description',
+ 'container_inclusive' => false,
+ 'render_callback' => 'twentyfifteen_customize_partial_blogdescription',
+ )
+ );
}
// Add color scheme setting and control.
- $wp_customize->add_setting( 'color_scheme', array(
- 'default' => 'default',
- 'sanitize_callback' => 'twentyfifteen_sanitize_color_scheme',
- 'transport' => 'postMessage',
- ) );
-
- $wp_customize->add_control( 'color_scheme', array(
- 'label' => __( 'Base Color Scheme', 'twentyfifteen' ),
- 'section' => 'colors',
- 'type' => 'select',
- 'choices' => twentyfifteen_get_color_scheme_choices(),
- 'priority' => 1,
- ) );
+ $wp_customize->add_setting(
+ 'color_scheme', array(
+ 'default' => 'default',
+ 'sanitize_callback' => 'twentyfifteen_sanitize_color_scheme',
+ 'transport' => 'postMessage',
+ )
+ );
+
+ $wp_customize->add_control(
+ 'color_scheme', array(
+ 'label' => __( 'Base Color Scheme', 'twentyfifteen' ),
+ 'section' => 'colors',
+ 'type' => 'select',
+ 'choices' => twentyfifteen_get_color_scheme_choices(),
+ 'priority' => 1,
+ )
+ );
// Add custom header and sidebar text color setting and control.
- $wp_customize->add_setting( 'sidebar_textcolor', array(
- 'default' => $color_scheme[4],
- 'sanitize_callback' => 'sanitize_hex_color',
- 'transport' => 'postMessage',
- ) );
-
- $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'sidebar_textcolor', array(
- 'label' => __( 'Header and Sidebar Text Color', 'twentyfifteen' ),
- 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
- 'section' => 'colors',
- ) ) );
+ $wp_customize->add_setting(
+ 'sidebar_textcolor', array(
+ 'default' => $color_scheme[4],
+ 'sanitize_callback' => 'sanitize_hex_color',
+ 'transport' => 'postMessage',
+ )
+ );
+
+ $wp_customize->add_control(
+ new WP_Customize_Color_Control(
+ $wp_customize, 'sidebar_textcolor', array(
+ 'label' => __( 'Header and Sidebar Text Color', 'twentyfifteen' ),
+ 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
+ 'section' => 'colors',
+ )
+ )
+ );
// Remove the core header textcolor control, as it shares the sidebar text color.
$wp_customize->remove_control( 'header_textcolor' );
// Add custom header and sidebar background color setting and control.
- $wp_customize->add_setting( 'header_background_color', array(
- 'default' => $color_scheme[1],
- 'sanitize_callback' => 'sanitize_hex_color',
- 'transport' => 'postMessage',
- ) );
-
- $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background_color', array(
- 'label' => __( 'Header and Sidebar Background Color', 'twentyfifteen' ),
- 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
- 'section' => 'colors',
- ) ) );
+ $wp_customize->add_setting(
+ 'header_background_color', array(
+ 'default' => $color_scheme[1],
+ 'sanitize_callback' => 'sanitize_hex_color',
+ 'transport' => 'postMessage',
+ )
+ );
+
+ $wp_customize->add_control(
+ new WP_Customize_Color_Control(
+ $wp_customize, 'header_background_color', array(
+ 'label' => __( 'Header and Sidebar Background Color', 'twentyfifteen' ),
+ 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
+ 'section' => 'colors',
+ )
+ )
+ );
// Add an additional description to the header image section.
$wp_customize->get_section( 'header_image' )->description = __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' );
@@ -145,134 +165,136 @@ function twentyfifteen_get_color_schemes() {
* }
* }
*/
- return apply_filters( 'twentyfifteen_color_schemes', array(
- 'default' => array(
- 'label' => __( 'Default', 'twentyfifteen' ),
- 'colors' => array(
- '#f1f1f1',
- '#ffffff',
- '#ffffff',
- '#333333',
- '#333333',
- '#f7f7f7',
+ return apply_filters(
+ 'twentyfifteen_color_schemes', array(
+ 'default' => array(
+ 'label' => __( 'Default', 'twentyfifteen' ),
+ 'colors' => array(
+ '#f1f1f1',
+ '#ffffff',
+ '#ffffff',
+ '#333333',
+ '#333333',
+ '#f7f7f7',
+ ),
),
- ),
- 'dark' => array(
- 'label' => __( 'Dark', 'twentyfifteen' ),
- 'colors' => array(
- '#111111',
- '#202020',
- '#202020',
- '#bebebe',
- '#bebebe',
- '#1b1b1b',
+ 'dark' => array(
+ 'label' => __( 'Dark', 'twentyfifteen' ),
+ 'colors' => array(
+ '#111111',
+ '#202020',
+ '#202020',
+ '#bebebe',
+ '#bebebe',
+ '#1b1b1b',
+ ),
),
- ),
- 'yellow' => array(
- 'label' => __( 'Yellow', 'twentyfifteen' ),
- 'colors' => array(
- '#f4ca16',
- '#ffdf00',
- '#ffffff',
- '#111111',
- '#111111',
- '#f1f1f1',
+ 'yellow' => array(
+ 'label' => __( 'Yellow', 'twentyfifteen' ),
+ 'colors' => array(
+ '#f4ca16',
+ '#ffdf00',
+ '#ffffff',
+ '#111111',
+ '#111111',
+ '#f1f1f1',
+ ),
),
- ),
- 'pink' => array(
- 'label' => __( 'Pink', 'twentyfifteen' ),
- 'colors' => array(
- '#ffe5d1',
- '#e53b51',
- '#ffffff',
- '#352712',
- '#ffffff',
- '#f1f1f1',
+ 'pink' => array(
+ 'label' => __( 'Pink', 'twentyfifteen' ),
+ 'colors' => array(
+ '#ffe5d1',
+ '#e53b51',
+ '#ffffff',
+ '#352712',
+ '#ffffff',
+ '#f1f1f1',
+ ),
),
- ),
- 'purple' => array(
- 'label' => __( 'Purple', 'twentyfifteen' ),
- 'colors' => array(
- '#674970',
- '#2e2256',
- '#ffffff',
- '#2e2256',
- '#ffffff',
- '#f1f1f1',
+ 'purple' => array(
+ 'label' => __( 'Purple', 'twentyfifteen' ),
+ 'colors' => array(
+ '#674970',
+ '#2e2256',
+ '#ffffff',
+ '#2e2256',
+ '#ffffff',
+ '#f1f1f1',
+ ),
),
- ),
- 'blue' => array(
- 'label' => __( 'Blue', 'twentyfifteen' ),
- 'colors' => array(
- '#e9f2f9',
- '#55c3dc',
- '#ffffff',
- '#22313f',
- '#ffffff',
- '#f1f1f1',
+ 'blue' => array(
+ 'label' => __( 'Blue', 'twentyfifteen' ),
+ 'colors' => array(
+ '#e9f2f9',
+ '#55c3dc',
+ '#ffffff',
+ '#22313f',
+ '#ffffff',
+ '#f1f1f1',
+ ),
),
- ),
- ) );
+ )
+ );
}
if ( ! function_exists( 'twentyfifteen_get_color_scheme' ) ) :
-/**
- * Get the current Twenty Fifteen color scheme.
- *
- * @since Twenty Fifteen 1.0
- *
- * @return array An associative array of either the current or default color scheme hex values.
- */
-function twentyfifteen_get_color_scheme() {
- $color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
- $color_schemes = twentyfifteen_get_color_schemes();
+ /**
+ * Get the current Twenty Fifteen color scheme.
+ *
+ * @since Twenty Fifteen 1.0
+ *
+ * @return array An associative array of either the current or default color scheme hex values.
+ */
+ function twentyfifteen_get_color_scheme() {
+ $color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
+ $color_schemes = twentyfifteen_get_color_schemes();
- if ( array_key_exists( $color_scheme_option, $color_schemes ) ) {
- return $color_schemes[ $color_scheme_option ]['colors'];
- }
+ if ( array_key_exists( $color_scheme_option, $color_schemes ) ) {
+ return $color_schemes[ $color_scheme_option ]['colors'];
+ }
- return $color_schemes['default']['colors'];
-}
+ return $color_schemes['default']['colors'];
+ }
endif; // twentyfifteen_get_color_scheme
if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) :
-/**
- * Returns an array of color scheme choices registered for Twenty Fifteen.
- *
- * @since Twenty Fifteen 1.0
- *
- * @return array Array of color schemes.
- */
-function twentyfifteen_get_color_scheme_choices() {
- $color_schemes = twentyfifteen_get_color_schemes();
- $color_scheme_control_options = array();
+ /**
+ * Returns an array of color scheme choices registered for Twenty Fifteen.
+ *
+ * @since Twenty Fifteen 1.0
+ *
+ * @return array Array of color schemes.
+ */
+ function twentyfifteen_get_color_scheme_choices() {
+ $color_schemes = twentyfifteen_get_color_schemes();
+ $color_scheme_control_options = array();
- foreach ( $color_schemes as $color_scheme => $value ) {
- $color_scheme_control_options[ $color_scheme ] = $value['label'];
- }
+ foreach ( $color_schemes as $color_scheme => $value ) {
+ $color_scheme_control_options[ $color_scheme ] = $value['label'];
+ }
- return $color_scheme_control_options;
-}
+ return $color_scheme_control_options;
+ }
endif; // twentyfifteen_get_color_scheme_choices
if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) :
-/**
- * Sanitization callback for color schemes.
- *
- * @since Twenty Fifteen 1.0
- *
- * @param string $value Color scheme name value.
- * @return string Color scheme name.
- */
-function twentyfifteen_sanitize_color_scheme( $value ) {
- $color_schemes = twentyfifteen_get_color_scheme_choices();
+ /**
+ * Sanitization callback for color schemes.
+ *
+ * @since Twenty Fifteen 1.0
+ *
+ * @param string $value Color scheme name value.
+ * @return string Color scheme name.
+ */
+ function twentyfifteen_sanitize_color_scheme( $value ) {
+ $color_schemes = twentyfifteen_get_color_scheme_choices();
- if ( ! array_key_exists( $value, $color_schemes ) ) {
- $value = 'default';
- }
+ if ( ! array_key_exists( $value, $color_schemes ) ) {
+ $value = 'default';
+ }
- return $value;
-}
+ return $value;
+ }
endif; // twentyfifteen_sanitize_color_scheme
/**
@@ -295,7 +317,7 @@ function twentyfifteen_color_scheme_css() {
// Convert main and sidebar text hex color to rgba.
$color_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[3] );
$color_sidebar_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[4] );
- $colors = array(
+ $colors = array(
'background_color' => $color_scheme[0],
'header_background_color' => $color_scheme[1],
'box_background_color' => $color_scheme[2],
@@ -348,20 +370,22 @@ add_action( 'customize_preview_init', 'twentyfifteen_customize_preview_js' );
* @return string Color scheme CSS.
*/
function twentyfifteen_get_color_scheme_css( $colors ) {
- $colors = wp_parse_args( $colors, array(
- 'background_color' => '',
- 'header_background_color' => '',
- 'box_background_color' => '',
- 'textcolor' => '',
- 'secondary_textcolor' => '',
- 'border_color' => '',
- 'border_focus_color' => '',
- 'sidebar_textcolor' => '',
- 'sidebar_border_color' => '',
- 'sidebar_border_focus_color' => '',
- 'secondary_sidebar_textcolor' => '',
- 'meta_box_background_color' => '',
- ) );
+ $colors = wp_parse_args(
+ $colors, array(
+ 'background_color' => '',
+ 'header_background_color' => '',
+ 'box_background_color' => '',
+ 'textcolor' => '',
+ 'secondary_textcolor' => '',
+ 'border_color' => '',
+ 'border_focus_color' => '',
+ 'sidebar_textcolor' => '',
+ 'sidebar_border_color' => '',
+ 'sidebar_border_focus_color' => '',
+ 'secondary_sidebar_textcolor' => '',
+ 'meta_box_background_color' => '',
+ )
+ );
$css = <<<CSS
/* Color Scheme */
diff --git a/themes/twentyfifteen/inc/template-tags.php b/themes/twentyfifteen/inc/template-tags.php
index 7b4ffeb7..baa98d21 100644
--- a/themes/twentyfifteen/inc/template-tags.php
+++ b/themes/twentyfifteen/inc/template-tags.php
@@ -10,120 +10,127 @@
*/
if ( ! function_exists( 'twentyfifteen_comment_nav' ) ) :
-/**
- * Display navigation to next/previous comments when applicable.
- *
- * @since Twenty Fifteen 1.0
- */
-function twentyfifteen_comment_nav() {
- // Are there comments to navigate through?
- if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
- ?>
- <nav class="navigation comment-navigation" role="navigation">
+ /**
+ * Display navigation to next/previous comments when applicable.
+ *
+ * @since Twenty Fifteen 1.0
+ */
+ function twentyfifteen_comment_nav() {
+ // Are there comments to navigate through?
+ if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
+ ?>
+ <nav class="navigation comment-navigation" role="navigation">
<h2 class="screen-reader-text"><?php _e( 'Comment navigation', 'twentyfifteen' ); ?></h2>
<div class="nav-links">
<?php
- if ( $prev_link = get_previous_comments_link( __( 'Older Comments', 'twentyfifteen' ) ) ) :
- printf( '<div class="nav-previous">%s</div>', $prev_link );
+ if ( $prev_link = get_previous_comments_link( __( 'Older Comments', 'twentyfifteen' ) ) ) :
+ printf( '<div class="nav-previous">%s</div>', $prev_link );
endif;
- if ( $next_link = get_next_comments_link( __( 'Newer Comments', 'twentyfifteen' ) ) ) :
- printf( '<div class="nav-next">%s</div>', $next_link );
+ if ( $next_link = get_next_comments_link( __( 'Newer Comments', 'twentyfifteen' ) ) ) :
+ printf( '<div class="nav-next">%s</div>', $next_link );
endif;
?>
- </div><!-- .nav-links -->
- </nav><!-- .comment-navigation -->
- <?php
- endif;
-}
+ </div><!-- .nav-links -->
+ </nav><!-- .comment-navigation -->
+ <?php
+ endif;
+ }
endif;
if ( ! function_exists( 'twentyfifteen_entry_meta' ) ) :
-/**
- * Prints HTML with meta information for the categories, tags.
- *
- * @since Twenty Fifteen 1.0
- */
-function twentyfifteen_entry_meta() {
- if ( is_sticky() && is_home() && ! is_paged() ) {
- printf( '<span class="sticky-post">%s</span>', __( 'Featured', 'twentyfifteen' ) );
- }
-
- $format = get_post_format();
- if ( current_theme_supports( 'post-formats', $format ) ) {
- printf( '<span class="entry-format">%1$s<a href="%2$s">%3$s</a></span>',
- sprintf( '<span class="screen-reader-text">%s </span>', _x( 'Format', 'Used before post format.', 'twentyfifteen' ) ),
- esc_url( get_post_format_link( $format ) ),
- get_post_format_string( $format )
- );
- }
-
- if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
- $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
+ /**
+ * Prints HTML with meta information for the categories, tags.
+ *
+ * @since Twenty Fifteen 1.0
+ */
+ function twentyfifteen_entry_meta() {
+ if ( is_sticky() && is_home() && ! is_paged() ) {
+ printf( '<span class="sticky-post">%s</span>', __( 'Featured', 'twentyfifteen' ) );
+ }
- if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
- $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
+ $format = get_post_format();
+ if ( current_theme_supports( 'post-formats', $format ) ) {
+ printf(
+ '<span class="entry-format">%1$s<a href="%2$s">%3$s</a></span>',
+ sprintf( '<span class="screen-reader-text">%s </span>', _x( 'Format', 'Used before post format.', 'twentyfifteen' ) ),
+ esc_url( get_post_format_link( $format ) ),
+ get_post_format_string( $format )
+ );
}
- $time_string = sprintf( $time_string,
- esc_attr( get_the_date( 'c' ) ),
- get_the_date(),
- esc_attr( get_the_modified_date( 'c' ) ),
- get_the_modified_date()
- );
+ if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
+ $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
- printf( '<span class="posted-on"><span class="screen-reader-text">%1$s </span><a href="%2$s" rel="bookmark">%3$s</a></span>',
- _x( 'Posted on', 'Used before publish date.', 'twentyfifteen' ),
- esc_url( get_permalink() ),
- $time_string
- );
- }
+ if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
+ $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
+ }
- if ( 'post' == get_post_type() ) {
- if ( is_singular() || is_multi_author() ) {
- printf( '<span class="byline"><span class="author vcard"><span class="screen-reader-text">%1$s </span><a class="url fn n" href="%2$s">%3$s</a></span></span>',
- _x( 'Author', 'Used before post author name.', 'twentyfifteen' ),
- esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
- get_the_author()
+ $time_string = sprintf(
+ $time_string,
+ esc_attr( get_the_date( 'c' ) ),
+ get_the_date(),
+ esc_attr( get_the_modified_date( 'c' ) ),
+ get_the_modified_date()
);
- }
- $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
- if ( $categories_list && twentyfifteen_categorized_blog() ) {
- printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
- _x( 'Categories', 'Used before category names.', 'twentyfifteen' ),
- $categories_list
+ printf(
+ '<span class="posted-on"><span class="screen-reader-text">%1$s </span><a href="%2$s" rel="bookmark">%3$s</a></span>',
+ _x( 'Posted on', 'Used before publish date.', 'twentyfifteen' ),
+ esc_url( get_permalink() ),
+ $time_string
);
}
- $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
- if ( $tags_list && ! is_wp_error( $tags_list ) ) {
- printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
- _x( 'Tags', 'Used before tag names.', 'twentyfifteen' ),
- $tags_list
- );
+ if ( 'post' == get_post_type() ) {
+ if ( is_singular() || is_multi_author() ) {
+ printf(
+ '<span class="byline"><span class="author vcard"><span class="screen-reader-text">%1$s </span><a class="url fn n" href="%2$s">%3$s</a></span></span>',
+ _x( 'Author', 'Used before post author name.', 'twentyfifteen' ),
+ esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
+ get_the_author()
+ );
+ }
+
+ $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
+ if ( $categories_list && twentyfifteen_categorized_blog() ) {
+ printf(
+ '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
+ _x( 'Categories', 'Used before category names.', 'twentyfifteen' ),
+ $categories_list
+ );
+ }
+
+ $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
+ if ( $tags_list && ! is_wp_error( $tags_list ) ) {
+ printf(
+ '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
+ _x( 'Tags', 'Used before tag names.', 'twentyfifteen' ),
+ $tags_list
+ );
+ }
}
- }
- if ( is_attachment() && wp_attachment_is_image() ) {
- // Retrieve attachment metadata.
- $metadata = wp_get_attachment_metadata();
+ if ( is_attachment() && wp_attachment_is_image() ) {
+ // Retrieve attachment metadata.
+ $metadata = wp_get_attachment_metadata();
- printf( '<span class="full-size-link"><span class="screen-reader-text">%1$s </span><a href="%2$s">%3$s &times; %4$s</a></span>',
- _x( 'Full size', 'Used before full size attachment link.', 'twentyfifteen' ),
- esc_url( wp_get_attachment_url() ),
- $metadata['width'],
- $metadata['height']
- );
- }
+ printf(
+ '<span class="full-size-link"><span class="screen-reader-text">%1$s </span><a href="%2$s">%3$s &times; %4$s</a></span>',
+ _x( 'Full size', 'Used before full size attachment link.', 'twentyfifteen' ),
+ esc_url( wp_get_attachment_url() ),
+ $metadata['width'],
+ $metadata['height']
+ );
+ }
- if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
- echo '<span class="comments-link">';
- /* translators: %s: post title */
- comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentyfifteen' ), get_the_title() ) );
- echo '</span>';
+ if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
+ echo '<span class="comments-link">';
+ /* translators: %s: post title */
+ comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentyfifteen' ), get_the_title() ) );
+ echo '</span>';
+ }
}
-}
endif;
/**
@@ -136,13 +143,15 @@ endif;
function twentyfifteen_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'twentyfifteen_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
- $all_the_cool_cats = get_categories( array(
- 'fields' => 'ids',
- 'hide_empty' => 1,
+ $all_the_cool_cats = get_categories(
+ array(
+ 'fields' => 'ids',
+ 'hide_empty' => 1,
- // We only need to know if there is more than one category.
- 'number' => 2,
- ) );
+ // We only need to know if there is more than one category.
+ 'number' => 2,
+ )
+ );
// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );
@@ -169,26 +178,26 @@ function twentyfifteen_category_transient_flusher() {
delete_transient( 'twentyfifteen_categories' );
}
add_action( 'edit_category', 'twentyfifteen_category_transient_flusher' );
-add_action( 'save_post', 'twentyfifteen_category_transient_flusher' );
+add_action( 'save_post', 'twentyfifteen_category_transient_flusher' );
if ( ! function_exists( 'twentyfifteen_post_thumbnail' ) ) :
-/**
- * Display an optional post thumbnail.
- *
- * Wraps the post thumbnail in an anchor element on index views, or a div
- * element when on single views.
- *
- * @since Twenty Fifteen 1.0
- */
-function twentyfifteen_post_thumbnail() {
- if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
- return;
- }
+ /**
+ * Display an optional post thumbnail.
+ *
+ * Wraps the post thumbnail in an anchor element on index views, or a div
+ * element when on single views.
+ *
+ * @since Twenty Fifteen 1.0
+ */
+ function twentyfifteen_post_thumbnail() {
+ if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
+ return;
+ }
- if ( is_singular() ) :
- ?>
+ if ( is_singular() ) :
+ ?>
- <div class="post-thumbnail">
+ <div class="post-thumbnail">
<?php the_post_thumbnail(); ?>
</div><!-- .post-thumbnail -->
@@ -200,59 +209,61 @@ function twentyfifteen_post_thumbnail() {
?>
</a>
- <?php endif; // End is_singular()
-}
+ <?php
+ endif; // End is_singular()
+ }
endif;
if ( ! function_exists( 'twentyfifteen_get_link_url' ) ) :
-/**
- * Return the post URL.
- *
- * Falls back to the post permalink if no URL is found in the post.
- *
- * @since Twenty Fifteen 1.0
- *
- * @see get_url_in_content()
- *
- * @return string The Link format URL.
- */
-function twentyfifteen_get_link_url() {
- $has_url = get_url_in_content( get_the_content() );
+ /**
+ * Return the post URL.
+ *
+ * Falls back to the post permalink if no URL is found in the post.
+ *
+ * @since Twenty Fifteen 1.0
+ *
+ * @see get_url_in_content()
+ *
+ * @return string The Link format URL.
+ */
+ function twentyfifteen_get_link_url() {
+ $has_url = get_url_in_content( get_the_content() );
- return $has_url ? $has_url : apply_filters( 'the_permalink', get_permalink() );
-}
+ return $has_url ? $has_url : apply_filters( 'the_permalink', get_permalink() );
+ }
endif;
if ( ! function_exists( 'twentyfifteen_excerpt_more' ) && ! is_admin() ) :
-/**
- * Replaces "[...]" (appended to automatically generated excerpts) with ... and a 'Continue reading' link.
- *
- * @since Twenty Fifteen 1.0
- *
- * @return string 'Continue reading' link prepended with an ellipsis.
- */
-function twentyfifteen_excerpt_more( $more ) {
- $link = sprintf( '<a href="%1$s" class="more-link">%2$s</a>',
- esc_url( get_permalink( get_the_ID() ) ),
- /* translators: %s: Name of current post */
- sprintf( __( 'Continue reading %s', 'twentyfifteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
+ /**
+ * Replaces "[...]" (appended to automatically generated excerpts) with ... and a 'Continue reading' link.
+ *
+ * @since Twenty Fifteen 1.0
+ *
+ * @return string 'Continue reading' link prepended with an ellipsis.
+ */
+ function twentyfifteen_excerpt_more( $more ) {
+ $link = sprintf(
+ '<a href="%1$s" class="more-link">%2$s</a>',
+ esc_url( get_permalink( get_the_ID() ) ),
+ /* translators: %s: Name of current post */
+ sprintf( __( 'Continue reading %s', 'twentyfifteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
);
- return ' &hellip; ' . $link;
-}
-add_filter( 'excerpt_more', 'twentyfifteen_excerpt_more' );
+ return ' &hellip; ' . $link;
+ }
+ add_filter( 'excerpt_more', 'twentyfifteen_excerpt_more' );
endif;
if ( ! function_exists( 'twentyfifteen_the_custom_logo' ) ) :
-/**
- * Displays the optional custom logo.
- *
- * Does nothing if the custom logo is not available.
- *
- * @since Twenty Fifteen 1.5
- */
-function twentyfifteen_the_custom_logo() {
- if ( function_exists( 'the_custom_logo' ) ) {
- the_custom_logo();
+ /**
+ * Displays the optional custom logo.
+ *
+ * Does nothing if the custom logo is not available.
+ *
+ * @since Twenty Fifteen 1.5
+ */
+ function twentyfifteen_the_custom_logo() {
+ if ( function_exists( 'the_custom_logo' ) ) {
+ the_custom_logo();
+ }
}
-}
endif;