call-out-block.php 3.52 KB
<?php

$type = get_field('type');
if(!$type || $type == 'full_width_half') {

    $id = 'full-width-block-' . $block['id'] . rand(0,100);
    if( !empty($block['anchor']) ) {
        $id = $block['anchor'];
    }

    // Create class attribute allowing for custom "className" and "align" values.
    $className = 'full-width-block ' . $type;
    $className .= ' ' .get_field('style');
    if( !empty($block['className']) ) {
        $className .= ' ' . $block['className'];
    }

    $image = get_field('image');
    $buttons = get_field('buttons');
    $content = get_field('content');
    $style = get_field('style');
    $colour_style = get_field('colour_style');
    $show_previous_impact_reports = get_field('show_previous_impact_reports');
    $show_previous_financial_reports = get_field('show_previous_financial_reports');

?>

<div class="stretch no-pad <?= $className ?> <?= $colour_style ?> <?= $style ?>" id='<?= $id ?>'>

    <div class='image'><figure class='wp-block-image'><img src='<?= $image['sizes']['medium_large'] ?>' alt='<?= $image['alt'] ?>' /><?php if(!empty($image['caption'])) { ?> <figcaption><?= $image['caption'] ?></figcaption><?php } ?></figure></div>
    <div class='content'>
        <div class='inner-content'><?= $content ?></div>
        <div class='button-list'>
            <?php foreach($buttons as $btn) { ?>
                <a class='btn' href='<?= $btn['link']['url'] ?>'><?= $btn['link']['title'] ?></a>
            <?php } ?>
        </div>
        <?php if($show_previous_impact_reports) { ?>
            <a class='previous-reports-anchor' href='#'><?= __("VIEW PREVIOUS REPORTS AND LATEST INTERNATIONAL REPORT", 'msf') ?></a>
            <div class='previous_impact_reports'>
                <?php msf_get_translated_sidebar('previous-impact-report') ?>
            </div>
        <?php } ?>
        <?php if($show_previous_financial_reports && !$show_previous_impact_reports) { ?>
            <a class='previous-reports-anchor' href='#'><?= __("VIEW PREVIOUS REPORTS & LATEST INTERNATIONAL FINANCIAL REPORT", 'msf') ?></a>
            <div class='previous_impact_reports'>
                <?php msf_get_translated_sidebar('previous-financial-report') ?>
            </div>
        <?php } ?>
    </div>

</div>


<?php
} else {

    // Create id attribute allowing for custom "anchor" value.
    $id = 'call-out-block-' . $block['id'] . rand(0,100);
    if( !empty($block['anchor']) ) {
        $id = $block['anchor'];
    }

    // Create class attribute allowing for custom "className" and "align" values.
    $className = 'call-out-block ' . $type;
    $className .= ' ' .get_field('style');
    if( !empty($block['className']) ) {
        $className .= ' ' . $block['className'];
    }

    $count = get_field('count');
    $button = get_field('button_url');
    $bg_image = get_field('background_image');
    $text_content = get_field('text_content');
    $pure_html = get_field('pure_html');
?>

    <div class="<?= $className ?> <?= (strlen($text_content) < 250)?'small-text':'' ?>" id='<?= $id ?>' style="<?= (!empty($bg_image))?"background-image: url(".$bg_image.")":"" ?>">
        <div class='content'>
            <?= $text_content ?>
            <?php if($type == 'newsletter_signup') { ?>
                <?= get_field('signup_form', 'options') ?>
            <?php } else if($type == 'html') { ?>
                <?= $pure_html ?>
            <?php } ?>
            <?php if(!empty($button)) { ?>
                <a href="<?= $button['url'] ?>" > <?= $button['title'] ?> </a>
            <?php } ?>
        </div>
    </div>

<?php } ?>