<?php
/**
 * Custom template tags for this theme
 * Eventually, some of the functionality here could be replaced by core features.
 *
 * @package Equable_Lite
 */


// Prints the posted on date for the blog home page
if ( ! function_exists( 'equable_lite_posted_on' ) ) :	
function equable_lite_posted_on() {
		$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() )
		);
	
		echo '<span class="posted-on">' . $time_string . '</span>'; // WPCS: XSS OK.		
	
	}
endif;
 
 
// Prints the post meta info on the full post view
	if ( ! function_exists( 'equable_lite_single_posted_on' ) ) :
	function equable_lite_single_posted_on() {
		$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() )
		);
		
		
		$byline = sprintf(
			// translators: %s: post author
			esc_html_x( 'by %s', 'post author', 'equable-lite' ),
			'<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">' . $time_string . '</span><span class="byline">' . $byline . '</span>'; // WPCS: XSS OK.

		if ( ! is_singular() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
			echo '<span class="comments-link">';
			/* translators: %s: post title link */
			comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'equable-lite' ), get_the_title() ) );
		echo '</span>';
		}
	}
endif;


if ( ! function_exists( 'equable_lite_entry_footer' ) ) :
	// Prints HTML with meta information for the categories, tags and comments.
	function equable_lite_entry_footer() {
		// Hide category and tag text for pages.
		if ( 'post' === get_post_type() ) {
			// translators: used between list items, there is a space after the comma
			$categories_list = get_the_category_list( esc_html__( ', ', 'equable-lite' ) );
			if ( $categories_list && esc_attr(get_theme_mod( 'equable_lite_show_post_categories', true )) ) {
				// translators: 1: list of categories
				printf( '<p id="category-links"><i class="fa fa-th-large" aria-hidden="true"></i>' . esc_html__( 'Posted in %1$s', 'equable-lite' ) . '</p>', $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_x( ', ', 'list item separator', 'equable-lite' ) );
			if ( $tags_list && esc_attr(get_theme_mod( 'equable_lite_show_post_tags', true ))) {
				// translators: 1: list of tags
				printf( '<p id="tag-links"><i class="fa fa-tags" aria-hidden="true"></i>' . esc_html__( 'Tags %1$s', 'equable-lite' ) . '</p>', $tags_list ); // WPCS: XSS OK.
			}
		}

		if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
			echo '<span class="comments-link">';
			comments_popup_link(
				sprintf(
					wp_kses(
						// translators: %s: post title
						esc_html__( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'equable-lite' ),
						array(
							'span' => array(
								'class' => array(),
							),
						)
					),
					get_the_title()
				)
			);
			echo '</span>';
		}

	}
endif;