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

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

if ( ! function_exists( 'wrockmetro_posted_on' ) ) {
	/**
	 * Prints HTML with meta information for the current post-date/time and author.
	 */
	function wrockmetro_posted_on() {
		$post = get_post();
		if ( ! $post ) {
			return;
		}

		$time_string = '<time class="entry-date published updated" '.wrockmetro_get_schema( 'published_date' ).' datetime="%1$s">%2$s</time>';

		// if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		// 	$time_string = '<time class="entry-date published" '.wrockmetro_get_schema( 'modified_date' ).' 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' ) ), // @phpstan-ignore-line -- post exists
			esc_html( get_the_date() ) // @phpstan-ignore-line -- post exists
		);

		// $time_string = sprintf(
		// 	$time_string,
		// 	esc_attr( get_the_date( 'c' ) ), // @phpstan-ignore-line -- post exists
		// 	esc_html( get_the_date() ), // @phpstan-ignore-line -- post exists
		// 	esc_attr( get_the_modified_date( 'c' ) ), // @phpstan-ignore-line -- post exists
		// 	esc_html( get_the_modified_date() ) // @phpstan-ignore-line -- post exists
		// );
		$single_meta_option = get_theme_mod('wrockmetro_single_meta', 'enable');
		$blog_meta_option = get_theme_mod('wrockmetro_blog_date', 'enable');

		if (is_single() && $single_meta_option == 'enable') {
			$posted_on = apply_filters(
				'wrockmetro_posted_on',
				sprintf(
					'<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>',
					esc_html_x('', 'post date', 'wrock-metro'),
					esc_url(get_permalink()),
					apply_filters('wrockmetro_posted_on_time', $time_string)
				)
			);

			echo $posted_on;
		} elseif ( ! is_single() && $blog_meta_option == 'enable' ) {
			$posted_on = apply_filters(
				'wrockmetro_posted_on',
				sprintf(
					'<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>',
					esc_html_x('', 'post date', 'wrock-metro'),
					esc_url(get_permalink()),
					apply_filters('wrockmetro_posted_on_time', $time_string)
				)
			);

			echo $posted_on;
        }  
		// $posted_on = apply_filters(
			// 'wrockmetro_posted_on',
			// sprintf(
				// '<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>',
				// esc_html_x( '', 'post date', 'wrock-metro' ),
				// esc_url( get_permalink() ), // @phpstan-ignore-line -- post exists
				// apply_filters( 'wrockmetro_posted_on_time', $time_string )
			// )
		// );
		$single_meta_author = get_theme_mod('wrockmetro_singlemeta_author', 'enable');
		$blog_meta_author = get_theme_mod('wrockmetro_blogmeta_author', 'enable');

		if (is_single() && $single_meta_author === 'enable') {
			$author_id = (int) get_the_author_meta( 'ID' );
			if ( 0 === $author_id ) {
				$byline = '';
			} else {
				$byline = apply_filters(
					'wrockmetro_posted_by',sprintf(
					'<span class="byline"> %1$s<span class="author vcard" '.wrockmetro_get_schema( 'author_name' ).'> <a class="url fn n" href="%2$s">%3$s</a></span></span>',
					esc_html_x('', 'post author', 'wrock-metro'),
					esc_url(get_author_posts_url($author_id)),
					esc_html(get_the_author_meta('display_name', $author_id))
				)
					// 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( '', 'post author', 'wrock-metro' ) : esc_html_x( '', 'post author', 'wrock-metro' ),
						// esc_url( get_author_posts_url( $author_id ) ),
						// esc_html( get_the_author_meta( 'display_name', $author_id ) )
					// )
				);
			}
		 echo $byline;
		}
		
		if ( ! is_single() && $blog_meta_author === 'enable') {
			$author_id = (int) get_the_author_meta( 'ID' );
			if ( 0 === $author_id ) {
				$byline = '';
			} else {
				$byline = apply_filters(
					'wrockmetro_posted_by',sprintf(
					'<span class="byline"> %1$s<span class="author vcard" '.wrockmetro_get_schema( 'author_name' ).'> <a class="url fn n" href="%2$s">%3$s</a></span></span>',
					esc_html_x('', 'post author', 'wrock-metro'),
					esc_url(get_author_posts_url($author_id)),
					esc_html(get_the_author_meta('display_name', $author_id))
				)
					// 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( '', 'post author', 'wrock-metro' ) : esc_html_x( '', 'post author', 'wrock-metro' ),
						// esc_url( get_author_posts_url( $author_id ) ),
						// esc_html( get_the_author_meta( 'display_name', $author_id ) )
					// )
				);
			}
		 echo $byline;
		}

		// if (get_theme_mod('wrockmetro_single_meta') == 'enable') { echo $posted_on; }
		  //if (get_theme_mod('wrockmetro_singlemeta_author') == 'enable') { echo $byline; }
		 
		 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	}
}

if ( ! function_exists( 'wrockmetro_entry_footer' ) ) {
	/**
	 * Prints HTML with meta information for the categories, tags and comments.
	 */
	function wrockmetro_entry_footer() {
		// Hide category and tag text for pages.
		if ( 'post' === get_post_type() ) {
			wrockmetro_categories_tags_list();
		}		
		wrockmetro_edit_post_link();
	}
}

if ( ! function_exists( 'wrockmetro_categories_tags_list' ) ) {
	/**
	 * Displays a list of categories and a list of tags.
	 *
	 * @since 1.2.0
	 */
	function wrockmetro_categories_tags_list() {
		// if (get_theme_mod('wrockmetro_singlemeta_category') == 'enable') {
		// 	wrockmetro_categories_list();
		// }

		if ( is_single() && get_theme_mod('wrockmetro_singlemeta_category') == 'enable' ) {
            wrockmetro_categories_list();
        }
        // Check if it's not a single post (blog/archive page) and the blog meta category option is enabled
        elseif ( ! is_single() && get_theme_mod('wrockmetro_blogmeta_category') == 'enable' ) {
            wrockmetro_categories_list();
        }  

		if ( is_single() && get_theme_mod('wrockmetro_singlemeta_tags') == 'enable' ) {
			wrockmetro_tags_list();
        }
        // Check if it's not a single post (blog/archive page) and the blog meta category option is enabled
        elseif ( ! is_single() && get_theme_mod('wrockmetro_blogmeta_tags') == 'enable' ) {
            wrockmetro_tags_list();
        }  

		// if (get_theme_mod('wrockmetro_singlemeta_tags') == 'enable') {
		// 	wrockmetro_tags_list();
		// }
	}
}

if ( ! function_exists( 'wrockmetro_categories_list' ) ) {
	/**
	 * Displays a list of categories.
	 *
	 * @since 1.2.0
	 */
	function wrockmetro_categories_list() {
		$categories_list = get_the_category_list( wrockmetro_get_list_item_separator() );
		if ( $categories_list && wrockmetro_categorized_blog() ) {
			/* translators: %s: Categories of current post */
			printf( '<span class="cat-links">' . esc_html__( '%s', 'wrock-metro' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		}
	}
}

if ( ! function_exists( 'wrockmetro_tags_list' ) ) {
	/**
	 * Displays a list of tags.
	 *
	 * @since 1.2.0
	 */
	function wrockmetro_tags_list() {
		$tags_list = get_the_tag_list( '', wrockmetro_get_list_item_separator() );
		if ( $tags_list && ! is_wp_error( $tags_list ) ) {
			/* translators: %s: Tags of current post */
			printf( '<span class="tags-links">' . esc_html__( '%s', 'wrock-metro' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		}
	}
}

if ( ! function_exists( 'wrockmetro_comments_popup_link' ) ) {
	/**
	 * Displays the link to the comments for the current post.
	 *
	 * @since 1.2.0
	 */
	function wrockmetro_comments_popup_link() {
		if ( is_single() || post_password_required() || ( ! comments_open() && 0 === absint( get_comments_number() ) ) ) {
			return;
		}

		$post_title    = get_the_title();
		$leave_comment = sprintf(
			/* translators: %s post title */
			__( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'wrock-metro' ),
			$post_title
		);
		$leave_comment = wp_kses( $leave_comment, array( 'span' => array( 'class' => true ) ) );

		echo '<span class="comments-link">';
		comments_popup_link( $leave_comment );
		echo '</span>';
	}
}

if ( ! function_exists( 'wrockmetro_categorized_blog' ) ) {
	/**
	 * Returns true if a blog has more than 1 category.
	 *
	 * @return bool
	 */
	function wrockmetro_categorized_blog() {
		$all_the_cool_cats = get_transient( 'wrockmetro_categories' );
		if ( false === $all_the_cool_cats ) {
			// Create an array of all the categories that are attached to posts.
			$all_the_cool_cats = get_categories(
				array(
					'fields'     => 'ids',
					'hide_empty' => 1,
					// We only need to know if there is more than one category.
					'number'     => 2,
				)
			);
			// Count the number of categories that are attached to the posts.
			$all_the_cool_cats = count( $all_the_cool_cats );
			set_transient( 'wrockmetro_categories', $all_the_cool_cats );
		}
		if ( $all_the_cool_cats > 1 ) {
			// This blog has more than 1 category so wrockmetro_categorized_blog should return true.
			return true;
		}
		// This blog has only 1 category so wrockmetro_categorized_blog should return false.
		return false;
	}
}

add_action( 'delete_category', 'wrockmetro_category_transient_flusher' );
add_action( 'save_post', 'wrockmetro_category_transient_flusher' );
add_action( 'trashed_post', 'wrockmetro_category_transient_flusher' );
add_action( 'deleted_post', 'wrockmetro_category_transient_flusher' );

if ( ! function_exists( 'wrockmetro_category_transient_flusher' ) ) {
	/**
	 * Flush out the transients used in wrockmetro_categorized_blog.
	 */
	function wrockmetro_category_transient_flusher() {
		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
			return;
		}
		// Like, beat it. Dig?
		delete_transient( 'wrockmetro_categories' );
	}
}

if ( ! function_exists( 'wrockmetro_body_attributes' ) ) {
	/**
	 * Displays the attributes for the body element.
	 */
	function wrockmetro_body_attributes() {
		/**
		 * Filters the body attributes.
		 *
		 * @param array $atts An associative array of attributes.
		 */
		$atts = array_unique( apply_filters( 'wrockmetro_body_attributes', $atts = array() ) );
		if ( ! is_array( $atts ) || empty( $atts ) ) {
			return;
		}

		$attributes = '';
		foreach ( $atts as $name => $value ) {
			if ( $value ) {
				if ( ! is_string( $value ) ) {
					continue;
				}
				$attributes .= sanitize_key( $name ) . '="' . esc_attr( $value ) . '" ';
			} else {
				$attributes .= sanitize_key( $name ) . ' ';
			}
		}

		echo trim( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput
	}
}

if ( ! function_exists( 'wrockmetro_comment_navigation' ) ) {
	/**
	 * Displays the comment navigation.
	 *
	 * @since 1.0.0
	 *
	 * @param string $nav_id The ID of the comment navigation.
	 */
	function wrockmetro_comment_navigation( $nav_id ) {
		if ( get_comment_pages_count() <= 1 ) {
			// Return early if there are no comments to navigate through.
			return;
		}
		?>
		<nav class="comment-navigation" id="<?php echo esc_attr( $nav_id ); ?>">

			<h1 class="screen-reader-text"><?php esc_html_e( 'Comments navigation', 'wrock-metro' ); ?></h1>

			<?php if ( get_previous_comments_link() ) { ?>
				<div class="nav-previous">
					<?php previous_comments_link( __( '&larr; Older Comments', 'wrock-metro' ) ); ?>
				</div>
			<?php } ?>

			<?php if ( get_next_comments_link() ) { ?>
				<div class="nav-next">
					<?php next_comments_link( __( 'Newer Comments &rarr;', 'wrock-metro' ) ); ?>
				</div>
			<?php } ?>

		</nav><!-- #<?php echo esc_attr( $nav_id ); ?> -->
		<?php
	}
}

if ( ! function_exists( 'wrockmetro_edit_post_link' ) ) {
	/**
	 * Displays the edit post link for post.
	 *
	 * @since 1.0.0
	 */
	function wrockmetro_edit_post_link() {
		edit_post_link(
			sprintf(
				/* translators: %s: Name of current post */
				esc_html__( 'Edit %s', 'wrock-metro' ),
				the_title( '<span class="screen-reader-text">"', '"</span>', false )
			),
			'<span class="edit-link">',
			'</span>'
		);
	}
}

if ( ! function_exists( 'wrockmetro_post_nav' ) ) {
	/**
	 * Display navigation to next/previous post when applicable.
	 *
	 * @global WP_Post|null $post The current post.
	 */
	function wrockmetro_post_nav() {
		global $post;
		if ( ! $post ) {
			return;
		}

		// Don't print empty markup if there's nowhere to navigate.
		$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
		$next     = get_adjacent_post( false, '', false );
		if ( ! $next && ! $previous ) {
			return;
		}
		?>
		<nav class="container navigation post-navigation">
			<h2 class="screen-reader-text"><?php esc_html_e( 'Post navigation', 'wrock-metro' ); ?></h2>				
			<?php if(get_theme_mod( 'wrockmetro_postnavi_style') =='styleone'){ ?>
			
			<div class="d-flex nav-links justify-content-between">
				<?php
				if ( get_previous_post_link() ) {
					previous_post_link( '<span class="nav-previous">%link</span>', _x( '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-double-left" viewBox="0 0 16 20"><path fill-rule="evenodd" d="M8.354 1.646a.5.5 0 0 1 0 .708L2.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"/><path fill-rule="evenodd" d="M12.354 1.646a.5.5 0 0 1 0 .708L6.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"/></svg>&nbsp;%title', 'Previous post link', 'wrock-metro' ) );
				}
				if ( get_next_post_link() ) {
					next_post_link( '<span class="nav-next">%link</span>', _x( '%title&nbsp;<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-double-right" viewBox="0 0 16 20"><path fill-rule="evenodd" d="M3.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L9.293 8 3.646 2.354a.5.5 0 0 1 0-.708"/><path fill-rule="evenodd" d="M7.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L13.293 8 7.646 2.354a.5.5 0 0 1 0-.708"/></svg>', 'Next post link', 'wrock-metro' ) );
				}
				?></div>
			<?php } elseif (get_theme_mod( 'wrockmetro_postnavi_style') =='styletwo'){ ?>
			<div id="NextPrevPosts">
				<?php 	
			if ( $prev_post = get_previous_post() ) {
				$prev_post_thumbnail = get_the_post_thumbnail( $prev_post->ID, array( 75, 75) ); // Change 'thumbnail' to your desired image size
				$prev_post_title = $prev_post->post_title;
				$prev_post_link = get_permalink( $prev_post->ID );

				echo '<a href="' . esc_url( $prev_post_link ) . '"><div class="prev">';
				echo '<div class="arrow">';
				echo '<svg version="1.1" id="PrevArrow" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 11.289 27.701" enable-background="new 0 0 11.289 27.701" xml:space="preserve"><polyline fill="none" stroke="#232323" opacity="0.4" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" points="9.501,26.201 1.499,13.851 9.501,1.5 "></polyline></svg>';
				echo '</div>';
				echo '<div class="preview">';
				echo '<div class="pull-left featuredImg">' . $prev_post_thumbnail . '</div>';
				echo '<div class="pull-left preview-content">' . esc_html( $prev_post_title ) . '</div></div></div></a>';
			}

			if ( $next_post = get_next_post() ) {
					$next_post_thumbnail = get_the_post_thumbnail( $next_post->ID, array( 75, 75) ); // Change 'thumbnail' to your desired image size
					$next_post_title = $next_post->post_title;
					$next_post_link = get_permalink( $next_post->ID );

					echo '<a href="' . esc_url( $next_post_link ) . '"><div class="next">';
					echo '<div class="arrow">';
					echo '<svg version="1.1" id="NextArrow" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 11.289 27.701" enable-background="new 0 0 11.289 27.701" xml:space="preserve"><polyline fill="none" stroke="#232323" opacity="0.4" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" points="1.5,1.5 9.502,13.85 1.5,26.201 "></polyline></svg>';
					echo '</div>';
					echo '<div class="preview"><div class="pull-right featuredImg">' . $next_post_thumbnail . '</div>';
					echo '<div class="pull-right preview-content">' . esc_html( $next_post_title ) . '</div></div></div></a>';
				}
		 ?>
		</div>
		<?php } elseif (get_theme_mod( 'wrockmetro_postnavi_style') =='stylethree'){ ?>
			<div class="d-flex nav-links justify-content-between stylethree">
				<?php 
				if ( $prev_post = get_previous_post() ) {
				$prev_post_link = get_permalink( $prev_post->ID );

				echo '<a href="' . esc_url( $prev_post_link ) . '"><div class="stylethreepre">';
				echo '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/></svg>';
				echo esc_attr('&nbsp;Previous Post','wrock-metro') . '</div></a>';
			}
				if ( $next_post = get_next_post() ) {					
					$next_post_link = get_permalink( $next_post->ID );
					echo '<a href="' . esc_url( $next_post_link ) . '"><div class="stylethreenext">';
					echo esc_attr('Next Post&nbsp;','wrock-metro');
					echo '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/></svg>';
					echo '</div></a>';
				}
				?>
				</div>
				<?php } elseif (get_theme_mod( 'wrockmetro_postnavi_style') =='stylefour'){ ?>
			<div class="row stylefour">
				<?php 	
			if ( $prev_post = get_previous_post() ) {
				$prev_post_thumbnail = get_the_post_thumbnail( $prev_post->ID, array( 75, 75) ); // Change 'thumbnail' to your desired image size
				$prev_post_title = $prev_post->post_title;
				$prev_post_link = get_permalink( $prev_post->ID );

				echo '<div class="col-6"><a href="' . esc_url( $prev_post_link ) . '"><div class="row stylefourprev border">';
				echo '<div class="col leftImg">' . $prev_post_thumbnail . '</div>';
				echo '<div class="col-9 left-content"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/></svg> ' . esc_html( $prev_post_title ) . '</div></div></a></div>';
			}

			if ( $next_post = get_next_post() ) {
					$next_post_thumbnail = get_the_post_thumbnail( $next_post->ID, array( 75, 75) ); // Change 'thumbnail' to your desired image size
					$next_post_title = $next_post->post_title;
					$next_post_link = get_permalink( $next_post->ID );

					echo '<div class="col-6"><a href="' . esc_url( $next_post_link ) . '"><div class="row stylefournext border">';						
					echo '<div class="col-9 right-content">' . esc_html( $next_post_title ) . ' <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/></svg></div>';
					echo '<div class="col rightimg">' . $next_post_thumbnail . '</div>';
					echo '</div></a></div>';
				}
		 ?>
		</div>
			<?php } else { ?>
			<div class="d-flex nav-links justify-content-between">
				<?php if ( get_previous_post_link() ) {
					previous_post_link( '<span class="nav-previous">%link</span>', _x( '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-double-left" viewBox="0 0 16 20"><path fill-rule="evenodd" d="M8.354 1.646a.5.5 0 0 1 0 .708L2.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"/><path fill-rule="evenodd" d="M12.354 1.646a.5.5 0 0 1 0 .708L6.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"/></svg>&nbsp;%title', 'Previous post link', 'wrock-metro' ) );
				}
				if ( get_next_post_link() ) {
					next_post_link( '<span class="nav-next">%link</span>', _x( '%title&nbsp;<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-double-right" viewBox="0 0 16 20"><path fill-rule="evenodd" d="M3.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L9.293 8 3.646 2.354a.5.5 0 0 1 0-.708"/><path fill-rule="evenodd" d="M7.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L13.293 8 7.646 2.354a.5.5 0 0 1 0-.708"/></svg>', 'Next post link', 'wrock-metro' ) );
				}
				?>
				</div>
			<?php } ?>
			<!-- .nav-links -->
		</nav><!-- .post-navigation -->
		<?php
	}
}

if ( ! function_exists( 'wrockmetro_link_pages' ) ) {
	/**
	 * Displays/retrieves page links for paginated posts (i.e. including the
	 * `<!--nextpage-->` Quicktag one or more times). This tag must be
	 * within The Loop. Default: echo.
	 *
	 * @since 1.0.0
	 *
	 * @return void|string Formatted output in HTML.
	 */
	function wrockmetro_link_pages() {
		$args = apply_filters(
			'wrockmetro_link_pages_args',
			array(
				'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'wrock-metro' ),
				'after'  => '</div>',
			)
		);
		wp_link_pages( $args );
	}
}

if ( ! function_exists( 'wrockmetro_get_select_control_class' ) ) {
	/**
	 * Retrieves the Bootstrap CSS class for the select tag.
	 *
	 * @since 1.2.0
	 *
	 * @return string Bootstrap CSS class for the select tag.
	 */
	function wrockmetro_get_select_control_class() {
		/* if ( 'bootstrap4' === get_theme_mod( 'wrockmetro_bootstrap_version', 'bootstrap4' ) ) {
			return 'form-control';
		} */
		return 'form-select';
	}
}

if ( ! function_exists( 'wrockmetro_get_list_item_separator' ) ) {
	/**
	 * Retrieves the localized list item separator.
	 *
	 * `wp_get_list_item_separator()` has been introduced in WP 6.0.0. For WP
	 * versions lower than 6.0.0 we have to use a custom translation.
	 *
	 * @since 1.2.0
	 *
	 * @return string Localized list item separator.
	 */
	function wrockmetro_get_list_item_separator() {
		if ( function_exists( 'wp_get_list_item_separator' ) ) {
			return esc_html( wp_get_list_item_separator() );
		}
		/* translators: used between list items, there is a space after the comma */
		return esc_html__( ', ', 'wrock-metro' );
	}
}
