<?php
/**
 * The template for displaying call to action in pre footer.
 *
 * @see https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package     Business Interface
 * @author      WPInterface Team
 * @since       1.0.0
 */

$business_interface_cta_text = apply_filters( 'business_interface_pre_footer_cta_text', business_interface_option( 'pre_footer_cta_text' ) );

$business_interface_cta_button_args = array(
	'text'    => business_interface_option( 'pre_footer_cta_btn_text' ),
	'url'     => business_interface_option( 'pre_footer_cta_btn_url' ),
	'new_tab' => business_interface_option( 'pre_footer_cta_btn_new_tab' ),
	'class'   => 'interface-button button-large',
);
$business_interface_cta_button_args = apply_filters( 'business_interface_pre_footer_cta_button', $business_interface_cta_button_args );

$business_interface_cta_button = '';

if ( $business_interface_cta_button_args['text'] || is_customize_preview() ) {
	$business_interface_cta_button = sprintf(
		'<a href="%1$s" class="%2$s" role="button" %3$s>%4$s</a>',
		esc_url( $business_interface_cta_button_args['url'] ),
		esc_attr( $business_interface_cta_button_args['class'] ),
		$business_interface_cta_button_args['new_tab'] ? 'target="_blank" rel="noopener noreferrer"' : 'target="_self"',
		esc_html( $business_interface_cta_button_args['text'] )
	);
}

// Classes.
$business_interface_cta_classes    = array( 'interface-container', 'si-pre-footer-cta' );
$business_interface_cta_visibility = business_interface_option( 'pre_footer_cta_visibility' );

if ( 'all' !== $business_interface_cta_visibility ) {
	$business_interface_cta_classes[] = 'business-interface-' . $business_interface_cta_visibility;
}

$business_interface_cta_classes = apply_filters( 'business_interface_pre_footer_cta_classes', $business_interface_cta_classes );
$business_interface_cta_classes = trim( implode( ' ', $business_interface_cta_classes ) );

?>
<div class="<?php echo esc_attr( $business_interface_cta_classes ); ?>">
	<div class="si-flex-row middle-md">

		<div class="col-xs-12 col-md-8 center-xs start-md">
			<p class="h3"><?php echo wp_kses_post( $business_interface_cta_text ); ?></p>
		</div>

		<div class="col-xs-12 col-md-4 center-xs end-md">
			<?php echo $business_interface_cta_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
		</div>

	</div>
</div>
