<?php
/**
 * sponsor section
 *
 * This is the template for the content of sponsor section
 *
 * @package Theme Palace
 * @subpackage Charity Give
 * @since Charity Give 1.0.0
 */
if ( ! function_exists( 'charity_give_add_sponsor_section' ) ) :
    /**
    * Add sponsor section
    *
    *@since Charity Give 1.0.0
    */
    function charity_give_add_sponsor_section() {
        $options = charity_give_get_theme_options();
        // Check if sponsor is enabled on frontpage
        $sponsor_enable = apply_filters( 'charity_give_section_status', true, 'sponsor_section_enable' );

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

        // Render sponsor section now.
        charity_give_render_sponsor_section();
    }
endif;

if ( ! function_exists( 'charity_give_render_sponsor_section' ) ) :
  /**
   * Start sponsor section
   *
   * @return string sponsor content
   * @since Charity Give 1.0.0
   *
   */
   function charity_give_render_sponsor_section() {
        $options = charity_give_get_theme_options();
        ?>

        <div id="charity_give_sponsor_section" class="relative page-section same-background">
          <?php if ( is_customize_preview()):
                  charity_give_section_tooltip( 'charity_give_sponsor_section' );
                endif; ?>
            <div class="wrapper">
                <?php if ( !empty( $options['sponsor_title'] ) || !empty( $options['sponsor_sub_title'] ) ) : ?>
                    <div class="section-header">
                      <?php if ( ! empty( $options['sponsor_title'] ) ) : ?>
                        <h2 class="section-title"><?php echo esc_html( $options['sponsor_title'] ); ?></h2>
                      <?php endif; ?>
                      <?php if ( ! empty( $options['sponsor_sub_title'] ) ) : ?>
                        <p class="section-subtitle"><?php echo esc_html( $options['sponsor_sub_title'] ); ?></p>
                      <?php endif; ?>
                    </div><!-- .section-header -->
                <?php endif; ?>
                <div class="section-content col-5 clear">
                    <?php for ( $i = 1; $i <= 5; $i++){ ?>
                        <article>
                            <?php if( !empty( $options['sponsor_url_' . $i] ) && !empty( $options['sponsor_image_' . $i] ) ): ?>
                                <div class="featured-image"><a href="<?php echo esc_url( $options['sponsor_url_' . $i] ); ?>" target="_blank"><img src="<?php echo esc_url( $options['sponsor_image_' . $i] ); ?>"></a></div>
                            <?php endif; ?>
                        </article>
                    <?php } ?>
                </div><!-- .col-4 -->
            </div><!-- .wrapper -->
        </div><!-- #charity_give_sponsor_section -->
            
    <?php }
endif;