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

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

        // Render promotion section now.
        charity_give_render_promotion_section();
    }
endif;

if ( ! function_exists( 'charity_give_render_promotion_section' ) ) :
  /**
   * Start promotion section
   *
   * @return string promotion content
   * @since Charity Give 1.0.0
   *
   */
   function charity_give_render_promotion_section() {
    $options = charity_give_get_theme_options();
    $readmore = ! empty( $options['promotion_btn_title'] ) ? $options['promotion_btn_title'] : esc_html__( 'Read More', 'charity-give' );
    $image = !empty( $options['promotion_image'] ) ? $options['promotion_image'] : '';
    ?>
        <div id="charity_give_promotion_section" class="relative page-section" style="background-image: url('<?php echo esc_url( $image ); ?>');">
            <div class="overlay"></div>
            <div class="wrapper">
                <?php if ( is_customize_preview()):
                    charity_give_section_tooltip( 'charity_give_promotion_section' );
                endif; ?>

                <?php if ( !empty( $options['promotion_title'] ) ) : ?>
                    <header class="entry-header">
                        <h2 class="entry-title"><?php echo esc_html( $options['promotion_title'] ); ?></h2>
                    </header>
                <?php endif; ?>

                <div class="entry-content">
                    <p><?php echo wp_kses_post( $options['promotion_description'] ); ?></p>
                </div><!-- .entry-content -->


                <?php 
                    if ( !empty( $options['promotion_video_btn_url'] ) ) : ?>
                        <div class="video-button">
                            <a href="<?php echo esc_url( $options['promotion_video_btn_url'] ); ?>" class="popup-video"><i class="fa fa-play"></i></a>
                        </div>
                        <?php
                    endif;
                ?>
            </div>
        </div>  <!-- #charity_give_promotion --> 
    <?php
    }
endif;
