WP-Mix

A fresh mix of code snippets and tutorials

PHP Sanitize XSS

Here is a simple PHP function I use to prevent XSS attacks. Use it to sanitize any user-input or otherwise unknown variables before use.

CSS Style Placeholders

When displaying with HTML forms, most modern browsers display placeholder values for textarea and input fields. Once you’ve added placeholder attributes to your form fields, you can style their appearance via CSS.

110+ Free Stock Photo Sites

Here is a growing collection of free stock photo sites. Before downloading and using any photos for your project, be sure to check the specific licensing policies of whichever site(s) you are considering. Most everything from the following sites are free and/or open source, but there may be certain exceptions. Make sure to check the […]

jQuery Add / Remove Class

Adding and removing classes to/from HTML elements is super-easy with jQuery. Here is a quick tutorial that explains how it’s done. The code snippets are copy & paste friendly, so you can grab, gulp, and go.

.htaccess block spammer

Quick tutorial showing how to block a specific spammer via .htaccess. This technique is perfect for forum and site owners who want to block access to pesky visitors based on their reported IP address.

WordPress Exclude Custom Post Type from Search

Out of the box, WordPress search results include matches from any Custom Post Types that may be enabled via the theme template. For example, at htaccessbook.com, any matching content found in forum posts will be included in search results. This default behavior can be super convenient, but it is not always desirable. In this quick […]

jQuery Fade Out Element

Here is a simple jQuery technique to fade out any element on the page. It uses jQuery’s .hide() method to animate the fade-out of the specified element.

.htaccess enable compression

Two quick code snippets for compressing your file output with Apache’s mod_deflate (gzip). Compressing your content is a great way to improve performance by decreasing the amount of data that is sent to the client.

Disable Pinterest on Your Pages

Pinterest is a social-media service that people can use to collect your site’s images. The Pinterest browser extension and app add a “Pin it” (or whatever) button to the images that are included on your web pages. That way users can just click a button to add your images to their account on Pinterest. Fortunately, […]

jQuery Get Number of Paragraphs

Quick jQuery code snippet to get the number of paragraphs in the specified element. The technique can be modified easily to get the number of any element.

PHP Add and Remove Query String Variables

Two quick functions, one for adding a query string variable and another to remove a query string variable. Either of these functions can be used in any PHP script to modify query-string parameters.

Moto G Disable Sync

The Moto G Android phone by default syncs everything with your Google account. That’s fine for people who are not concerned about their privacy, but for everyone else here are the steps required to disable auto-sync on Moto G (and similar) phones.