<?php
/**
 * The template for displaying cta section
 *
 * @package Oginer
 */
 
$cta_id = get_theme_mod( 'oginer_cta_id', 'cta' );
$cta_page = get_theme_mod( 'oginer_cta_page' );
$cta_url = get_theme_mod( 'oginer_cta_url', '#' );
$cta_url_title = get_theme_mod( 'oginer_cta_url_title', __( 'More info', 'oginer' ) );

if ( $cta_page ) { ?>
	<section id="<?php echo esc_attr( $cta_id ); ?>" class="mw-section cta bg-dark">
		<div class="container">
			<div class="row">
				<div class="col-md-12 text-center">
					<?php
						$args = array(
							'page_id' => absint( $cta_page ),
							'post_status' => 'publish'
						);

						$post_query = new WP_Query( $args );
						
						if( $post_query->have_posts() ): ?>
							<?php while ( $post_query->have_posts() ) : $post_query->the_post(); ?>
					
								<h2 class="mw-animation" data-os-animation="fadeInLeft"><?php the_title(); ?></h2>
								
								<h3 class="mw-animation" data-os-animation="fadeInRight" data-os-animation-delay="0.5s"><?php the_content(); ?></h3>
							<?php endwhile;
							wp_reset_postdata();
						endif; 
					?>
					
					<?php if ( $cta_url != '' ) { ?>
					<div class="mw-animation" data-os-animation="fadeInUp" data-os-animation-delay="1s">
						<a target="_self" class="btn" href="<?php echo esc_url( $cta_url ); ?>"><?php echo esc_html( $cta_url_title ); ?></a>
					</div>
					<?php } ?>
				</div>
			</div>
		</div>
	</section>
	<?php
}