forked from mirror/_s
Compare commits
3 Commits
master
...
improve-by
Author | SHA1 | Date |
---|---|---|
Yoav Farhi | b2880f537e | |
Yoav Farhi | 6af98e3e3b | |
Yoav Farhi | 43bc383c26 |
|
@ -7,11 +7,12 @@
|
||||||
* @package _s
|
* @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>';
|
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
||||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
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 = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
|
||||||
|
@ -24,30 +25,12 @@ if ( ! function_exists( '_s_posted_on' ) ) :
|
||||||
esc_html( get_the_modified_date() )
|
esc_html( get_the_modified_date() )
|
||||||
);
|
);
|
||||||
|
|
||||||
$posted_on = sprintf(
|
printf(
|
||||||
/* translators: %s: post date. */
|
/* translators: %1$s: post date, %2$s: post author . */
|
||||||
esc_html_x( 'Posted on %s', 'post date', '_s' ),
|
__( '<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>'
|
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>', // WPCS: XSS OK.
|
||||||
);
|
|
||||||
|
|
||||||
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' ),
|
|
||||||
'<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>'
|
'<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;
|
endif;
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
<?php if ( 'post' === get_post_type() ) : ?>
|
<?php if ( 'post' === get_post_type() ) : ?>
|
||||||
<div class="entry-meta">
|
<div class="entry-meta">
|
||||||
<?php
|
<?php
|
||||||
_s_posted_on();
|
_s_posted_on_by()
|
||||||
_s_posted_by();
|
|
||||||
?>
|
?>
|
||||||
</div><!-- .entry-meta -->
|
</div><!-- .entry-meta -->
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
?>
|
?>
|
||||||
<div class="entry-meta">
|
<div class="entry-meta">
|
||||||
<?php
|
<?php
|
||||||
_s_posted_on();
|
_s_posted_on_by();
|
||||||
_s_posted_by();
|
|
||||||
?>
|
?>
|
||||||
</div><!-- .entry-meta -->
|
</div><!-- .entry-meta -->
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
Reference in New Issue