home/theblueo/tv/wp-content/themes/twentynineteen/inc/template-tags.php 0000604 00000016247 15214150405 0022433 0 ustar 00 %2$s';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '';
}
$time_string = sprintf(
$time_string,
esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( DATE_W3C ) ),
esc_html( get_the_modified_date() )
);
printf(
'%1$s%3$s',
twentynineteen_get_icon_svg( 'watch', 16 ),
esc_url( get_permalink() ),
$time_string
);
}
endif;
if ( ! function_exists( 'twentynineteen_posted_by' ) ) :
/**
* Prints HTML with meta information about theme author.
*/
function twentynineteen_posted_by() {
printf(
/* translators: 1: SVG icon. 2: Post author, only visible to screen readers. 3: Author link. */
'%1$s%2$s%4$s',
twentynineteen_get_icon_svg( 'person', 16 ),
__( 'Posted by', 'twentynineteen' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() )
);
}
endif;
if ( ! function_exists( 'twentynineteen_comment_count' ) ) :
/**
* Prints HTML with the comment count for the current post.
*/
function twentynineteen_comment_count() {
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '';
echo twentynineteen_get_icon_svg( 'comment', 16 );
/* translators: %s: Post title. Only visible to screen readers. */
comments_popup_link( sprintf( __( 'Leave a comment on %s', 'twentynineteen' ), get_the_title() ) );
echo '';
}
}
endif;
if ( ! function_exists( 'twentynineteen_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function twentynineteen_entry_footer() {
// Hide author, post date, category and tag text for pages.
if ( 'post' === get_post_type() ) {
// Posted by.
twentynineteen_posted_by();
// Posted on.
twentynineteen_posted_on();
/* translators: Used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( __( ', ', 'twentynineteen' ) );
if ( $categories_list ) {
printf(
/* translators: 1: SVG icon. 2: Posted in label, only visible to screen readers. 3: List of categories. */
'%1$s%2$s%3$s',
twentynineteen_get_icon_svg( 'archive', 16 ),
__( 'Posted in', 'twentynineteen' ),
$categories_list
); // WPCS: XSS OK.
}
/* translators: Used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', __( ', ', 'twentynineteen' ) );
if ( $tags_list ) {
printf(
/* translators: 1: SVG icon. 2: Posted in label, only visible to screen readers. 3: List of tags. */
'%1$s%2$s %3$s',
twentynineteen_get_icon_svg( 'tag', 16 ),
__( 'Tags:', 'twentynineteen' ),
$tags_list
); // WPCS: XSS OK.
}
}
// Comment count.
if ( ! is_singular() ) {
twentynineteen_comment_count();
}
// Edit post link.
edit_post_link(
sprintf(
wp_kses(
/* translators: %s: Post title. Only visible to screen readers. */
__( 'Edit %s', 'twentynineteen' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
),
'' . twentynineteen_get_icon_svg( 'edit', 16 ),
''
);
}
endif;
if ( ! function_exists( 'twentynineteen_post_thumbnail' ) ) :
/**
* Displays an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index views, or a div
* element when on single views.
*/
function twentynineteen_post_thumbnail() {
if ( ! twentynineteen_can_show_post_thumbnail() ) {
return;
}
if ( is_singular() ) :
?>
%s', get_avatar( $id_or_email, twentynineteen_get_avatar_size() ) );
}
endif;
if ( ! function_exists( 'twentynineteen_discussion_avatars_list' ) ) :
/**
* Displays a list of avatars involved in a discussion for a given post.
*/
function twentynineteen_discussion_avatars_list( $comment_authors ) {
if ( empty( $comment_authors ) ) {
return;
}
echo '
',
'condition' => ( is_front_page() || is_home() ) && ! is_page(),
);
$args = wp_parse_args( $args, $defaults );
/**
* Filters the arguments for `twentytwenty_site_logo()`.
*
* @param array $args Parsed arguments.
* @param array $defaults Function's default arguments.
*/
$args = apply_filters( 'twentytwenty_site_logo_args', $args, $defaults );
if ( has_custom_logo() ) {
$contents = sprintf( $args['logo'], $logo, esc_html( $site_title ) );
$classname = $args['logo_class'];
} else {
$contents = sprintf( $args['title'], esc_url( get_home_url( null, '/' ) ), esc_html( $site_title ) );
$classname = $args['title_class'];
}
$wrap = $args['condition'] ? 'home_wrap' : 'single_wrap';
$html = sprintf( $args[ $wrap ], $classname, $contents );
/**
* Filters the arguments for `twentytwenty_site_logo()`.
*
* @param string $html Compiled html based on our arguments.
* @param array $args Parsed arguments.
* @param string $classname Class name based on current view, home or single.
* @param string $contents HTML for site title or logo.
*/
$html = apply_filters( 'twentytwenty_site_logo', $html, $args, $classname, $contents );
if ( ! $echo ) {
return $html;
}
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Displays the site description.
*
* @param boolean $echo Echo or return the html.
*
* @return string $html The HTML to display.
*/
function twentytwenty_site_description( $echo = true ) {
$description = get_bloginfo( 'description' );
if ( ! $description ) {
return;
}
$wrapper = '
%s
';
$html = sprintf( $wrapper, esc_html( $description ) );
/**
* Filters the html for the site description.
*
* @since Twenty Twenty 1.0
*
* @param string $html The HTML to display.
* @param string $description Site description via `bloginfo()`.
* @param string $wrapper The format used in case you want to reuse it in a `sprintf()`.
*/
$html = apply_filters( 'twentytwenty_site_description', $html, $description, $wrapper );
if ( ! $echo ) {
return $html;
}
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Comments
*/
/**
* Check if the specified comment is written by the author of the post commented on.
*
* @param object $comment Comment data.
*
* @return bool
*/
function twentytwenty_is_comment_by_post_author( $comment = null ) {
if ( is_object( $comment ) && $comment->user_id > 0 ) {
$user = get_userdata( $comment->user_id );
$post = get_post( $comment->comment_post_ID );
if ( ! empty( $user ) && ! empty( $post ) ) {
return $comment->user_id === $post->post_author;
}
}
return false;
}
/**
* Filter comment reply link to not JS scroll.
* Filter the comment reply link to add a class indicating it should not use JS slow-scroll, as it
* makes it scroll to the wrong position on the page.
*
* @param string $link Link to the top of the page.
*
* @return string $link Link to the top of the page.
*/
function twentytwenty_filter_comment_reply_link( $link ) {
$link = str_replace( 'class=\'', 'class=\'do-not-scroll ', $link );
return $link;
}
add_filter( 'comment_reply_link', 'twentytwenty_filter_comment_reply_link' );
/**
* Post Meta
*/
/**
* Get and Output Post Meta.
* If it's a single post, output the post meta values specified in the Customizer settings.
*
* @param int $post_id The ID of the post for which the post meta should be output.
* @param string $location Which post meta location to output – single or preview.
*/
function twentytwenty_the_post_meta( $post_id = null, $location = 'single-top' ) {
echo twentytwenty_get_post_meta( $post_id, $location ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_post_meta().
}
/**
* Filters the edit post link to add an icon and use the post meta structure.
*
* @param string $link Anchor tag for the edit link.
* @param int $post_id Post ID.
* @param string $text Anchor text.
*/
function twentytwenty_edit_post_link( $link, $post_id, $text ) {
if ( is_admin() ) {
return $link;
}
$edit_url = get_edit_post_link( $post_id );
if ( ! $edit_url ) {
return;
}
$text = sprintf(
wp_kses(
/* translators: %s: Post title. Only visible to screen readers. */
__( 'Edit %s', 'twentytwenty' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title( $post_id )
);
return '
';
}
add_filter( 'edit_post_link', 'twentytwenty_edit_post_link', 10, 3 );
/**
* Get the post meta.
*
* @param int $post_id The ID of the post.
* @param string $location The location where the meta is shown.
*/
function twentytwenty_get_post_meta( $post_id = null, $location = 'single-top' ) {
// Require post ID.
if ( ! $post_id ) {
return;
}
/**
* Filters post types array
*
* This filter can be used to hide post meta information of post, page or custom post type registerd by child themes or plugins
*
* @since Twenty Twenty 1.0
*
* @param array Array of post types
*/
$disallowed_post_types = apply_filters( 'twentytwenty_disallowed_post_types_for_meta_output', array( 'page' ) );
// Check whether the post type is allowed to output post meta.
if ( in_array( get_post_type( $post_id ), $disallowed_post_types, true ) ) {
return;
}
$post_meta_wrapper_classes = '';
$post_meta_classes = '';
// Get the post meta settings for the location specified.
if ( 'single-top' === $location ) {
/**
* Filters post meta info visibility
*
* Use this filter to hide post meta information like Author, Post date, Comments, Is sticky status
*
* @since Twenty Twenty 1.0
*
* @param array $args {
* @type string 'author'
* @type string 'post-date'
* @type string 'comments'
* @type string 'sticky'
* }
*/
$post_meta = apply_filters(
'twentytwenty_post_meta_location_single_top',
array(
'author',
'post-date',
'comments',
'sticky',
)
);
$post_meta_wrapper_classes = ' post-meta-single post-meta-single-top';
} elseif ( 'single-bottom' === $location ) {
/**
* Filters post tags visibility
*
* Use this filter to hide post tags
*
* @since Twenty Twenty 1.0
*
* @param array $args {
* @type string 'tags'
* }
*/
$post_meta = apply_filters(
'twentytwenty_post_meta_location_single_bottom',
array(
'tags',
)
);
$post_meta_wrapper_classes = ' post-meta-single post-meta-single-bottom';
}
// If the post meta setting has the value 'empty', it's explicitly empty and the default post meta shouldn't be output.
if ( $post_meta && ! in_array( 'empty', $post_meta, true ) ) {
// Make sure we don't output an empty container.
$has_meta = false;
global $post;
$the_post = get_post( $post_id );
setup_postdata( $the_post );
ob_start();
?>