Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
* @package _s
*/

if ( ! function_exists( '_s_posted_on' ) ) :
if ( ! function_exists( '_s_posted_on_by' ) ) :
/**
* Prints HTML with meta information for the current post-date/time.
* Prints HTML with meta information for the current post-date/time and current author.
*/
function _s_posted_on() {
function _s_posted_on_by() {

$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>';
Expand All @@ -24,30 +25,12 @@ function _s_posted_on() {
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>'
);

echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK.

}
endif;

if ( ! function_exists( '_s_posted_by' ) ) :
/**
* Prints HTML with meta information for the current author.
*/
function _s_posted_by() {
$byline = sprintf(
/* translators: %s: post author. */
esc_html_x( 'by %s', 'post author', '_s' ),
printf(
/* translators: %1$s: post date, %2$s: post author . */
__( '<span class="posted-on">Posted on %1$s</span> <span class="byline">by %2$s</span>', '_s' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>', // WPCS: XSS OK.
'<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>'; // WPCS: XSS OK.

}
endif;

Expand Down
3 changes: 1 addition & 2 deletions template-parts/content-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<?php if ( 'post' === get_post_type() ) : ?>
<div class="entry-meta">
<?php
_s_posted_on();
_s_posted_by();
_s_posted_on_by()
?>
</div><!-- .entry-meta -->
<?php endif; ?>
Expand Down
3 changes: 1 addition & 2 deletions template-parts/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
?>
<div class="entry-meta">
<?php
_s_posted_on();
_s_posted_by();
_s_posted_on_by();
?>
</div><!-- .entry-meta -->
<?php endif; ?>
Expand Down