Snippets

Adding Toolbar Menus in WordPress

If developing themes or plugins for WordPress sometimes it is handy to add a menu item to the WordPress admin bar to help quickly reference the desired action.

You can do various things with the admin bar but this snippet should help you get started.

Exclude IP Address From Google Analytics

If you have installed Google Analytics on your site, or for a client it is always helpful to exclude IP addresses so the sites stats give an accurate representation of the real traffic.

Styling Placeholder Text

Sometimes the light grey placeholder text needs to be styled to fit with your needs. All in all it is pretty easy with a couple of pseudo-elements and pseudo-classes.

Checkbox Checked in YUI

If you happen to need to trigger an event when a checkbox is checked or unchecked with YUI then this little snippet should help you out.

Text input non-editable

If you ever need to make an input field or textarea non-editable the readonly attribute comes in very handy.

When the readonly attribute is present in the markup, it specifies that the user will not be able to modify the value. However the user will still be able to tab to it and copy the text.

Sass Clearfix Mixin

There are a few ways to implement the clearfix hack but the following Sass mixin has been in my toolbox for the last year thanks to this article on Nicolas Gallaghers blog.

Group Posts by Date

If you publish posts multiple times per day sometimes there is a need to wrap posts by date. This is common amongst lots of link bloggers.

If you run a WordPress driven site thankfully this is super easy with one slight addition inside your loop.

Converts pixels to EMs with Sass

If you like using pixel values but understand that having your fonts set in EMs works better, especially when tackling responsive web design then this little Sass function will become super handy.

This function automatically converts pixels to EMs so that you don’t have to manually calculate them.

URL as a Sass Variable

Do you ever find yourself trying to remember the URL path of you images directory? Well with Sass you can quickly add the path to the desired location and just use the variable throughout your code. Sass to the rescue.

All you need to do is declare the variable and then use the interpolation syntax when you reference it.