<?php
/**
 * Template part for displaying the services section
 *
 * @package Air Condition Repair
 * @subpackage air_condition_repair
 */

// Get the courses setting.
  $air_condition_repair_servicesec = get_theme_mod('air_condition_repair_service_show_hide', 1);
  if ($air_condition_repair_servicesec == 1) : 
  ?>
  <section id="service-section">
    <div class="container"> 
      <div class="serv-head mb-md-5 mb-3"> 
          <div class="serv-left">
            <?php if (get_theme_mod('air_condition_repair_section_small_title')) : ?>
              <p class="section-small-title"><?php echo esc_html(get_theme_mod('air_condition_repair_section_small_title')); ?></p>
            <?php endif; ?> 
            <?php if (get_theme_mod('air_condition_repair_section_title')) : ?>
              <h2 class="section-title"><?php echo esc_html(get_theme_mod('air_condition_repair_section_title')); ?></h2>
            <?php endif; ?> 
          </div>
          <div class="serv-right">
              <span class="view-more-button">
                  <?php if (get_theme_mod('air_condition_repair_view_more_button_link') && get_theme_mod('air_condition_repair_view_more_button_text', 'Explore All Team')): ?>
                      <a href="<?php echo esc_url(get_theme_mod('air_condition_repair_view_more_button_link')); ?>"><span><?php echo esc_html(get_theme_mod('air_condition_repair_view_more_button_text', 'Explore All Team')); ?></span><i class="fas fa-arrow-right"></i></a>
                  <?php endif; ?>
              </span>
          </div>
      </div>
      <div class="owl-carousel owl-theme">
        <?php
        $air_condition_repair_post_category = get_theme_mod('air_condition_repair_offer_section_category','');
        if ($air_condition_repair_post_category) :
          $air_condition_repair_category_id = term_exists($air_condition_repair_post_category, 'category');
          if ($air_condition_repair_category_id !== 0 && $air_condition_repair_category_id !== null) :
            $air_condition_repair_posts_to_show = get_theme_mod('air_condition_repair_posts_to_show', 3);
            $air_condition_repair_page_query = new WP_Query(array(
              'category_name' => esc_attr($air_condition_repair_post_category),
              'posts_per_page' => $air_condition_repair_posts_to_show,
            ));

            $air_condition_repair_post_count = 0;
            if ($air_condition_repair_page_query->have_posts()) :
              while ($air_condition_repair_page_query->have_posts()) : $air_condition_repair_page_query->the_post(); 
                $air_condition_repair_post_count++;
        ?>
                <div class="item">
                  <div class="serv-box">
                      <div class="post-main-img">
                          <?php if ( has_post_thumbnail() ) : ?>
                              <img src="<?php echo esc_url( get_the_post_thumbnail_url( null, 'full' ) ); ?>" alt="<?php the_title_attribute(); ?>" />
                          <?php else : ?>
                              <img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/post-img1.png' ); ?>" alt="<?php echo esc_attr__( 'Default Team Member Image', 'air-condition-repair' ); ?>" />
                          <?php endif; ?>
                          <div class="post-bottom-content">
                            <div class="post-content">
                                <h3 class="text-capitalize"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                <?php if ($air_condition_repair_team_role = get_theme_mod('air_condition_repair_team_role' . $air_condition_repair_post_count)) { ?>
                                    <p class="team-role"><?php echo esc_html($air_condition_repair_team_role); ?></p>
                                <?php } ?>
                            </div>
                            <div class="right-serv">
                              <span class="serv-phone">
                                <?php 
                                  $air_condition_repair_phone_number = get_theme_mod( 'air_condition_repair_btn_call_serv' . $air_condition_repair_post_count );

                                  if ( ! empty( $air_condition_repair_phone_number ) ) : ?>
                                      <p class="btn-call-serv my-0">
                                          <a href="tel:<?php echo esc_attr( $air_condition_repair_phone_number ); ?>" aria-label="<?php esc_attr_e( 'Call us', 'air-condition-repair' ); ?>">
                                              <i class="fas fa-phone"></i>
                                          </a>
                                      </p>
                                  <?php endif; ?>
                              </span>
                              <?php
                              $air_condition_repair_serv_facebook_url = get_theme_mod( 'air_condition_repair_serv_facebook_url' . $air_condition_repair_post_count );
                              $air_condition_repair_serv_twitter_url  = get_theme_mod( 'air_condition_repair_serv_twitter_url' . $air_condition_repair_post_count );
                              $air_condition_repair_serv_insta_url = get_theme_mod( 'air_condition_repair_serv_insta_url' . $air_condition_repair_post_count );
                              $air_condition_repair_serv_linked_url = get_theme_mod( 'air_condition_repair_serv_linked_url' . $air_condition_repair_post_count );

                              if ( ! empty( $air_condition_repair_serv_facebook_url ) || ! empty( $air_condition_repair_serv_twitter_url ) || ! empty( $air_condition_repair_serv_insta_url ) || ! empty( $air_condition_repair_serv_linked_url ) ) : ?>
                                
                                <span class="share-icon">
                                  <i class="fas fa-share-alt share-box"
                                     tabindex="0"
                                     role="button"
                                     aria-haspopup="true"
                                     aria-expanded="false"
                                     aria-controls="share-options-<?php echo esc_attr( $air_condition_repair_post_count ); ?>">
                                  </i>
                                  <span class="serv-social-media share-options" id="share-options-<?php echo esc_attr( $air_condition_repair_post_count ); ?>">
                                    <?php if ( ! empty( $air_condition_repair_serv_facebook_url ) ) : ?>
                                      <a target="_blank" href="<?php echo esc_url( $air_condition_repair_serv_facebook_url ); ?>" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Share on Facebook', 'air-condition-repair' ); ?>">
                                        <i class="fab fa-facebook-f"></i>
                                      </a>
                                    <?php endif; ?>

                                    <?php if ( ! empty( $air_condition_repair_serv_twitter_url ) ) : ?>
                                      <a target="_blank" href="<?php echo esc_url( $air_condition_repair_serv_twitter_url ); ?>" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Share on Twitter', 'air-condition-repair' ); ?>">
                                        <i class="fab fa-twitter"></i>
                                      </a>
                                    <?php endif; ?>

                                    <?php if ( ! empty( $air_condition_repair_serv_insta_url ) ) : ?>
                                      <a target="_blank" href="<?php echo esc_url( $air_condition_repair_serv_insta_url ); ?>" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Share on Instagram', 'air-condition-repair' ); ?>">
                                        <i class="fab fa-instagram"></i>
                                      </a>
                                    <?php endif; ?>

                                    <?php if ( ! empty( $air_condition_repair_serv_linked_url ) ) : ?>
                                      <a target="_blank" href="<?php echo esc_url( $air_condition_repair_serv_linked_url ); ?>" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Share on LinkedIn', 'air-condition-repair' ); ?>">
                                        <i class="fab fa-linkedin-in"></i>
                                      </a>
                                    <?php endif; ?>
                                  </span>
                                </span>
                              <?php endif; ?>
                            </div>
                          </div>
                      </div>
                  </div>
                </div>
              <?php endwhile; ?>
              <?php wp_reset_postdata(); ?>
            <?php else : ?>
              <div class="no-postfound"></div>
            <?php endif; ?>
          <?php endif; ?>
        <?php endif; ?>
      </div>
    </div>
  </section>
<?php endif; ?>