WP-Mix

A fresh mix of code snippets and tutorials

jQuery browser detection

Here’s a tasty little snippet for adding custom browser classes using jQuery.

Require user login for any plugin

Here’s a quick trick to require user-login for any plugin. For example, if you want users to be able to use your chat plugin only if they are logged in. Here’s how..

Add titles to previous_post_link & next_post_link

Here’s a quick way to include a title in previous_post_link() and next_post_link().

Simple jQuery tooltip

There are many great jQuery plugins for creating tooltips, but for simple cases only a few lines of code are needed.

Display category name in WordPress

Here are two snippets for displaying the category name and displaying the category link in WordPress.

Shorten text with CSS

There are several ways to shorten text, depending on the situation and goals. It’s preferable in most cases to shorten text server-side via PHP, but also possible to shorten via jQuery or even CSS.

Simple live comment preview with jQuery

Here is a very simple and basic live-preview for comments and contact forms.

Combine & compress CSS files with PHP

Here is another technique for combining multiple CSS stylesheets into a single, compressed file.

Combine all CSS files with PHP

Here is a simple PHP script that will combine all CSS files (stylesheets) in a given directory. Delivering one CSS file with your web pages is much faster than delivering multiple files because there are fewer HTTP requests involved.

Infinite loop trap for spammers

In this WP-Mix post, we’ll see how to send spammers on a virtual infinite loop chasing down randomly generated email addresses. It’s very satisfying.

PHP trap for bad bots

Another effective trap for bad bots and spammers, built with PHP and a slice of .htaccess.

Live comment preview with JavaScript

Here is a simple way to display a live comment preview for any comment or contact form using ordinary JavaScript.