<?php
/**
 * Theme footer template
 *
 * @package wpstream-theme
 */

$wpstream_theme_show_footer  = get_theme_mod( 'wpstream_theme_show_footer', true );
$footer_background_image_url = get_theme_mod( 'wpstream_theme_footer_bg_image', '' );
$footer_background_repeat    = get_theme_mod( 'wpstream_theme_repeat_footer_bg', 'repeat' );
$footer_background_style     = '';

if ( ! empty( $footer_background_image_url ) ) {
    $footer_background_style = sprintf( 
        'background-image: url(%s); background-repeat: %s;',
        esc_url( $footer_background_image_url ),
        esc_attr( $footer_background_repeat )
    );
}
?>
<footer  id="footer" <?php echo esc_attr($footer_background_style) ? 'style="' . esc_attr( $footer_background_style ) . '"' : ''; ?>>
    <?php if ( $wpstream_theme_show_footer ) : ?>
        <div class="wpstream_theme-footer">
            <div class="<?php echo esc_attr( wpstream_theme_footer_container_class() ); ?>">
                <div class="row">
                    <!-- Footer Type Content -->
                    <?php include get_template_directory() . '/template-parts/footer-templates/footer-type-template.php'; ?>
                </div>
            </div>
        </div>
    <?php endif; ?>
    
    <?php
    $wpstream_theme_show_footer_copyright = get_theme_mod( 'wpstream_theme_show_footer_copyright', true );
    if ( $wpstream_theme_show_footer_copyright ) :
    ?>
        <div class="wpstream_theme-info pb-5 pt-4">
            <div class="<?php echo esc_attr( wpstream_theme_footer_container_class() ); ?>">
                <?php
                if ( is_active_sidebar( 'footer-info' ) ) {
                    dynamic_sidebar( 'footer-info' );
                }

                $copyright_message = get_theme_mod( 'wpstream_theme_copyright_message', '' );
                if ( ! empty( $copyright_message ) ) :
                ?>
                    <small class="wpstream_theme-copyright">
                        <?php echo esc_html( $copyright_message ); ?>
                    </small>
                <?php endif; ?>
            </div>
        </div>
    <?php endif; ?>
</footer>

<!-- To top button -->
<a href="#" class="btn btn-primary shadow top-button wpstream_back_to_top position-fixed zi-1020 type-1-button-style">
    <svg width="12" height="20" viewBox="0 0 12 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
        <path fill-rule="evenodd" clip-rule="evenodd" d="M0.93934 0.93934C1.52513 0.353553 2.47487 0.353553 3.06066 0.93934L11.0607 8.93934C11.6464 9.52513 11.6464 10.4749 11.0607 11.0607L3.06066 19.0607C2.47487 19.6464 1.52513 19.6464 0.93934 19.0607C0.353553 18.4749 0.353553 17.5251 0.93934 16.9393L7.87868 10L0.93934 3.06066C0.353553 2.47487 0.353553 1.52513 0.93934 0.93934Z"/>
    </svg>
</a>
</div><!-- #page -->

<?php wp_footer(); ?>
</body>
</html>