The Easy Way to Remove the Popular Tab from a WordPress Taxonomy

Wow, that was a long title for this short article.

First off, I am assuming that you know how to add JS scripts to your WordPress admin. If not, you need to know that first.

So without further ado…

if ($ === undefined) {
    $ = jQuery;
}
if ($('#custom_taxonomy_id-pop').length) {
    $('#custom_taxonomy_id-pop').remove();
    $('#custom_taxonomy_id-tabs').remove();
    $('#custom_taxonomy_id-all').show();
}

There are other ways to go about destroying the meta box and rebuilding it manually. This, however, seems to be less invasive. It’s also a lot less code.

Track Ad Blocking Software with Google Tag Manager

Ad blocking plugins can easily cut into any website’s revenue. Not sure if it’s happening to yours? You can use this simple method to find out just how much your traffic is being affected by AdBlockers.

For the purposes of this illustration, I will assume you’ve already set up Google Tag Manager and Google Analytics. If not, go there first, and get it set up. This tutorial also assumes that you are using jQuery.

Set Up an AdBlocker Tracking Variable

Once you’re inside Google Tag Manager, click on the menu item labeled Variables. Under User-Defined Variables, choose New. Under Choose Type, select Custom Javascript. Then configure the script like this:

function () {
  $(document.body).append('<div id="adsense" style="position:absolute; left:-999999px;">Advertisement</div>');
  var eventValue = 'Blocked';
  if ($("#adsense").height()) {
    eventValue = 'Unblocked';
  }
  return eventValue;
}

Track the Result With a New Tag

Now we have to report this new variable to Google Analytics. Click on the menu item labeled Tags. Set up a new tag like this:

Publish Your Changes

None of this will work until you publish your changes in the Google Tag Manager.

Follow Along in Google Analytics

All you need to do now is watch your Google Analytics in real time as you visit your web site. From Google Analytics, visit Real Time >  Events. Click on Events (last 30 minutes). You will see AdBlockStatus start to appear here. Clicking on AdBlockStatus here will show you how many people are blocking your ads, along with a percentage.

Adding the Bootstrap “active” class to a WordPress Menu Item

Working with WordPress and Bootstrap, you might be frustrated with the built in menu options. There isn’t an easy way to tell WordPress to swap out the  current-menu-item class with bootstrap’s active class. Fortunately for you and me, there’s jQuery for that. Just a little dab will do ya.

jQuery(document).ready(function () {
  $(".current-menu-item").addClass("active");
});

This little blessed bit of jQuery will add the active class to your menu on the fly.

The Ugly Bootstrap File Input Type

Bootstrap has a way making a lot of HTML elements look good, right off the bat. But the day finally came when I had to face to inevitable: The <input type=”file”>. This is the red headed stepchild of Bootstrap (and browser makers). Browsers render this element differently from each other, making it nearly impossible to look good across the board.

Our final result should look something like this!
Our final result should look something like this!

Continue reading The Ugly Bootstrap File Input Type

Understanding the WordPress Quick Edit Custom Box

Alright, I have to confess. This took me some time to wrap my head around. It also seemed like a lot of people were having the same problem. The question is “How do I add custom post meta fields to the quick edit function in WordPress?”

For some reason, I had a hard time finding the answers I needed in Google. I must not have been asking the right question or something. So here is what I learned. Continue reading Understanding the WordPress Quick Edit Custom Box

Set a Container to the Window Height with jQuery

A common issue with CSS is finding the best way to set an element, such as a div, to stretch from the top of the screen, to the bottom of the screen. You can do this with positioning. Sometimes, though, you want the div to start from after the banner, navigation, or something else. This creates some additional variables. You also need to account for what happens if someone resizes the screen. Continue reading Set a Container to the Window Height with jQuery

Create a SpeedBump with jQuery & the Bootstrap Modal

A speedbump is a essentially a confirmation dialogue when a website visitor clicks a link to leave your site. Speedbumps are actually required by law in some countries for industries such as Credit Unions and banks. There are several ways to create a speedbump, and I’m going to show you just one way. You can borrow or adapt any part of these methods for your own site. Continue reading Create a SpeedBump with jQuery & the Bootstrap Modal

Simple PHP+CSS+jQuery Anti-Spam Measure

Today I set out to implement some additional anti-spam measures for some forms on one of my sites. Let me start by saying that this should not be the only thing you do to prevent spam. Nor are these ideas new or unique. This is just a simple technique to help prevent spam. Continue reading Simple PHP+CSS+jQuery Anti-Spam Measure