WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 32 of 35

Notes on @media queries

Just a couple of notes for working with CSS @media queries: two ways to write media queries and how to query portrait vs. landscape orientation.

WordPress s2member PayPal Fix

For those using s2Member and getting no response after clicking the “Continue” button on the PayPal.com site, here is a quick possible solution.

Over 300 SQL Code Snippets for WordPress

I’m excited to launch my latest book, Wizard’s SQL Recipes for WordPress. Years in the making, Wizard’s SQL Recipes brings together over 300 recipes for managing and optimizing the WordPress database. If you’re a WordPress administrator or developer who wants to level up their database skills, this book’s for you. Check out the PDF Demo […]

PHP: Remove Empty File Data

This quick function does one simple thing. It removes empty file data from a PHP files array. As you may know, the structure of the $_FILES array is sort of backwards from what normally would be expected. Because of this, removing empty file data from the array requires some extra wrangling. So to make things […]

JavaScript & jQuery: Add Style to Fragment Identifier

It’s easy to style a <div></div> by targeting its ID. But what if you only want to add style when a specific fragment identifier is targeted via the URL? So for example, your page at /about/ has a table with all the data. When visitors arrive directly at /about/, no extra styles are added. But […]

Redirect Attacker to Special Message

If you are using Apache server, you can stop an attack by getting the IP address of the attacker and then using it to block or redirect all of their requests. Normally I just block the requests using either Deny or Require directives (depending on Apache version), but sometimes it’s fun to redirect the attacker […]

Get WP, PHP, and SQL Info

Here are some sweet code snippets for getting various types of server information. Includes more functions for getting and/or checking various types of WordPress, PHP, and SQL data. Strictly plug-&-play for quick reference and copy/paste usage.

Vanilla JavaScript: Focus Input on Page Load

Super quick tutorial today. How to focus the user on any input when the page loads. For example, when you visit the WordPress Login Page, the “Username” field is focused automatically. This technique is very simple and works on any input or element that supports a focused state.

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.

PHP Stringify Formatted Text

This code snippet takes a string of text and removes all carriage returns, new lines, and tabs, replacing any matches with a simple blank space. An ideal way to “stringify” a potentially formatted lump of alphanumeric text.

jQuery Add Another Image Link

This code snippet is taken from my plugin, User Submitted Posts. It displays a link that users may click to add another file-upload input field.

Auto-Height for Ajax-Loaded Content

Here is a jQuery function for automatically setting the height of Ajax-loaded content.