Myzwer / foothillschurch

Bootcamp II is a wordpress theme (as well as an inside joke) designed to suit the needs of foothillschurch.com. It makes use of webpack, Babel, Sass, Tailwind, Browsersync, PostCSS, ESLint, Stylelint, Prettier and more. It is meant for that site, but if you can use it by all means go for it.
1 stars 1 forks source link

Button group cleanup #62

Closed rain2o closed 2 weeks ago

rain2o commented 1 month ago

https://github.com/Myzwer/foothillschurch/blob/effc5bbf81497ae99f0561ab7849412fe9272bfd/components/layouts/button-group.php#L22-L30

It might be better to put this <?php if ($link != null): ?> first in the loop, so empty html doesn't get generated, and you can delay other declarations until after the condition is met.

while (have_rows('button_group')) : the_row();
    $link = get_sub_field('button_link');
    if ($link != null): ?>
        <div class="font-bold text-xl pb-3 md:inline-block mr-3">
            <a href="<?php echo $link ?>">
                <div class="ghost inline-block">
                    <?php the_sub_field('button_text') ?>
                </div>
            </a>
        </div>
    <?php
    endif;
endwhile;

I don't know if you want the title to show even if button_group doesn't have rows, but if you don't, then you could move that if have_rows up to wrap the entire file.


Also this else can go

https://github.com/Myzwer/foothillschurch/blob/effc5bbf81497ae99f0561ab7849412fe9272bfd/components/layouts/button-group.php#L42-L43

Myzwer commented 2 weeks ago

Ended up reworking the sections so I don't need this. Deleted.