<?php
/**
 * Client section
 *
 * This is the template for the content of client section
 *
 * @package Theme Palace
 * @subpackage Enlightme
 * @since Enlightme 1.0.0
 */
if ( ! function_exists( 'enlightme_add_client_section' ) ) :
    /**
    * Add client section
    *
    *@since enlightme 1.0.0
    */
    function enlightme_add_client_section() {
    	$options = enlightme_get_theme_options();
        // Check if client is enabled on frontpage
        $client_enable = apply_filters( 'enlightme_section_status', true, 'client_section_enable' );

        if ( true !== $client_enable ) {
            return false;
        }

        // Render client section now.
        enlightme_render_client_section();
    }
endif;

if ( ! function_exists( 'enlightme_render_client_section' ) ) :
  /**
   * Start client section
   *
   * @return string client content
   * @since enlightme 1.0.0
   *
   */
   function enlightme_render_client_section() {
        $options    = enlightme_get_theme_options();
        
        $contents = array();
        for( $i= 1; $i <=6 ; $i++ ){
            $page_post['image']      = empty( $options['client_image_'.$i] ) ? '' : $options['client_image_'.$i] ;
            $page_post['url']     = empty( $options['client_url_'.$i] ) ? '' :$options['client_url_'.$i];
            array_push( $contents, $page_post );
        }

        ?>

        <div id="enlightme_client_section" class="relative page-section same-background">

        <div id="client">
            <div class="wrapper">
            <?php if ( is_customize_preview()):
                enlightme_section_tooltip( 'client' );
                endif; ?>
                <?php if ( !empty( $options['client_title'] ) ): ?>
                    <p><?php echo esc_html( $options['client_title'] ); ?></p>
                <?php endif ?>                
                <div class="section-content col-6 clear">
                    <?php $i = 1 ; foreach ( $contents as $content ): ?>
                        <article>
                        <?php if( !empty( $content['url'] ) && !empty( $content['image'] ) ): ?>
                            <div class="featured-image">
                                <a href="<?php echo esc_url( $content['url'] ); ?>">
                                    <img src="<?php echo esc_url( $content['image'] ); ?>" alt="logo-0<?php echo esc_attr( $i ) ; ?>">
                                </a>
                            </div><!-- .featured-image -->
                        <?php endif; ?>
                        </article>
                    <?php $i++; endforeach ?>
                </div><!-- .col-5 -->                        
            </div><!-- .wrapper -->
        </div><!-- #client -->

        </div>
        
    <?php }
endif;