WP-Mix

A fresh mix of code snippets and tutorials

PHP Search Multidimensional Array

When you need to search an array using PHP, you can call upon the ancient powers of in_array() and call it a day. But that only works for flat, or one-dimensional arrays. What if you need to find a value in a multi-dimensional array? Well my friend, there isn’t a native PHP function to help […]

Stop WordPress from adding bundled plugins and themes during updates

By default, WordPress installs its bundled themes and plugins every time the software is updated. So for example, if you’re running the Hello Dolly plugin and a new version is available, WordPress will update the plugin when you upgrade WordPress.

WordPress clean up do_pings

When your WordPress site is configured to enable pings, the database can fill up with many do_pings WP Cron entries. This post provides a couple of quick ways to clean them up, by either disabling the functionality or deleting the do_pings entries from the database.

CSS select all except last child

Blazing fast snippet for you today: how to select all children except the last child. Targeting HTML with CSS has never been so much fun..

Minimal, optimal email headers

I recently had a conversation with an email guru concerning the ideal headers to use when sending plain-text email messages. Here is the punchline of that insightful exchange..

Disable extra p tags in WP shortcodes

When WordPress processes shortcodes, it first passes the content through its wpautop() function to convert line breaks to <p></p> or <br /> tags. This order of processing can lead to unwanted paragraph and breaks scattered throughout your shortcode content. This post provides a simple way to prevent this from happening, so you can keep your […]

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 […]