homegrade_blocks_production/blocks/content-page-header/build/render.php
2023-11-24 18:41:02 +01:00

40 lines
1.7 KiB
PHP

<?php
$pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null;
$pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null;
$cta = $attributes['cta'] ?? null;
$pageIcon = get_field('page_icon');
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
$customImageUrl = $attributes['imageUrl'] ?? null;
$customImageAlt = $attributes['imageAlt'] ?? null;
$customTitle = $attributes['blockCustomTitle'] ?? null;
?>
<section id="<?php echo esc_html($attributes['anchor']) ?>" <?php echo get_block_wrapper_attributes(['class' => 'block-content-page-header']) ?>>
<div class="block-content-page-header__content">
<div className="section_titling">
<?php if (!$attributes['hasCustomTitle']) : ?>
<h1 class="section_titling__title"><?php echo get_the_title() ?></h1>
<?php endif; ?>
<?php if ($attributes['hasCustomTitle'] && $customTitle) : ?>
<h1 class="section_titling__title"><?php echo $customTitle ?></h1>
<?php endif; ?>
<h2 class="section_titling__subtitle"><?php echo $pageHeaderTitle ?> </h2>
</div>
<p><?php echo $pageHeaderDescription ?> </p>
<?php echo $content ?>
<?php if ($cta && $cta['title'] && $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 ($pageIcon && !$hasCustomImage) : ?>
<img class="block-content-page-header__page-icon" src="<?php echo $pageIcon['url'] ?>" alt="">
<?php endif; ?>
<?php if ($hasCustomImage && $customImageUrl) : ?>
<img class="block-content-page-header__page-icon" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
<?php endif; ?>
</section>