<?php
/**
 * Custom Comment Area Modification
 * @package Nextpage
 * @since 1.0.0
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

if ( ! function_exists( 'nextpage_comment_modification' ) ) {
	function nextpage_comment_modification( $comment, $args, $depth ) {
		$GLOBALS['comment'] = $comment; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
		extract( $args, EXTR_SKIP );
		if ( 'div' == $args['style'] ) {
			$tag       = 'div';
			$add_below = 'comment';
		} else {
			$tag       = 'li';
			$add_below = 'div-comment';
		}
		$comment_class = empty( $args['has_children'] ) ? '' : 'parent';

		$nesting_clas = ( $depth > 1 ? 'nesting' : '' );

		?>

        <<?php echo esc_attr( $tag ); ?> <?php comment_class( 'item ' . $comment_class . ' ' ); ?> id="comment-<?php comment_ID() ?>">
		<?php if ( 'div' != $args['style'] ) : ?>
            <div id="div-comment-<?php comment_ID() ?>" class="nextpage-comment">
		<?php endif; ?>


        <div class="media <?php echo esc_attr( $nesting_clas ); ?> commnter-img">
			<?php
			if ( $args['avatar_size'] != 0 ) {
				echo get_avatar( $comment, 100 );
			}
			?>
            <div class="media-body ">
                <h5><span><?php printf( '%s', get_comment_author() ); ?></span></h5>
				<?php printf( '<span class="date">%s</span>', get_comment_date( 'd M Y' ) ); ?>
				<?php comment_text(); ?>
				<?php if ( $comment->comment_approved == '0' ) : ?>
                    <em class="comment-awaiting-moderation"><?php echo esc_html__( 'Your comment is awaiting moderation.', 'nextpage' ); ?></em>
				<?php endif; ?>
				<?php
				comment_reply_link( array_merge( $args, array(
					'reply_text' => esc_html__( 'Reply', 'nextpage' ) . '<i class="la la-arrow-right"></i>',
					'before'     => '',
					'class'      => '',
					'depth'      => $depth,
					'max_depth'  => $args['max_depth']
				) ) );
				?>
            </div>
        </div>

		<?php if ( 'div' != $args['style'] ) : ?>
            </div>
		<?php endif;
	}
}