Merge pull request #813 from IanDelMar/patch-1

Add filters for posted on/by
This commit is contained in:
Holger 2018-09-27 15:30:27 +02:00 committed by GitHub
commit 4c778ed270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 10 deletions

View File

@ -26,15 +26,23 @@ if ( ! function_exists ( 'understrap_posted_on' ) ) {
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
esc_html_x( 'Posted on %s', 'post date', 'understrap' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
$posted_on = apply_filters(
'understrap_posted_on', sprintf(
'<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>',
esc_html_x( 'Posted on', 'post date', 'understrap' ),
esc_url( get_permalink() ),
apply_filters( 'understrap_posted_on_time', $time_string )
)
);
$byline = sprintf(
esc_html_x( 'by %s', 'post author', 'understrap' ),
'<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>'
$byline = apply_filters(
'understrap_posted_by', sprintf(
'<span class="byline"> %1$s<span class="author vcard"><a class="url fn n" href="%2$s"> %3$s</a></span></span>',
$posted_on ? esc_html_x( 'by', 'post author', 'understrap' ) : esc_html_x( 'Posted by', 'post author', 'understrap' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() )
)
);
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
echo $posted_on . $byline; // WPCS: XSS OK.
}
}
@ -49,12 +57,14 @@ if ( ! function_exists ( 'understrap_entry_footer' ) ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'understrap' ) );
if ( $categories_list && understrap_categorized_blog() ) {
printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', 'understrap' ) . '</span>', $categories_list ); // WPCS: XSS OK.
/* translators: %s: Categories of current post */
printf( '<span class="cat-links">' . esc_html__( 'Posted in %s', 'understrap' ) . '</span>', $categories_list ); // WPCS: XSS OK.
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'understrap' ) );
if ( $tags_list ) {
printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', 'understrap' ) . '</span>', $tags_list ); // WPCS: XSS OK.
/* translators: %s: Tags of current post */
printf( '<span class="tags-links">' . esc_html__( 'Tagged %s', 'understrap' ) . '</span>', $tags_list ); // WPCS: XSS OK.
}
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
@ -119,4 +129,4 @@ if ( ! function_exists ( 'understrap_category_transient_flusher' ) ) {
// Like, beat it. Dig?
delete_transient( 'understrap_categories' );
}
}
}