<?php
/**
 * Universal page template: renders the editor content.
 *
 * Page hero is shown if the page has a title and there is no [hero] shortcode
 * already in the content. Any [hero] shortcode placed at the top of the editor
 * replaces this automatic hero.
 */
get_header();
?>

<main>
	<?php
	while ( have_posts() ) :
		the_post();

		$content = get_the_content();
		if ( false !== strpos( $content, '[hero' ) ) {
			// Hero handled inside the content via shortcode.
		} else {
			?>
			<section class="page-hero">
				<div class="container">
					<h1><?php the_title(); ?></h1>
					<?php if ( has_excerpt() ) : ?>
						<p><?php echo esc_html( get_the_excerpt() ); ?></p>
					<?php endif; ?>
				</div>
			</section>
			<?php
		}
		?>

		<section class="section">
			<div class="container">
				<div class="entry-content">
					<?php the_content(); ?>
				</div>
			</div>
		</section>
	<?php endwhile; ?>
</main>

<?php
get_footer();
