<?php
/*
 * The template for displaying the footer.
 * Author & Copyright:wpoceans
 * URL: http://themeforest.net/user/wpoceans
 */

$portio_id    = (isset($post)) ? $post->ID : 0;
$portio_id    = (is_home()) ? get_option('page_for_posts') : $portio_id;
$portio_id    = (is_woocommerce_shop()) ? wc_get_page_id('shop') : $portio_id;
$portio_meta  = get_post_meta($portio_id, 'page_type_metabox', true);
$portio_ft_bg = cs_get_option('portio_ft_bg');
$portio_attachment = wp_get_attachment_image_src($portio_ft_bg, 'full');
$portio_attachment = $portio_attachment ? $portio_attachment[0] : '';
if ($portio_meta) {
	$portio_footer_design  = $portio_meta['select_footer_design'];
	if ($portio_footer_design != 'theme') {
		$portio_footer_design = $portio_footer_design;
	} else {
		$portio_footer_design = cs_get_option('select_footer_design');
	}
} else {
	$portio_footer_design  = cs_get_option('select_footer_design');
}

if (is_numeric($portio_footer_design)) {
	$footer_class = 'footer-builder';
} else {
	$footer_class = 'wpo-site-footer clearfix';
}

if ($portio_attachment && !is_numeric($portio_footer_design)) {
	$bg_url = ' style="';
	$bg_url .= 'background-image: url( https://hectordmilita2.monetizadorapm.com/wp-content/uploads/2026/03/features-bg-img.jpg );'; // Nueva imagen de fondo
	$bg_url .= '"';
} else {
	$bg_url = '';
}

if ($portio_meta) {
	$portio_hide_footer  = $portio_meta['hide_footer'];
} else {
	$portio_hide_footer = '';
}
if (!$portio_hide_footer) { // Hide Footer Metabox
	$hide_copyright = cs_get_option('hide_copyright');

?>
	<!-- Footer -->
	<footer class="<?php echo esc_attr($footer_class); ?>" <?php echo wp_kses($bg_url, array('img' => array('src' => array(), 'alt' => array()),)); ?>>
		<?php if (is_numeric($portio_footer_design)) {
			$footer_builder = new WP_Query(
				array(
					'post_type' => 'footerbuilder',
					'posts_per_page' => 1,
					'p' => $portio_footer_design,
					'orderby' => 'none',
					'order' => 'DESC'
				)
			);

			if ($footer_builder->have_posts()) {
				while ($footer_builder->have_posts()) {
					$footer_builder->the_post();
					the_content();
				}
			}
			wp_reset_postdata();
		} else {
			$footer_widget_block = cs_get_option('footer_widget_block');
			if ($footer_widget_block) {
				get_template_part('theme-layouts/footer/footer', 'widgets');
			}
			if (!$hide_copyright) {
				get_template_part('theme-layouts/footer/footer', 'copyright');
			}
		} ?>
	</footer>
	<!-- Footer -->
<?php } // Hide Footer Metabox 
?>
</div><!--portio-theme-wrapper -->
</div><!--portio-gsap-wrapper -->
</div><!--portio-gsap-end -->
<?php wp_footer(); ?>
</body>

</html>