<?php
/**
 * The template part for displaying single-post
 *
 * @package Real Estate Broker
 * @since 1.0
 */
?>
<?php
  $archive_year  = get_the_time('Y');
  $archive_month = get_the_time('m');
  $archive_day   = get_the_time('d');
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('inner-service single-post-page wow bounceInLeft'); ?>>
	<h1><?php the_title(); ?></h1>
	<?php if( get_theme_mod( 'real_estate_realtor_single_post_date',true) != '' || get_theme_mod( 'real_estate_realtor_single_post_author',true) != '' || get_theme_mod( 'real_estate_realtor_single_post_comment',true) != '' || get_theme_mod( 'real_estate_realtor_single_post_time',true) != '') { ?>
		<div class="metabox py-3 mb-3">
    	<?php if( get_theme_mod( 'real_estate_realtor_single_post_date',true) != '') { ?>
      	<span class="entry-date me-1 py-1"><i class="<?php echo esc_attr(get_theme_mod('real_estate_realtor_single_post_date_icon','far fa-calendar-alt')); ?> me-2"></i><a href="<?php echo esc_url( get_day_link( $archive_year, $archive_month, $archive_day)); ?>"><?php echo esc_html( get_the_date() ); ?><span class="screen-reader-text"><?php echo esc_html( get_the_date() ); ?></span></a></span><span class="mx-1"><?php echo esc_html( get_theme_mod('real_estate_realtor_single_post_meta_seperator','|') ); ?></span>
    	<?php }?>
    	<?php if( get_theme_mod( 'real_estate_realtor_single_post_author',true) != '') { ?>
      	<span class="entry-author me-1 py-1"><i class="<?php echo esc_attr(get_theme_mod('real_estate_realtor_single_post_author_icon','fas fa-user')); ?> me-2"></i><a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' )) ); ?>"><?php the_author(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></span><span class="mx-1"><?php echo esc_html( get_theme_mod('real_estate_realtor_single_post_meta_seperator','|') ); ?></span>
    	<?php }?>
    	<?php if( get_theme_mod( 'real_estate_realtor_single_post_comment',true) != '') { ?>
      	<span class="entry-comments me-1 py-1"><i class="<?php echo esc_attr(get_theme_mod('real_estate_realtor_single_post_comment_icon','fas fa-comments')); ?> me-2"></i> <?php comments_number( __('0 Comment', 'real-estate-realtor'), __('0 Comments', 'real-estate-realtor'), __('% Comments', 'real-estate-realtor') ); ?></span><span class="mx-1"><?php echo esc_html( get_theme_mod('real_estate_realtor_single_post_meta_seperator','|') ); ?></span>
    	<?php }?>
    	<?php if( get_theme_mod( 'real_estate_realtor_single_post_time',true) != '' ) { ?>
      		<span class="entry-time me-1 py-1"><i class="<?php echo esc_attr(get_theme_mod('real_estate_realtor_single_post_time_icon','fas fa-clock')); ?> me-2"></i> <?php echo esc_html( get_the_time() ); ?></span>
      <?php }?>
      <?php echo esc_html (real_estate_realtor_edit_link()); ?>
  	</div>
	<?php }?>
	<?php if( get_theme_mod( 'real_estate_realtor_single_post_featured_image',true) != '') { ?>
    <div class="feature-box real-estate-realtor-featured-image">
      <?php the_post_thumbnail(); ?>
    </div>
    <hr>
    <?php } ?>
    <?php if( get_theme_mod('real_estate_realtor_show_hide_single_post_categories',true) != ''){ ?>
	    <div class="category mb-2">
	     <span>Categories :</span><?php the_category(); ?>
	    </div>
  	<?php } ?>
    <?php if( get_theme_mod( 'real_estate_realtor_single_post_tags',true) != '') { ?>
		<div class="tags"><?php the_tags(); ?></div>
	<?php }?>
    <div class="new-text">
      <?php the_content();?>
    </div>
	<?php
	$real_estate_realtor_sale_rent = get_post_meta( get_the_ID(), 'real_estate_realtor_property_sale_rent', true );
	$real_estate_realtor_amount    = get_post_meta( get_the_ID(), 'real_estate_realtor_property_amount', true );
	$real_estate_realtor_beds      = get_post_meta( get_the_ID(), 'real_estate_realtor_property_bed', true );
	$real_estate_realtor_baths     = get_post_meta( get_the_ID(), 'real_estate_realtor_property_baths', true );
	$real_estate_realtor_sqft      = get_post_meta( get_the_ID(), 'real_estate_realtor_property_sqft', true );

	// Only show if any field is filled
	if ( $real_estate_realtor_sale_rent || $real_estate_realtor_amount || $real_estate_realtor_beds || $real_estate_realtor_baths || $real_estate_realtor_sqft ) : ?>
		<div class="property-meta d-flex gap-3 mt-4 p-3 border rounded">
			<?php if ( $real_estate_realtor_sale_rent ) : ?>
				<p><strong><?php esc_html_e('Sale Type:', 'real-estate-realtor'); ?></strong> <?php echo esc_html($real_estate_realtor_sale_rent); ?></p>
			<?php endif; ?>

			<?php if ( $real_estate_realtor_amount ) : ?>
				<p><strong><?php esc_html_e('Price:', 'real-estate-realtor'); ?></strong> <?php echo esc_html($real_estate_realtor_amount); ?></p>
			<?php endif; ?>

			<?php if ( $real_estate_realtor_beds ) : ?>
				<p><strong><?php esc_html_e('Beds:', 'real-estate-realtor'); ?></strong> <?php echo esc_html($real_estate_realtor_beds); ?></p>
			<?php endif; ?>

			<?php if ( $real_estate_realtor_baths ) : ?>
				<p><strong><?php esc_html_e('Baths:', 'real-estate-realtor'); ?></strong> <?php echo esc_html($real_estate_realtor_baths); ?></p>
			<?php endif; ?>

			<?php if ( $real_estate_realtor_sqft ) : ?>
				<p><strong><?php esc_html_e('Sqft:', 'real-estate-realtor'); ?></strong> <?php echo esc_html($real_estate_realtor_sqft); ?></p>
			<?php endif; ?>
		</div>
	<?php endif; ?>
	<?php
	$real_estate_realtor_noof_property = get_post_meta( $post->ID, 'real_estate_broker_noof_property', true );
    $real_estate_realtor_property_detail = get_post_meta( $post->ID, 'real_estate_broker_property_detail', true );
    $real_estate_realtor_property_price = get_post_meta( $post->ID, 'real_estate_broker_property_price', true );
	if ( $real_estate_realtor_noof_property || $real_estate_realtor_property_detail || $real_estate_realtor_property_price ) : ?>
		<div id="testimonials_custom_stuff">
			<table id="list">
				<tbody id="the-list" data-wp-lists="list:meta">
					<tr id="meta-8">
						<td class="left">
							<?php esc_html_e( 'No. of Properties', 'real-estate-broker' )?>
						</td>
						<td class="left">
							<input type="text" name="real_estate_broker_noof_property" id="real_estate_broker_noof_property" value="<?php echo esc_attr($real_estate_realtor_noof_property); ?>" />
						</td>
					</tr>
					<tr id="meta-8">
						<td class="left">
							<?php esc_html_e( 'Property Detail', 'real-estate-broker' )?>
						</td>
						<td class="left">
							<input type="text" name="real_estate_broker_property_detail" id="real_estate_broker_property_detail" value="<?php echo esc_attr($real_estate_realtor_property_detail); ?>" />
						</td>
					</tr>
					<tr id="meta-8">
						<td class="left">
							<?php esc_html_e( 'Price', 'real-estate-broker' )?>
						</td>
						<td class="left">
							<input type="text" name="real_estate_broker_property_price" id="real_estate_broker_property_price" value="<?php echo esc_attr($real_estate_realtor_property_price); ?>" />
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	<?php endif; ?>
    <?php if( get_theme_mod( 'real_estate_realtor_enable_single_post_pagination',true) != '') { ?>
	    <?php
			if ( is_singular( 'attachment' ) ) {
				// Parent post navigation.
				the_post_navigation( array(
					'prev_text' => _x( '<span class="meta-nav">Published in</span><span class="post-title">%title</span>', 'Parent post link', 'real-estate-realtor' ),
				) );
			} elseif ( is_singular( 'post' ) ) {
				if( get_theme_mod( 'real_estate_realtor_enable_single_post_pagination',true) != '') {
				// Previous/next post navigation.
				the_post_navigation( array(
					'next_text' => '<span class="meta-nav" aria-hidden="true">' . esc_html(get_theme_mod('real_estate_realtor_next_text',__( 'Next page', 'real-estate-realtor' ))) . '</span> ' .
						'<span class="screen-reader-text">' . __( 'Newer Posts', 'real-estate-realtor' ) . '</span> ' .
						'<span class="post-title">%title</span>',
					'prev_text' => '<span class="meta-nav" aria-hidden="true">' . esc_html(get_theme_mod('real_estate_realtor_prev_text',__( 'Previous page', 'real-estate-realtor' ))) . '</span> ' .
						'<span class="screen-reader-text">' . __( 'Older Posts', 'real-estate-realtor' ) . '</span> ' .
						'<span class="post-title">%title</span>',
				) );
			}
			}	
			echo '<div class="clearfix"></div>';?>

	<?php } ?>
	<?php
	// If comments are open or we have at least one comment, load up the comment template.
	if ( comments_open() || get_comments_number() ) {
		comments_template();
	} ?>

	<?php get_template_part('template-parts/related-posts'); ?>
</article>
