Skip to content

Commit

Permalink
Merge pull request #42 from BlackbirdDigital/feature/template-tag-tem…
Browse files Browse the repository at this point in the history
…plate-parts

Feature/template tag template parts
  • Loading branch information
cr0ybot authored Aug 5, 2022
2 parents ba6ba9a + 8c12bde commit 879e886
Show file tree
Hide file tree
Showing 37 changed files with 697 additions and 324 deletions.
12 changes: 4 additions & 8 deletions archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@
<main id="content" class="site-content archive">

<?php
if ( have_posts() ) :

if ( have_posts() ) {
get_template_part( 'template-parts/loop/archive' );

else :

get_template_part( 'template-parts/content/none' );

endif;
} else {
get_template_part( 'template-parts/content/none', get_post_type() );
}
?>

</main>
Expand Down
23 changes: 11 additions & 12 deletions comments.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* The template for displaying comments
* The template for displaying comments.
*
* This is the template that displays the area of the page that contains both the current comments
* and the comment form.
* This is the template that displays the area of the page that contains both
* the current comments and the comment form.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
Expand All @@ -20,13 +20,12 @@
}
?>

<div id="comments" class="comments-area">
<div id="comments" class="comments">

<?php
// You can start editing here -- including this comment!
if ( have_comments() ) :
?>
<h2 class="comments-title">
<h2 class="comments__title">
<?php
$theme_scaffold_comment_count = get_comments_number();
if ( '1' === $theme_scaffold_comment_count ) {
Expand All @@ -36,19 +35,19 @@
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
);
} else {
printf(
printf(
/* translators: 1: comment count number, 2: title. */
esc_html( _nx( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', $theme_scaffold_comment_count, 'comments title', 'theme-scaffold' ) ),
number_format_i18n( $theme_scaffold_comment_count ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
);
}
?>
</h2><!-- .comments-title -->
</h2>

<?php the_comments_navigation(); ?>

<ol class="comment-list">
<ol class="comments__list">
<?php
wp_list_comments(
array(
Expand All @@ -57,15 +56,15 @@
)
);
?>
</ol><!-- .comment-list -->
</ol>

<?php
the_comments_navigation();

// If comments are closed and there are comments, let's leave a little note, shall we?
if ( ! comments_open() ) :
?>
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'theme-scaffold' ); ?></p>
<p class="comments__closed"><?php esc_html_e( 'Comments are closed.', 'theme-scaffold' ); ?></p>
<?php
endif;

Expand All @@ -74,4 +73,4 @@
comment_form();
?>

</div><!-- #comments -->
</div><!-- .comments -->
148 changes: 2 additions & 146 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,155 +2,11 @@
/**
* Custom template tags for this theme.
*
* Note: functions defined here are not namespaced!
*
* @package theme-scaffold
*/

if ( ! function_exists( 'theme_scaffold_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time.
*/
function theme_scaffold_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( DATE_W3C ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( DATE_W3C ) ),
esc_html( get_the_modified_date() )
);

$posted_on = sprintf(
/* translators: %s: post date. */
esc_html_x( 'Posted on %s', 'post date', 'theme-scaffold' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);

echo '<span class="posted-on">' . $posted_on . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

}
endif;

if ( ! function_exists( 'theme_scaffold_posted_by' ) ) :
/**
* Prints HTML with meta information for the current author.
*/
function theme_scaffold_posted_by() {
$byline = sprintf(
/* translators: %s: post author. */
esc_html_x( 'by %s', 'post author', 'theme-scaffold' ),
'<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="byline"> ' . $byline . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

}
endif;

if ( ! function_exists( 'theme_scaffold_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function theme_scaffold_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__( ', ', 'theme-scaffold' ) );
if ( $categories_list ) {
/* translators: 1: list of categories. */
printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', 'theme-scaffold' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'theme-scaffold' ) );
if ( $tags_list ) {
/* translators: 1: list of tags. */
printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', 'theme-scaffold' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}

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>', 'theme-scaffold' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( 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>', 'theme-scaffold' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
),
'<span class="edit-link">',
'</span>'
);
}
endif;

if ( ! function_exists( 'theme_scaffold_post_thumbnail' ) ) :
/**
* Displays an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index views, or a div
* element when on single views.
*/
function theme_scaffold_post_thumbnail() {
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}

if ( is_singular() ) :
?>

<div class="post-thumbnail">
<?php the_post_thumbnail(); ?>
</div><!-- .post-thumbnail -->

<?php else : ?>

<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
<?php
the_post_thumbnail(
'post-thumbnail',
array(
'alt' => the_title_attribute(
array(
'echo' => false,
)
),
)
);
?>
</a>

<?php
endif; // End is_singular().
}
endif;

if ( ! function_exists( 'wp_body_open' ) ) :
/**
* Shim for sites older than 5.2.
Expand Down
91 changes: 38 additions & 53 deletions languages/theme-scaffold.pot
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,25 @@ msgid "It looks like nothing was found at this location."
msgstr ""

#. translators: 1: comment count number, 2: title.
#: comments.php:41
#: comments.php:40
msgctxt "comments title"
msgid "%1$s thought on &ldquo;%2$s&rdquo;"
msgid_plural "%1$s thoughts on &ldquo;%2$s&rdquo;"
msgstr[0] ""
msgstr[1] ""

#: comments.php:35
#: comments.php:34
msgid "One thought on &ldquo;%1$s&rdquo;"
msgstr ""

#: comments.php:68
#: comments.php:67
msgid "Comments are closed."
msgstr ""

#: header.php:26
msgid "Skip to content"
msgstr ""

#: single.php:28
msgid "Previous:"
msgstr ""

#: single.php:29
msgid "Next:"
msgstr ""

#: style.css:2
msgid "Theme Scaffold"
msgstr ""
Expand Down Expand Up @@ -101,70 +93,63 @@ msgstr ""
msgid "Footer blocks."
msgstr ""

#. translators: %s: post date.
#: inc/template-tags.php:28
msgctxt "post date"
msgid "Posted on %s"
#: template-parts/content/none.php:14
msgid "Nothing Found"
msgstr ""

#. translators: %s: post author.
#: inc/template-tags.php:44
msgctxt "post author"
msgid "by %s"
#: template-parts/content/none.php:44
msgid "It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help."
msgstr ""

#. translators: used between list items, there is a space after the comma
#: inc/template-tags.php:61
msgid ", "
#: template-parts/content/none.php:37
msgid "Sorry, but nothing matched your search terms. Please try again with some different keywords."
msgstr ""

#. translators: 1: list of categories.
#: inc/template-tags.php:64
msgid "Posted in %1$s"
#: template-parts/content/none.php:24
msgid "Ready to publish your first post? <a href=\"%1$s\">Get started here</a>."
msgstr ""

#. translators: used between list items, there is a space after the comma
#: inc/template-tags.php:68
msgctxt "list item separator"
msgid ", "
#. translators: %s: search query.
#: template-parts/loop/archive-search.php:17
msgid "Search Results for: %s"
msgstr ""

#. translators: 1: list of tags.
#: inc/template-tags.php:71
msgid "Tagged %1$s"
#: template-parts/nav/navigation.php:19
msgctxt "post prev/next links label"
msgid "Post navigation"
msgstr ""

#. translators: %s: post title
#: inc/template-tags.php:81
msgid "Leave a Comment<span class=\"screen-reader-text\"> on %s</span>"
#: template-parts/nav/page-links.php:11
msgctxt "post page links label"
msgid "Pages:"
msgstr ""

#. translators: %s: Name of current post. Only visible to screen readers
#: inc/template-tags.php:98
msgid "Edit <span class=\"screen-reader-text\">%s</span>"
#: template-parts/nav/pagination.php:25
msgctxt "pagination label"
msgid "Page navigation"
msgstr ""

#: template-parts/content/entry.php:39, template-parts/content/page.php:28
msgid "Pages:"
#: template-parts/tag/author.php:11
msgctxt "post author byline"
msgid "by"
msgstr ""

#: template-parts/content/none.php:12
msgid "Nothing Found"
msgstr ""

#: template-parts/content/none.php:42
msgid "It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help."
#. translators: %s: post title
#: template-parts/tag/comment-link.php:19
msgid "Leave a Comment<span class=\"screen-reader-text\"> on %s</span>"
msgstr ""

#: template-parts/content/none.php:35
msgid "Sorry, but nothing matched your search terms. Please try again with some different keywords."
#: template-parts/tag/date.php:12
msgctxt "post date label"
msgid "Posted on"
msgstr ""

#: template-parts/content/none.php:22
msgid "Ready to publish your first post? <a href=\"%1$s\">Get started here</a>."
#: template-parts/tag/term-list.php:11
msgctxt "post tags label"
msgid "Posted in"
msgstr ""

#. translators: %s: search query.
#: template-parts/loop/archive-search.php:15
msgid "Search Results for: %s"
#: template-parts/tag/term-list.php:20
msgctxt "term list separator"
msgid ", "
msgstr ""
Loading

0 comments on commit 879e886

Please sign in to comment.