A fresh mix of code snippets and tutorials

Including Arrays in URI Requests

Some esoteric code phenomena for you today.. in this post I explain how PHP handles arrays when they are included in URL requests (via the query string). It’s something I failed to grasp until doing some in-depth work developing my professional WordPress firewall plugin. Now let’s jump in..

jQuery Toggle Password Field

Just a quick jQuery code snippet to toggle a password field. I used this technique for the license field of my premium WordPress firewall plugin, BBQ Pro. Sharing it here for reference and just in case I need to use it again.

Remove .DS_Store in macOS

I would give my left testicle to stop macOS from creating .DS_Store files in every freaking directory on the system. The stupid files have been driving Mac users mad for years, and apparently there is no end in sight. Fortunately, there are a couple of ways to remove them.

WordPress db-error.php drop-in template

One of the more useful WordPress must-use plugins and drop-ins is the db-error.php file, which you can create, customize, and upload to your site’s /wp-content/ directory. Upon doing so, the contents of the file will be displayed whenever the database is unavailable. This post provides a simple template for db-error.php that you can customize and […]

Private URLs with .htaccess

With WordPress and other publishing software, you can create “private” and “password-protected” posts, but the URL is still going to be discoverable via search engines and visitors. This technique using .htaccess makes the post and URL accessible only to the specified IP addresses.

.htaccess for cookie-less image domain

Here is a choice collection of .htaccess directives that I use when hosting images on a subdomain. When doing so, it’s best for performance to make sure the domain or sub-domain is “cookie-less”, so there is no time wasted sending cookie data back and forth between the server and client. Other optimizations are included to […]

WordPress Image Gallery Loop

This post shares the custom-loop code referenced by the image gallery tutorial. Basically what we’re doing here is creating a custom loop for displaying images that are attached to the current post (i.e., in the WP Loop). This technique is used for the Responsive Image Gallery.

PHP List All Directory Files

Here are three ways to list all files in a directory via PHP: via iterator class, file function, and while loop (in order of preference).

18 Sweet WordPress Functions

Here is a collection of 18 sweet WordPress functions that can be used to improve the functionality of any WordPress-powered site. Enjoy!

WordPress Random Post Class

Here is a simple plugin that you can use to include a random post class for each post. With a slight modification it can be used to include a random body class. This function can be useful for applying random colors and styles to your blog posts. Or whatever.

Get child or parent theme URI & path

These days, WordPress provides numerous ways to get the path and URI for the current theme directory. This post is reference for WP developers who need to get the URI and/or path for the current child or parent theme. Just grab, gulp, and go..

Canonical www via .htaccess

Creating canonical URLs for your site is an important part of good SEO. In this quick post, we’ll look at several .htaccess techniques for removing and requiring the www prefix, and additionally we’ll see how to remove any index.php appendage from all URIs.