<?php
$pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null;
$pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null;
$cta = $attributes['cta'] ?? null;
$pageIllustration = get_field('page_illustration') ?? null;

$hasCustomImage = $attributes['hasCustomImage'] ?? null;
$customImageUrl = $attributes['imageUrl'] ?? null;
$customImageAlt = $attributes['imageAlt'] ?? null;
$coverSize = $attributes['coverSize'] ?? null;

$customTitle = $attributes['blockCustomTitle'] ?? null;
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;

?>

<section id="<?php echo $anchor ?? "" ?>" <?php echo get_block_wrapper_attributes(['class' => 'block-content-page-header']) ?>>
	<div class="block-content-page-header__content">
		<?php echo $content ?>
		<?php if ($cta &&  isset($cta['title']) && isset($cta['url'])) : ?>
			<a class="block-content-page-header__cta-link" href="<?php echo $cta['url'] ?>"><?php echo $cta['title'] ?></a>
		<?php endif; ?>
	</div>

	<?php if ($pageIllustration && !$hasCustomImage) : ?>
		<img class="block-content-page-header__page-icon <?php echo $coverSize ? "block-content-page-header__page-icon--" . $coverSize : ""  ?> " src="<?php echo $pageIllustration['url'] ?>" alt="">
	<?php endif; ?>
	<?php if ($hasCustomImage && $customImageUrl) : ?>
		<img class="block-content-page-header__page-icon <?php echo $coverSize ? "block-content-page-header__page-icon--" . $coverSize : ""  ?>" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
	<?php endif; ?>
</section>