diff --git a/comments.php b/comments.php index f378e3d8..30b2e88b 100644 --- a/comments.php +++ b/comments.php @@ -27,21 +27,21 @@ if ( post_password_required() ) { if ( have_comments() ) : ?>

' . get_the_title() . '' - ); - } else { - printf( // WPCS: XSS OK. - /* translators: 1: comment count number, 2: title. */ - esc_html( _nx( '%1$s thought on “%2$s”', '%1$s thoughts on “%2$s”', $comment_count, 'comments title', '_s' ) ), - number_format_i18n( $comment_count ), - '' . get_the_title() . '' - ); - } + $comment_count = get_comments_number(); + if ( 1 === $comment_count ) { + printf( + /* translators: 1: title. */ + esc_html_e( 'One thought on “%1$s”', '_s' ), + '' . get_the_title() . '' + ); + } else { + printf( // WPCS: XSS OK. + /* translators: 1: comment count number, 2: title. */ + esc_html( _nx( '%1$s thought on “%2$s”', '%1$s thoughts on “%2$s”', $comment_count, 'comments title', '_s' ) ), + number_format_i18n( $comment_count ), + '' . get_the_title() . '' + ); + } ?>

diff --git a/functions.php b/functions.php index acf75f0b..76bac867 100644 --- a/functions.php +++ b/functions.php @@ -8,78 +8,78 @@ */ if ( ! function_exists( '_s_setup' ) ) : -/** - * Sets up theme defaults and registers support for various WordPress features. - * - * Note that this function is hooked into the after_setup_theme hook, which - * runs before the init hook. The init hook is too late for some features, such - * as indicating support for post thumbnails. - */ -function _s_setup() { - /* - * Make theme available for translation. - * Translations can be filed in the /languages/ directory. - * If you're building a theme based on _s, use a find and replace - * to change '_s' to the name of your theme in all the template files. - */ - load_theme_textdomain( '_s', get_template_directory() . '/languages' ); - - // Add default posts and comments RSS feed links to head. - add_theme_support( 'automatic-feed-links' ); - - /* - * Let WordPress manage the document title. - * By adding theme support, we declare that this theme does not use a - * hard-coded tag in the document head, and expect WordPress to - * provide it for us. - */ - add_theme_support( 'title-tag' ); - - /* - * Enable support for Post Thumbnails on posts and pages. - * - * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ - */ - add_theme_support( 'post-thumbnails' ); - - // This theme uses wp_nav_menu() in one location. - register_nav_menus( array( - 'menu-1' => esc_html__( 'Primary', '_s' ), - ) ); - - /* - * Switch default core markup for search form, comment form, and comments - * to output valid HTML5. - */ - add_theme_support( 'html5', array( - 'search-form', - 'comment-form', - 'comment-list', - 'gallery', - 'caption', - ) ); - - // Set up the WordPress core custom background feature. - add_theme_support( 'custom-background', apply_filters( '_s_custom_background_args', array( - 'default-color' => 'ffffff', - 'default-image' => '', - ) ) ); - - // Add theme support for selective refresh for widgets. - add_theme_support( 'customize-selective-refresh-widgets' ); - /** - * Add support for core custom logo. + * Sets up theme defaults and registers support for various WordPress features. * - * @link https://codex.wordpress.org/Theme_Logo + * Note that this function is hooked into the after_setup_theme hook, which + * runs before the init hook. The init hook is too late for some features, such + * as indicating support for post thumbnails. */ - add_theme_support( 'custom-logo', array( - 'height' => 250, - 'width' => 250, - 'flex-width' => true, - 'flex-height' => true, - ) ); -} + function _s_setup() { + /* + * Make theme available for translation. + * Translations can be filed in the /languages/ directory. + * If you're building a theme based on _s, use a find and replace + * to change '_s' to the name of your theme in all the template files. + */ + load_theme_textdomain( '_s', get_template_directory() . '/languages' ); + + // Add default posts and comments RSS feed links to head. + add_theme_support( 'automatic-feed-links' ); + + /* + * Let WordPress manage the document title. + * By adding theme support, we declare that this theme does not use a + * hard-coded <title> tag in the document head, and expect WordPress to + * provide it for us. + */ + add_theme_support( 'title-tag' ); + + /* + * Enable support for Post Thumbnails on posts and pages. + * + * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ + */ + add_theme_support( 'post-thumbnails' ); + + // This theme uses wp_nav_menu() in one location. + register_nav_menus( array( + 'menu-1' => esc_html__( 'Primary', '_s' ), + ) ); + + /* + * Switch default core markup for search form, comment form, and comments + * to output valid HTML5. + */ + add_theme_support( 'html5', array( + 'search-form', + 'comment-form', + 'comment-list', + 'gallery', + 'caption', + ) ); + + // Set up the WordPress core custom background feature. + add_theme_support( 'custom-background', apply_filters( '_s_custom_background_args', array( + 'default-color' => 'ffffff', + 'default-image' => '', + ) ) ); + + // Add theme support for selective refresh for widgets. + add_theme_support( 'customize-selective-refresh-widgets' ); + + /** + * Add support for core custom logo. + * + * @link https://codex.wordpress.org/Theme_Logo + */ + add_theme_support( 'custom-logo', array( + 'height' => 250, + 'width' => 250, + 'flex-width' => true, + 'flex-height' => true, + ) ); + } endif; add_action( 'after_setup_theme', '_s_setup' ); diff --git a/inc/custom-header.php b/inc/custom-header.php index 134f1077..97b1db28 100644 --- a/inc/custom-header.php +++ b/inc/custom-header.php @@ -29,44 +29,44 @@ function _s_custom_header_setup() { add_action( 'after_setup_theme', '_s_custom_header_setup' ); if ( ! function_exists( '_s_header_style' ) ) : -/** - * Styles the header image and text displayed on the blog. - * - * @see _s_custom_header_setup(). - */ -function _s_header_style() { - $header_text_color = get_header_textcolor(); - - /* - * If no custom options for text are set, let's bail. - * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ). + /** + * Styles the header image and text displayed on the blog. + * + * @see _s_custom_header_setup(). */ - if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) { - return; - } + function _s_header_style() { + $header_text_color = get_header_textcolor(); - // If we get this far, we have custom styles. Let's do this. - ?> - <style type="text/css"> - <?php + /* + * If no custom options for text are set, let's bail. + * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ). + */ + if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) { + return; + } + + // If we get this far, we have custom styles. Let's do this. + ?> + <style type="text/css"> + <?php // Has the text been hidden? if ( ! display_header_text() ) : - ?> - .site-title, - .site-description { - position: absolute; - clip: rect(1px, 1px, 1px, 1px); - } - <?php - // If the user has set a custom color for the text use that. - else : - ?> - .site-title a, - .site-description { - color: #<?php echo esc_attr( $header_text_color ); ?>; - } - <?php endif; ?> - </style> - <?php -} + ?> + .site-title, + .site-description { + position: absolute; + clip: rect(1px, 1px, 1px, 1px); + } + <?php + // If the user has set a custom color for the text use that. + else : + ?> + .site-title a, + .site-description { + color: #<?php echo esc_attr( $header_text_color ); ?>; + } + <?php endif; ?> + </style> + <?php + } endif; diff --git a/inc/template-tags.php b/inc/template-tags.php index e4b9cf02..3260c44e 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -8,68 +8,85 @@ */ if ( ! function_exists( '_s_posted_on' ) ) : -/** - * Prints HTML with meta information for the current post-date/time and author. - */ -function _s_posted_on() { - $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; - 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>'; + /** + * Prints HTML with meta information for the current post-date/time and author. + */ + function _s_posted_on() { + $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; + 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>'; + } + + $time_string = sprintf( $time_string, + esc_attr( get_the_date( 'c' ) ), + esc_html( get_the_date() ), + esc_attr( get_the_modified_date( 'c' ) ), + esc_html( get_the_modified_date() ) + ); + + $posted_on = sprintf( + /* translators: %s: post date. */ + esc_html_x( 'Posted on %s', 'post date', '_s' ), + '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' + ); + + $byline = sprintf( + /* translators: %s: post author. */ + esc_html_x( 'by %s', 'post author', '_s' ), + '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>' + ); + + echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. + } - - $time_string = sprintf( $time_string, - esc_attr( get_the_date( 'c' ) ), - esc_html( get_the_date() ), - esc_attr( get_the_modified_date( 'c' ) ), - esc_html( get_the_modified_date() ) - ); - - $posted_on = sprintf( - /* translators: %s: post date. */ - esc_html_x( 'Posted on %s', 'post date', '_s' ), - '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' - ); - - $byline = sprintf( - /* translators: %s: post author. */ - esc_html_x( 'by %s', 'post author', '_s' ), - '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>' - ); - - echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. - -} endif; if ( ! function_exists( '_s_entry_footer' ) ) : -/** - * Prints HTML with meta information for the categories, tags and comments. - */ -function _s_entry_footer() { - // Hide category and tag text for pages. - if ( 'post' === get_post_type() ) { - /* translators: used between list items, there is a space after the comma */ - $categories_list = get_the_category_list( esc_html__( ', ', '_s' ) ); - if ( $categories_list ) { - /* translators: 1: list of categories. */ - printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', '_s' ) . '</span>', $categories_list ); // WPCS: XSS OK. + /** + * Prints HTML with meta information for the categories, tags and comments. + */ + function _s_entry_footer() { + // Hide category and tag text for pages. + if ( 'post' === get_post_type() ) { + /* translators: used between list items, there is a space after the comma */ + $categories_list = get_the_category_list( esc_html__( ', ', '_s' ) ); + if ( $categories_list ) { + /* translators: 1: list of categories. */ + printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', '_s' ) . '</span>', $categories_list ); // WPCS: XSS OK. + } + + /* translators: used between list items, there is a space after the comma */ + $tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', '_s' ) ); + if ( $tags_list ) { + /* translators: 1: list of tags. */ + printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', '_s' ) . '</span>', $tags_list ); // WPCS: XSS OK. + } } - /* translators: used between list items, there is a space after the comma */ - $tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', '_s' ) ); - if ( $tags_list ) { - /* translators: 1: list of tags. */ - printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', '_s' ) . '</span>', $tags_list ); // WPCS: XSS OK. + if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { + echo '<span class="comments-link">'; + comments_popup_link( + sprintf( + wp_kses( + /* translators: %s: post title */ + __( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', '_s' ), + array( + 'span' => array( + 'class' => array(), + ), + ) + ), + get_the_title() + ) + ); + echo '</span>'; } - } - if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { - echo '<span class="comments-link">'; - comments_popup_link( + edit_post_link( sprintf( wp_kses( - /* translators: %s: post title */ - __( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', '_s' ), + /* translators: %s: Name of current post. Only visible to screen readers */ + __( 'Edit <span class="screen-reader-text">%s</span>', '_s' ), array( 'span' => array( 'class' => array(), @@ -77,26 +94,9 @@ function _s_entry_footer() { ) ), get_the_title() - ) - ); - echo '</span>'; - } - - edit_post_link( - sprintf( - wp_kses( - /* translators: %s: Name of current post. Only visible to screen readers */ - __( 'Edit <span class="screen-reader-text">%s</span>', '_s' ), - array( - 'span' => array( - 'class' => array(), - ), - ) ), - get_the_title() - ), - '<span class="edit-link">', - '</span>' - ); -} + '<span class="edit-link">', + '</span>' + ); + } endif;