forked from mirror/_s
Merge pull request #1226 from Ismail-elkorchi/_s_posted
Split _s_posted_on into two functions
This commit is contained in:
commit
388951f1ee
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
if ( ! function_exists( '_s_posted_on' ) ) :
|
if ( ! function_exists( '_s_posted_on' ) ) :
|
||||||
/**
|
/**
|
||||||
* Prints HTML with meta information for the current post-date/time and author.
|
* Prints HTML with meta information for the current post-date/time.
|
||||||
*/
|
*/
|
||||||
function _s_posted_on() {
|
function _s_posted_on() {
|
||||||
$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>';
|
||||||
|
@ -30,13 +30,23 @@ if ( ! function_exists( '_s_posted_on' ) ) :
|
||||||
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
|
'<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(
|
$byline = sprintf(
|
||||||
/* translators: %s: post author. */
|
/* translators: %s: post author. */
|
||||||
esc_html_x( 'by %s', 'post author', '_s' ),
|
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="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
|
echo '<span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
|
||||||
|
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
|
@ -15,7 +15,10 @@
|
||||||
|
|
||||||
<?php if ( 'post' === get_post_type() ) : ?>
|
<?php if ( 'post' === get_post_type() ) : ?>
|
||||||
<div class="entry-meta">
|
<div class="entry-meta">
|
||||||
<?php _s_posted_on(); ?>
|
<?php
|
||||||
|
_s_posted_on();
|
||||||
|
_s_posted_by();
|
||||||
|
?>
|
||||||
</div><!-- .entry-meta -->
|
</div><!-- .entry-meta -->
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</header><!-- .entry-header -->
|
</header><!-- .entry-header -->
|
||||||
|
|
|
@ -20,7 +20,10 @@
|
||||||
|
|
||||||
if ( 'post' === get_post_type() ) : ?>
|
if ( 'post' === get_post_type() ) : ?>
|
||||||
<div class="entry-meta">
|
<div class="entry-meta">
|
||||||
<?php _s_posted_on(); ?>
|
<?php
|
||||||
|
_s_posted_on();
|
||||||
|
_s_posted_by();
|
||||||
|
?>
|
||||||
</div><!-- .entry-meta -->
|
</div><!-- .entry-meta -->
|
||||||
<?php
|
<?php
|
||||||
endif; ?>
|
endif; ?>
|
||||||
|
|
Reference in New Issue