<?php
/**
 * The template part for displaying the current date and time.
 * 
 * @package Newsxo
 * 
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {	exit; }

if ( ! function_exists( 'newsxo_date_display_type' ) ) :
   
    function newsxo_date_display_type() {
        // Return if date display option is not enabled
        $header_date_enable = esc_attr(get_theme_mod('header_date_enable',true));
        $header_time_enable = esc_attr(get_theme_mod('header_time_enable',true));
        $newsxo_date_time_show_type = get_theme_mod('newsxo_date_time_show_type','newsxo_default');

        echo '<div class="top-date ms-1">';
            if ( $newsxo_date_time_show_type == 'newsxo_default' ) {
            if($header_date_enable == true) { ?>
                <span class="day">
                    <?php echo date_i18n('j M  Y, D', strtotime(current_time("Y-m-d")));?>
                </span>
                <?php } if ($header_time_enable == true) { ?>
                <span id="time" class="time default"></span>
            <?php } } elseif( $newsxo_date_time_show_type == 'wordpress_date_setting') {
                if($header_date_enable == true) { ?>
                    <span class="day">
                        <?php echo date_i18n( get_option( 'date_format' ) ); ?>
                    </span>
                <?php } if ($header_time_enable == true) { ?>
                    <span class="time"> <?php $format = get_option('') . ' ' . get_option('time_format'); print date_i18n($format, current_time('timestamp')); ?></span>
                <?php }
            } 
        echo '</div>';
    }
endif;
add_action('newsxo_action_newsxo_date_time', 'newsxo_date_display_type');

do_action('newsxo_action_newsxo_date_time');