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

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

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

if ( ! function_exists( 'raise_charity_pro_render_sponsor_section' ) ) :
  /**
   * Start sponsor section
   *
   * @return string sponsor content
   * @since Raise Charity Pro 1.0.0
   *
   */
   function raise_charity_pro_render_sponsor_section() {
        $options = raise_charity_pro_get_theme_options();
        $sponsor_title = !empty( $options['sponsor_title'] ) ? $options['sponsor_title'] : '';
        $sponsor_sub_title = !empty( $options['sponsor_sub_title'] ) ? $options['sponsor_sub_title'] : '';
      
        ?>
        <div id="raise_charity_pro_sponsor_section">
          <div id="sponsor-section" class="relative page-section">
                <div class="wrapper">
                  <?php if ( is_customize_preview()):
                  raise_charity_pro_section_tooltip( 'sponsor-section' );
                  endif; ?>
                    <div class="section-header">
                    <?php if( !empty( $sponsor_title ) ): ?>
                        <h2 class="section-title"><?php echo esc_html( $sponsor_title ); ?></h2>
                      <?php endif;
                      if( !empty( $sponsor_sub_title ) ):
                       ?>
                        <p class="section-subtitle"><?php echo esc_html( $sponsor_sub_title ); ?></p>
                      <?php endif; ?>
                    </div><!-- .section-header -->

                    <div class="section-content col-5 clear">
                        
                        <?php for ( $i = 1; $i <= $options['sponsor_count']; $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] ); ?>" alt="sponsor"></a>
                            </div><!-- .featured-image -->
                          <?php endif; ?>
                        </article>

                        <?php } ?>

                    </div><!-- .col-5 -->                        
                </div><!-- .wrapper -->
            </div><!-- #sponsor-section -->
        </div>
        
            
    <?php }
endif;