Created
June 13, 2017 06:21
-
-
Save anonymous/34477c0ee78d27ca18dedabc530c278c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function emag_posted_on() { | |
global $post; | |
$author_id=$post->post_author; | |
$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( | |
esc_html_x( 'On %s', 'post date', 'emag' ), | |
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' | |
); | |
$byline = sprintf( | |
esc_html_x( 'By %s', 'post author', 'emag' ), | |
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( $author_id ) ) . '">' . esc_html( get_the_author_meta( 'display_name', $author_id ) ) . '</a></span>' | |
); | |
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment