Skip to content

Instantly share code, notes, and snippets.

@usm-interactive
Created June 17, 2021 16:16
Show Gist options
  • Save usm-interactive/17be03f2e935eded0b9f789914ed57cb to your computer and use it in GitHub Desktop.
Save usm-interactive/17be03f2e935eded0b9f789914ed57cb to your computer and use it in GitHub Desktop.
Consistency of Coding Syntax & Logic Efficiency
<?php
$link_one = get_sub_field('link_one');
$link_two = get_sub_field('link_two');
$cta_title = get_sub_field('cta_title')
?>
<?php if (!$link_two) : ?>
<div class="container">
<div class='cta-btn-container'>
<?php if ($cta_title) : ?>
<p class="cta-title"><?php echo $cta_title ?></p>
<?php endif ; ?>
<div class='inner-cta-container'>
<a href="<?php echo $link_one['url'] ?>" class='cta-btn'><?php echo $link_one['title'] ?></a>
</div>
</div>
</div>
<?php elseif ($link_two) : ?>
<div class="container">
<div class='cta-btn-container'>
<?php if ($cta_title) : ?>
<p class="cta-title"><?php echo $cta_title ?></p>
<?php endif ; ?>
<div class='inner-cta-container'>
<a href="<?php echo $link_one['url'] ?>" class='cta-btn-wh'><?php echo $link_one['title'] ?></a>
<a href="<?php echo $link_two['url'] ?>" class='cta-btn'><?php echo $link_two['title'] ?></a>
</div>
</div>
</div>
<?php endif ; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment