<?php 
/**
 * Template part for displaying About Us Section
 *
 * @package Prime Ecology
 */

$prime_ecology_about = get_theme_mod( 'prime_ecology_about_setting',false );
$prime_ecology_featured_mission_section_title = get_theme_mod( 'prime_ecology_featured_mission_section_title' );
$prime_ecology_featured_mission_posts[] = get_theme_mod( 'prime_ecology_featured_mission_post_' );
$prime_ecology_featured_mission_section_extra_title = get_theme_mod( 'prime_ecology_featured_mission_section_extra_title' );
$prime_ecology_featured_mission_section_extra_content = get_theme_mod( 'prime_ecology_featured_mission_section_extra_content' );

?>
<?php if ( $prime_ecology_about ){?>
<div id="about-section" class="section-content py-5">
    <div class="container">        
        <?php $args = array (
            'post_type'     => 'page',
            'posts_per_page' => 1,
            'post__in'      => $prime_ecology_featured_mission_posts,
            'orderby'       =>'post__in',
            'ignore_sticky_posts' => true,
        );?>
        <?php
        $loop = new WP_Query($args);
        if ( $loop->have_posts() ) :
            while ($loop->have_posts()) : $loop->the_post(); ?>
            <div class="featured-mission-box">
                <div class="row">
                    <div class="col-lg-7 col-md-12 align-self-center side-1">
                        <header class="entry-header">
                            <div class="section-title">
                                <?php if( !empty($prime_ecology_featured_mission_section_extra_title) ): ?>
                                    <p class="extra-title"><?php echo esc_html($prime_ecology_featured_mission_section_extra_title); ?></p>
                                <?php endif; ?>
                                <?php if( !empty($prime_ecology_featured_mission_section_title) ): ?>
                                    <h3><?php echo esc_html($prime_ecology_featured_mission_section_title); ?></h3>
                                <?php endif; ?>
                            </div>
                        </header>
                        <div class="entry-content">
                            <p class="mb-0"><?php echo wp_trim_words( get_the_content(), 100 ); ?></p>
                            <?php if( !empty($prime_ecology_featured_mission_section_extra_content) ): ?>
                                <p class="extra-content"><?php echo esc_html($prime_ecology_featured_mission_section_extra_content); ?></p>
                            <?php endif; ?>
                        </div>

                        <div class="btn-green my-4">
                            <a href="<?php the_permalink(); ?>">
                                <?php esc_html_e('Read More','prime-ecology'); ?>
                            </a>
                        </div>
                    </div>                    
                    <div class="col-lg-5 col-md-12 align-self-center about-us position-relative wow zoomInUp delay-1000" data-wow-duration="2s">
                            <?php if (has_post_thumbnail( $post->ID ) ): ?>
                                <div class="image-container">
                                    <?php the_post_thumbnail(); ?>
                                </div>
                            <?php endif; ?>
                        <?php if(get_theme_mod('prime_ecology_about_us_video_button_url') != ''){ ?>
                              <span class="about-video-btn ">
                                <!-- Button to open the modal -->
                                <a id="openModalButton" data-modal-src="<?php echo esc_url(get_theme_mod('prime_ecology_about_us_video_button_url')); ?>"><i class="far fa-play-circle"></i>
                                </i></a>
                                <!-- The modal -->
                                <div id="myModal" class="modal">
                                  <!-- Modal content -->
                                  <div class="modal-content">
                                    <span id="closeModalButton" class="close">&times;</span>
                                    <?php if( get_theme_mod('prime_ecology_about_us_video_button_url') != ''){ ?>
                                    <embed id="videoPlayer" height="369" src="<?php echo esc_url(get_theme_mod('prime_ecology_about_us_video_button_url')); ?>"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></embed>
                                    <?php }else{ ?>
                                      <h3><?php esc_html_e('Add Video Url In Customizer To Display Video Here','prime-ecology'); ?></h3>
                                    <?php } ?>
                                  </div>
                                </div> 
                              </span>
                            <?php } ?>
                    </div>
                </div>
            </div>
        <?php endwhile; ?>
        <?php endif; ?>
        <?php wp_reset_postdata(); ?>
    </div>
</div>
<?php } ?>