<?php get_header(); ?>

<?php global $ulz_explore; ?>

<div class="ulz-container">

	<div class="ulz-row">
		<main class="ulz-main">
			<div class="ulz-content">

				<?php if( function_exists('Ucore') ): ?>

					<?php

						global $wpdb;

						$author = get_queried_object();
						$user = new \UtillzCore\Inc\Src\User( $author->ID );
						$user_avatar = $user->get_avatar();
						$user_cover = $user->get_cover();

					?>

					<?php if( ! ( isset( $_GET['onpage'] ) && (int) $_GET['onpage'] > 1 ) ): ?>
		                <div class="ulz-author-cover">
		                    <div class="ulz--cover<?php if( $user_cover ) { echo ' ulz--has-cover'; } if( $user_avatar ) { echo ' ulz--has-avatar'; } ?>" style="<?php if( $user_cover ) { echo sprintf( 'background-image: url(\'%s\');', $user_cover ); } ?>">
		                        <div class="ulz--inner">
									<div class="ulz--heading">
			                            <div class="ulz--cover-avatar">
											<?php if( $user_avatar ): ?>
			                                    <img src="<?php echo esc_url( $user_avatar ); ?>">
			                                <?php else: ?>
			                                    <i class="ulz--avatar fas fa-user-alt"></i>
			                                <?php endif; ?>
			                            </div>
										<div class="ulz--action">
											<a href="#" class="ulz-button ulz--white" data-modal="conversation" data-params='{"id":<?php echo (int) $author->ID; ?>}'>
												 <span><?php echo sprintf( esc_html__('Contact %s', 'heilz'), $author->display_name ); ?></span>
											</a>
										</div>
		                            </div>
		                            <h5 class="ulz--name">
										<?php echo esc_html( $author->display_name ); ?>
									
										<?php
										$ulz_enable_author_details = get_option('ulz_enable_author_details'); // Get the value of ulz_enable_author_details
										if (!empty($ulz_enable_author_details) && $ulz_enable_author_details == 1) :
										?>
										    <h5 class="ulz--name">
										        <?php if (get_user_meta($author->ID, 'ulz_verified', true)) : ?>
										            <i class="ulz--verified fas fa-check-circle"></i>
										        <?php endif; ?>
										        <a style="color: white; text-decoration: none;" href="mailto:<?php echo esc_attr($author->user_email); ?>">
										            <i class="fas fa-envelope"></i>
										            <?php echo esc_html($author->user_email); ?>
										        </a>
										        <?php if ($author->billing_phone) : ?>
										            <span style="margin-left: 10px;"></span> <!-- Adding a small gap between email and phone -->
										            <?php if (get_user_meta($author->ID, 'ulz_verified', true)) : ?>
										                <i class="ulz--verified fas fa-check-circle"></i>
										            <?php endif; ?>
										            <a style="color: white; text-decoration: none; display: inline-flex; align-items: center;" href="tel:<?php echo esc_attr($author->billing_phone); ?>">
														
										                <i class="fa fa-phone-square" style="margin-left: 10px;"></i>
										                <?php echo esc_html($author->billing_phone); ?>
										            </a></h5>
										        <?php endif; ?>
										
									</h5>
								  <?php endif; ?>
		                            <p class="ulz--bio"><?php echo wp_trim_words( esc_html( get_the_author_meta( 'description', $author->ID ) ), 50, ' ...' ); ?></p>
		                        </div>
		                    </div>
		                </div>
					<?php endif; ?>

					<div class="">
						<h4 class="ulz-mb-3">
							<?php esc_html_e( 'Author\'s listings', 'heilz' ); ?>
						</h4>
					</div>

					<div class="ulz-explore" id="ulz-explore">
					    <div class="ulz-explore-content">
					        <?php Ucore()->the_template('explore/listings'); ?>
					    </div>
					</div>

				<?php else: ?>

					<?php if( have_posts() ): ?>
						<div class="ulz-articles ulz-no-excerpt">
							<div class="ulz-grid">
								<?php while ( have_posts() ) : the_post(); ?>
									<?php get_template_part( 'templates/article' ); ?>
								<?php endwhile; ?>
							</div>
						</div>
						<div class="ulz-paging">
							<?php echo Utheme()->pagination(); ?>
						</div>
					<?php else: ?>
						<?php get_template_part( 'templates/content-none' ); ?>
					<?php endif; ?>

				<?php endif; ?>

			</div>
		</main>
	</div>
</div>

<?php get_footer();
