<?php 
/* display comments */
if ( ! function_exists( 'mediapulse_comment' ) ) :
	function mediapulse_comment( $comment, $args, $depth ) {
		//get theme data
		global $mediapulse_comment_data;
		//translations
		//$leave_reply = $comment_data['translation_reply_to_coment'] ? $comment_data['translation_reply_to_coment'] : __( 'Reply', 'mediapulse' ); ?>
        <div class="comments">
            <div class="comments-grids">
                <div class="media mb-4">
					<?php echo get_avatar( $comment, $size = '60' ); ?>
                    <div class="media-body comments-grid-right">
                        <h6><?php comment_author(); ?>

                        <small><?php comment_date(); ?></small>
                        </h6>

						<?php comment_text(); ?>

                        <div class="reply">
							<?php comment_reply_link( array_merge( $args, array(
								'reply_text' => "Reply",
								'depth'      => $depth,
								'max_depth'  => $args['max_depth']
							) ) ) ?>
                        </div>

						<?php if ( $comment->comment_approved == '0' ) : ?>
                            <em class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'mediapulse' ); ?></em>
                            <br/>
						<?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
	<?php }
endif;

/* breadcrumb */
if ( ! function_exists( 'mediapulse_breadcrumb' ) ) :
	function mediapulse_breadcrumb() { ?>
        <nav class="breadcrumb bg-transparent m-0 p-0">
			<?php if ( have_posts() ) { ?>
                <ol class="breadcrumb d-flex justify-content-center">
                    <li class="breadcrumb-item">
                        <a href="<?php echo esc_url( home_url() ); ?>"><?php esc_html_e( 'Home', 'mediapulse' ); ?></a>
                    </li>

					<?php if ( is_page() || is_single() ) { ?>
                        <li class="breadcrumb-item " aria-current="page"><?php the_title(); ?></li> <?php } ?>

					<?php if ( is_category() || is_tag() ) { ?>
                        <li class="breadcrumb-item " aria-current="page"><?php echo single_cat_title(); ?></li>
					<?php } ?>

					<?php if ( is_archive() && ! is_tag() && ! is_author() ) { ?>
                        <li class="breadcrumb-item " aria-current="page">
							<?php if ( is_day() ) :
								/* translators: %s: date. */
								printf( esc_html__( 'Daily Archives: %s', 'mediapulse' ), '<span>' . get_the_date() . '</span>' );
                            elseif ( is_month() ) :
								/* translators: %s: month. */
								printf( esc_html__( 'Monthly Archives: %s', 'mediapulse' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'mediapulse' ) ) . '</span>' );
                            elseif ( is_year() ) :
								/* translators: %s: year. */
								printf( esc_html__( 'Yearly Archives: %s', 'mediapulse' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'mediapulse' ) ) . '</span>' );
							else :
								//esc_html_e( 'Archives', 'mediapulse' );
							endif; ?>
                        </li>
					<?php } ?>

					<?php if ( is_search() ) {
						/* translators: %s: search term. */ ?>
                        <li class="breadcrumb-item "
                            aria-current="page"><?php printf( esc_html__( 'Search Results for: %s', 'mediapulse' ), '<span>' . get_search_query() . '</span>' ); ?></li>
					<?php } ?>

					<?php if ( is_author() ) { ?>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo get_the_author(); ?></li>
					<?php } ?>

                </ol>
			<?php } elseif ( is_404() ) { ?>

                <ol class="breadcrumb d-flex justify-content-center">
                    <li class="breadcrumb-item">
                        <a href="<?php echo esc_url( home_url() ); ?>"><?php esc_html_e( 'Home', 'mediapulse' ); ?></a>
                    </li>

                    <li class="breadcrumb-item"><?php esc_html_e( '404 Error', 'mediapulse' ); ?></li>
                </ol>
			<?php } ?>
        </nav>
		<?php
	}
endif;
add_action( 'mediapulse_breadcrumb_area', 'mediapulse_breadcrumb' );

/* widget */
add_action( 'widgets_init', 'mediapulse_register_sidebars' );
function mediapulse_register_sidebars() {
		/* Register the 'primary' sidebar. */
		register_sidebar(
			array(
				'id'            => 'sidebar-primary',
				'name'          => __( 'Primary Sidebar', 'mediapulse' ),
				'description'   => __( 'A sidebar for page and blog pages.', 'mediapulse' ),
				'before_widget' => '<div id="%1$s" class="pb-3 primary">',
				'after_widget'  => '</div>',
				'before_title'  => '<div class="bg-light py-3 px-4 mb-3"><h3 class="m-0">',
				'after_title'   => '</h3></div>',
			)
		);

		$mediapulse_widget = get_theme_mod('footer_widget_layout',3);
		register_sidebar(
			array(
				'id'            => 'footer-widget',
				'name'          => __( 'Footer Widget Area', 'mediapulse' ),
				'description'   => __( 'Sidebar for footer.', 'mediapulse' ),
				'before_widget' => '<div id="%1$s" class="news-widget col-lg-'.$mediapulse_widget.' col-md-6 mb-5">',
				'after_widget'  => '</div>',
				'before_title'  => '<h4 class="font-weight-bold mb-4">',
				'after_title'   => '</h4>',
			)
		);
	}
	
add_action( 'admin_enqueue_scripts', 'mediapulse_admin_enqueue_scripts_callback' );
function mediapulse_admin_enqueue_scripts_callback() {
    if ( ! did_action( 'wp_enqueue_media' ) ) {
	wp_enqueue_media();
    }
    wp_enqueue_script('mediapulse-uploader-js', get_stylesheet_directory_uri() . '/js/uploader.js');
}