<?php
/**
* Post meta functions
*
* @package GridMini WordPress Theme
* @copyright Copyright (C) 2025 ThemesDNA
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
* @author ThemesDNA <themesdna@gmail.com>
*/

function gridmini_post_cat_links_text() {
    if ( gridmini_is_option_set('cat_links_text') ) {
        $cat_links_text = gridmini_get_option('cat_links_text');
    } else {
        $cat_links_text = esc_html__( 'Posted in', 'gridmini' );
    }
    return apply_filters( 'gridmini_post_cat_links_text', $cat_links_text );
}


function gridmini_post_tag_links_text() {
    if ( gridmini_is_option_set('tag_links_text') ) {
        $tag_links_text = gridmini_get_option('tag_links_text');
    } else {
        $tag_links_text = esc_html__( 'Tagged', 'gridmini' );
    }
    return apply_filters( 'gridmini_post_tag_links_text', $tag_links_text );
}


if ( ! function_exists( 'gridmini_post_tags' ) ) :
/**
 * Prints HTML with meta information for the tags.
 */
function gridmini_post_tags() {
    if ( 'post' == get_post_type() ) {
        /* translators: used between list items, there is a space after the comma */
        $tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'gridmini' ) );
        if ( $tags_list ) {
            /* translators: 1: list of tags. */
            printf( '<span class="gridmini-tags-links"><i class="fas fa-tags" aria-hidden="true"></i> ' . esc_html__( 'Tagged %1$s', 'gridmini' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
        }
    }
}
endif;


if ( ! function_exists( 'gridmini_grid_cats' ) ) :
function gridmini_grid_cats() {
    global $post;
    if ( !(gridmini_get_option('hide_post_categories_home')) && has_category() ) {
        if ( 'post' == get_post_type() ) {
            /* translators: used between list items, there is a space */
            $categories_list = get_the_category_list( esc_html__( '&nbsp;', 'gridmini' ) );
            if ( $categories_list ) {
                /* translators: 1: list of categories. */
                printf( '<div class="gridmini-grid-post-categories gridmini-grid-post-block">' . __( '<span class="gridmini-sr-only">Posted in </span>%1$s', 'gridmini' ) . '</div>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
            }
        }
    }
}
endif;


if ( ! function_exists( 'gridmini_single_cats' ) ) :
function gridmini_single_cats() {
    if ( 'post' == get_post_type() ) {
        /* translators: used between list items, there is a space */
        $categories_list = get_the_category_list( esc_html__( ', ', 'gridmini' ) );
        if ( $categories_list ) {
            /* translators: 1: list of categories. */
            printf( '<span class="gridmini-entry-meta-single-cats"><i class="far fa-folder-open" aria-hidden="true"></i>&nbsp;' . __( '<span class="gridmini-sr-only">Posted in </span>%1$s', 'gridmini' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
        }
    }
}
endif;


if ( ! function_exists( 'gridmini_single_postmeta' ) ) :
function gridmini_single_postmeta() { ?>
    <?php global $post; ?>
    <?php if ( !(gridmini_get_option('hide_post_author')) || !(gridmini_get_option('hide_posted_date')) || !(gridmini_get_option('hide_comments_link')) || !(gridmini_get_option('hide_post_categories')) || !(gridmini_get_option('hide_post_edit')) ) { ?>
    <div class="gridmini-entry-meta-single">
    <?php if ( !(gridmini_get_option('hide_post_author')) ) { ?><span class="gridmini-entry-meta-single-author"><i class="far fa-user-circle" aria-hidden="true"></i>&nbsp;<span class="author vcard" itemscope="itemscope" itemtype="http://schema.org/Person" itemprop="author"><a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo esc_html( get_the_author() ); ?></a></span></span><?php } ?>
    <?php if ( !(gridmini_get_option('hide_posted_date')) ) { ?><span class="gridmini-entry-meta-single-date"><i class="far fa-clock" aria-hidden="true"></i>&nbsp;<?php echo esc_html( get_the_date() ); ?></span><?php } ?>
    <?php if ( !(gridmini_get_option('hide_comments_link')) ) { ?><?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { ?>
    <span class="gridmini-entry-meta-single-comments"><i class="far fa-comments" aria-hidden="true"></i>&nbsp;<?php comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __( 'Leave a Comment<span class="gridmini-sr-only"> on %s</span>', 'gridmini' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ) ); ?></span>
    <?php } ?><?php } ?>
    <?php if ( !(gridmini_get_option('hide_post_categories')) ) { ?><?php gridmini_single_cats(); ?><?php } ?>
    <?php if ( !(gridmini_get_option('hide_post_edit')) ) { ?><?php edit_post_link( sprintf( wp_kses( /* translators: %s: Name of current post. Only visible to screen readers */ __( 'Edit<span class="gridmini-sr-only"> %s</span>', 'gridmini' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ), '<span class="edit-link">&nbsp;&nbsp;<i class="far fa-edit" aria-hidden="true"></i> ', '</span>' ); ?><?php } ?>
    </div>
    <?php } ?>
<?php }
endif;


if ( ! function_exists( 'gridmini_page_postmeta' ) ) :
function gridmini_page_postmeta() { ?>
    <?php global $post; ?>
    <?php if ( !(gridmini_get_option('hide_page_author')) || !(gridmini_get_option('hide_page_date')) || !(gridmini_get_option('hide_page_comments')) ) { ?>
    <?php if ( !((is_front_page()) && (gridmini_get_option('hide_static_page_meta'))) ) { ?>
    <div class="gridmini-entry-meta-single">
    <?php if ( !(gridmini_get_option('hide_page_author')) ) { ?><span class="gridmini-entry-meta-single-author"><i class="far fa-user-circle" aria-hidden="true"></i>&nbsp;<span class="author vcard" itemscope="itemscope" itemtype="http://schema.org/Person" itemprop="author"><a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo esc_html( get_the_author() ); ?></a></span></span><?php } ?>
    <?php if ( !(gridmini_get_option('hide_page_date')) ) { ?><span class="gridmini-entry-meta-single-date"><i class="far fa-clock" aria-hidden="true"></i>&nbsp;<?php echo esc_html( get_the_date() ); ?></span><?php } ?>
    <?php if ( !(gridmini_get_option('hide_page_comments')) ) { ?><?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { ?>
    <span class="gridmini-entry-meta-single-comments"><i class="far fa-comments" aria-hidden="true"></i>&nbsp;<?php comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __( 'Leave a Comment<span class="gridmini-sr-only"> on %s</span>', 'gridmini' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ) ); ?></span>
    <?php } ?><?php } ?>
    </div>
    <?php } ?>
    <?php } ?>
<?php }
endif;


if ( ! function_exists( 'gridmini_grid_media_bottom_data' ) ) :
function gridmini_grid_media_bottom_data() { ?>
    <?php global $post; ?>
    <?php if ( (!(gridmini_get_option('hide_post_categories_home')) && has_category()) || !(gridmini_get_option('hide_post_title_home')) || !(gridmini_get_option('hide_post_author_home')) || !(gridmini_get_option('hide_posted_date_home')) || (!(gridmini_get_option('hide_comments_link_home')) && (! post_password_required() && ( comments_open() || get_comments_number() ))) ) { ?>
    <div class="gridmini-thumbnail-overlay gridmini-clearfix">

    <?php if ( !(gridmini_get_option('hide_post_categories_home')) && has_category() ) { ?><?php gridmini_grid_cats(); ?><?php } ?>

    <?php if ( !(gridmini_get_option('hide_post_title_home')) ) { ?>
    <?php if ( gridmini_get_option('post_title_link_home') == 'no' ) { ?>
        <div class="gridmini-grid-post-header gridmini-grid-post-block gridmini-clearfix"><?php the_title( '<h3 class="gridmini-grid-post-title">', '</h3>' ); ?></div>
    <?php } else { ?>
        <div class="gridmini-grid-post-header gridmini-grid-post-block gridmini-clearfix"><?php the_title( sprintf( '<h3 class="gridmini-grid-post-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' ); ?></div>
    <?php } ?>
    <?php } ?>

    <?php if ( !(gridmini_get_option('hide_post_author_home')) || !(gridmini_get_option('hide_posted_date_home')) || (!(gridmini_get_option('hide_comments_link_home')) && (! post_password_required() && ( comments_open() || get_comments_number() ))) ) { ?>
    <div class="gridmini-grid-post-details gridmini-grid-post-block">
    <div class="gridmini-grid-post-details-inside">
    <?php if ( !(gridmini_get_option('hide_post_author_home')) ) { ?><span class="gridmini-grid-post-author gridmini-grid-post-meta"><a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo esc_html( get_the_author() ); ?></a></span><?php } ?>
    <?php if ( !(gridmini_get_option('hide_posted_date_home')) ) { ?><span class="gridmini-grid-post-date gridmini-grid-post-meta"><?php echo esc_html( get_the_date() ); ?></span><?php } ?>
    <?php if ( !(gridmini_get_option('hide_comments_link_home')) && (! post_password_required() && ( comments_open() || get_comments_number() )) ) { ?><span class="gridmini-grid-post-comments gridmini-grid-post-meta"><?php comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __( '0 Comment<span class="gridmini-sr-only"> on %s</span>', 'gridmini' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ) ); ?></span><?php } ?>
    </div>
    </div>
    <?php } ?>

    </div>
    <?php } ?>
<?php }
endif;