<?php
if ( ! function_exists( 'moment_before_footer' ) ) :
    /**
     * Footer content
     *
     * @since Moment 1.0.0
     *
     * @param null
     * @return false | void
     *
     */
    function moment_before_footer() {
    ?>
    </div>
    </div><!-- #content -->
    <?php
    }
endif;
add_action( 'moment_action_before_footer', 'moment_before_footer', 10 );

if ( ! function_exists( 'moment_footer_widgets' ) ) :
    /**
     * Footer content
     *
     * @since Moment 1.0.0
     *
     * @param null
     * @return false | void
     *
     */
    function moment_footer_widgets() {
        global $moment_customizer_all_values;
        $moment_footer_widgets_number = $moment_customizer_all_values['moment-footer-sidebar-number'];
        if( $moment_footer_widgets_number <= 0 ){
            return false;
        }
        if( !is_active_sidebar( 'footer-col-one' ) && !is_active_sidebar( 'footer-col-two' ) && !is_active_sidebar( 'footer-col-three' ) && !is_active_sidebar( 'footer-col-four' )){
            return false;
        }
        if( 1 == $moment_footer_widgets_number ){
                $col = 'column-md-12';
            }
        elseif( 2 == $moment_footer_widgets_number ){
            $col = 'column-md-6';
        }
        elseif( 3 == $moment_footer_widgets_number ){
            $col = 'column-md-4';
        }
        elseif( 4 == $moment_footer_widgets_number ){
            $col = 'column-md-3';
        }
        else{
            $col = 'column-md-3';
        }
        ?>
        <!-- *****************************************
             Footer before section
    ****************************************** -->
    <footer id="colophon" class="wrapper site-footer" role="contentinfo">
    <section class="salientthemes-wrapper block-section wrap-contact">
        <div class="container overhidden">
            <div class="contact-inner salientthemes-animate fadeInUp">
                <div class="row">
                    <div class="column-md-12">
                        <div class="row">
                            <?php if( is_active_sidebar( 'footer-col-one' ) && $moment_footer_widgets_number > 0 ) : ?>
                                <div class="contact-list <?php echo esc_attr( $col );?>">
                                    <?php dynamic_sidebar( 'footer-col-one' ); ?>
                                </div>
                            <?php endif; ?>
                            <?php if( is_active_sidebar( 'footer-col-two' ) && $moment_footer_widgets_number > 1 ) : ?>
                                <div class="contact-list <?php echo esc_attr( $col );?>">
                                    <?php dynamic_sidebar( 'footer-col-two' ); ?>
                                </div>
                            <?php endif; ?>
                            <?php if( is_active_sidebar( 'footer-col-three' ) && $moment_footer_widgets_number > 2 ) : ?>
                                <div class="contact-list <?php echo esc_attr( $col );?>">
                                    <?php dynamic_sidebar( 'footer-col-three' ); ?>
                                </div>
                            <?php endif; ?>
                            <?php if( is_active_sidebar( 'footer-col-four' ) && $moment_footer_widgets_number > 3 ) : ?>
                                <div class="contact-list <?php echo esc_attr( $col );?>">
                                    <?php dynamic_sidebar( 'footer-col-four' ); ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>
            </div>
        </div>
    </section>
        <!-- *****************************************
                 Footer before section ends
        ****************************************** -->
    <?php
    }
endif;
add_action( 'moment_action_footer_widget', 'moment_footer_widgets', 10 );

if ( ! function_exists( 'moment_footer' ) ) :
    /**
     * Footer content
     *
     * @since Moment 1.0.0
     *
     * @param null
     * @return null
     *
     */
    function moment_footer() {
        global $moment_customizer_all_values;
        ?>
        <!-- *****************************************
             Footer section starts
    ****************************************** -->
            <div class="footer-bottom">
                    <?php
                     if( 1 == $moment_customizer_all_values['moment-enable-theme-name']){
                        ?>
                     <div class="site-info">
                       <?php
                       if(isset($moment_customizer_all_values['moment-copyright-text'])){
                           echo wp_kses_post( $moment_customizer_all_values['moment-copyright-text'] );
                       }
                       ?>
                        <span class="sep"> | </span>
                        <?php printf( esc_html__( 'Theme: %1$s by %2$s', 'moment' ), 'Moment', '<a href="http://salientthemes.com/" target = "_blank" rel="designer">Salient Themes </a>' ); ?>
                    </div><!-- .site-info -->
                    <?php
                    }
                    ?>
                </div>
            </footer><!-- #colophon -->
        <!-- *****************************************
                 Footer section ends
        ****************************************** -->
    <?php
    }
endif;
add_action( 'moment_action_footer', 'moment_footer', 10 );

if ( ! function_exists( 'moment_page_end' ) ) :
    /**
     * Page end
     *
     * @since Moment 1.0.0
     *
     * @param null
     * @return null
     *
     */
    function moment_page_end() {
    global $moment_customizer_all_values;
        ?>
        </div><!-- #page -->
    <?php
     if( isset( $moment_customizer_all_values['moment-enable-back-to-top'] )  && 1 == $moment_customizer_all_values['moment-enable-back-to-top']) {
        ?>
            <a class="salientthemes-back-to-top" href="#page"><i class="fa fa-angle-up"></i></a>
        <?php
        }
    }
endif;
add_action( 'moment_action_after', 'moment_page_end', 10 );