Skip to content

Instantly share code, notes, and snippets.

Created May 22, 2017 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/17eb9b9c9853a1b129b5100adf9ba81e to your computer and use it in GitHub Desktop.
Save anonymous/17eb9b9c9853a1b129b5100adf9ba81e to your computer and use it in GitHub Desktop.
function magazine_plus_posted_on() {
$show_meta_date = magazine_plus_get_option( 'show_meta_date' );
$show_meta_author = magazine_plus_get_option( 'show_meta_author' );
$posted_on = '';
if ( true === $show_meta_date ) {
$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(
'%s',
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
}
$byline = '';
if ( true === $show_meta_author ) {
$byline = sprintf(
'%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>'
);
}
$reading_time = 'apple';
if(shortcode_exists('rt_reading_time')) :
$scode = do_shortcode('[rt_reading_time label="Reading Time:" postfix="minutes" postfix_singular="minute"]');
$reading_time = '<span class="byline reading-time"> <span class="author vcard">'.$scode.'</span></span>';
endif;
if ( ! empty( $posted_on ) ) {
echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK.
}
if ( ! empty( $byline ) ) {
echo '<span class="byline"> ' . $byline . '</span>'.$reading_time ; // WPCS: XSS OK.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment