Handy Tool – jQuery Waypoints

Why You Might Need Waypoints

If you need to fire off a function when the user scrolls and reveals a particular element in the viewport.

Read More »

Advertisements

‘dist’ Folder not making it to Production

The Problem

You’re using Sage (8.5.x) and when you push to production the styles on the site are not displaying. It’s because all the stylesheets and CSS maps are not actually making it to Production.

The Solution

Sage has its own .gitignore file in its root directory. This threw me off for a bit because I had my own .gitignore in the WordPress root directory and it didn’t occur to me at first that Sage would have its own.

Open up Sage’s .gitignore and remove ‘dist’ and save. When you go to push your code, you should see ‘dist’ and its files ready to be committed.

 

The Incredible Expanding Empty Space

The Problem

Some pages didn’t have enough content and the footer would start floating up and the site designs didn’t call for a sticky footer.

My Solution


"
"


    var header_height = jQuery("header").height();
    var content_height = jQuery(".wrap").height();
    var footer_height = jQuery(".footer-container").height();
    var window_height = jQuery(window).height();
    var all_content_height = header_height + content_height + footer_height;
    var gap;
    
    if (all_content_height < window_height) {
        gap = window_height - all_content_height;
        jQuery('.void-balloon').css("height",gap)
    } else {
        console.log('no content gap detected');
    }

How to Restart PiHole after a Reboot

You’re enjoying PiHole and then boom, something happens. System crashes. Power goes out. Water balloon hits the circuit breaker. You boot your Pi back up, but your PiHole is no longer runnning. You long for PiHole’s ad blocking capabilities. Let’s get your PiHole back up and running.

Fire up that command line.

pihole -d

The -d flag is to look for issues automatically.

ACF Hide Field if Empty

How to ignore or hide a field if it has no value?

This comes in handy with fields that are not required by the CMS user to fill out and will sometimes remain blank.

<?php if (get_field('email')): ?> 
   <?php the_field('email'); ?> 
<?php endif; ?>

Or if it is a sub field inside of the repeater loop.

<?php if (get_sub_field('email')): ?> 
   <?php the_sub_field('email'); ?> 
<?php endif; ?>

CSS Classes for Hiding on Desktop and Mobile

Here are some CSS classes for hiding a component on desktop and/or mobile. This seems a little dirty since you may ideally want components that are responsive. However, with some designs, you don’t have choice.


// LG =>1200px
@media (min-width:1200px){
   .hide-on-desktop {
      display: none;
   }
}

// MD 992-1199px
@media (min-width:992px) and (max-width:1199px) {
   .hide-on-desktop {
      display: none;
   }
}

// SM 769-991px
@media (min-width:769px) and (max-width:991px) {
   .hide-on-mobile {
      display: none;
   }
}

// XS-Tablet 321-768px
@media (min-width:321px) and (max-width:768px) {
   .hide-on-mobile {
      display: none;
   }
}

// XS-Phone =<320px
@media (max-width:320px) {
   .hide-on-mobile {
      display: none;
   }
}

ACF Repeater Loop Ready for HTML

Why is this needed?

I use this loop all the time and I always have to close out each line of PHP in order to pepper it with my markup. So this is just a way to save a little time.

<?php if( have_rows('repeater_field_name') ): ?>
   <?php while ( have_rows('repeater_field_name') ) : the_row(); ?>
      <?php the_sub_field('sub_field_name'); ?>
   <?php endwhile; ?>
<?php else: ?>
   <!-- there are no rows -->
<?php endif; ?>

Directory Shortcuts in Linux

The situation

Often I end up going to the same directories in the terminal over and over again. Some of those directories are like 10 folders deep. It gets old tabbing through all those directories.

Linux saves the day

Use the link command to create a nickname for a directory path. (example below)

ln -s /home/whoa/crazy/uhhh/wow/there/are/a/lot/of/directories banana

So next time instead of typing that crazy long directory, all you have to type is banana.

-s is for a ‘soft link’. This just means that when that directory is deleted, banana will no longer be a valid shortcut.