WordPress Rewrites Without Duplicate Content

There are times when you need to surface content in a different context. For instance, you might have an events section and you want to have your related live-blog posts reside within the context of that specific event URI structure. The problem lies in surfacing the same content in the original location and in a rewritten location. Search engines frown on this. You can easily sidestep this and stay search engine friendly by setting up simple redirects.


Automatic git status emails

This is a basic, elementary script to audit a git working copy. This is useful to keep a watchful eye on cowboy coding on a client server.

Save the following inside your git repo as .git-status.sh. Make sure to add ‘.git-status.sh’ to your .gitignore file.

DOMAIN = "http://whatever.com"
SENDTO = "your@email.com"
MODIFICATIONS=`git status -s`
if [ ! -z "$MODIFICATIONS" ]
        SUBJECT = "git changes from $DOMAIN"
        EMAIL = "$SENDTO"
        BODY = "/tmp/emailbody.txt"
        echo "Changes found on the following paths:\n" > $EMAILBODY
        mail -s "$SUBJECT" "$EMAIL" < $EMAILBODY
        echo "$MODIFICATIONS"

To automate, add a crontab:
30 15 * * * /path/to/your/script/.git-status.sh 2>&1>> /dev/null


Send a WordPress Auth Cookie with HTTP API Requests

This snippet I created lets you hit your site with a remote request that includes your current auth cookie. I use this to circumvent caching plugins that use output buffering when I need to store a page load for analysis.

Testing Plugins and Themes on Multiple WordPress Versions

If you’re a theme or plugin developer, it’s essential to support at least WordPress 3.3+. Smaller sites and blogs have an easier time upgrading to the latest WP version. However, upgrading large corporate sites becomes a major operation because the codebase is usually collaborative and has many dependencies built on earlier versions. With that said, it’s good to be inclusive of those users as well by adding backwards compatibility.

I typically test my plugins on the major releases. If users have issues on minor releases, I’ll generate an install for that version on my local environment and debug from there.

Get file permissions, owner and group with PHP

Here are a few functions to help you when interacting with files in your php scripts:

Find the owner of a file:
An array of information about the owner is returned.

function foo_get_file_ownership($file){
	$stat = stat($file);
		$group = posix_getgrgid($stat[5]);
		$user = posix_getpwuid($stat[4]);
		return compact('user', 'group');
		return false;

Get the four digit file permissions number:
A permissions string is returned. Example: 0755

function foo_get_file_perms($file){
	return substr(sprintf('%o', fileperms($file)), -4);


Debug This – WordPress Plugin

I’m excited to release my latest plugin. It’s a great tool for developers to debug their plugins or themes. Debug This comes with 49 different debug modes to help expose specific raw data when you need it. The benefit of Debug This is the time saved from hardcoding var_dump or print_r to see WP globals, queried objects, etc… Developers can easily add new debug modes from their theme or plugin.

Debug This utilizes the WordPress Admin bar for mode navigation. All mode navigation links are relative to whatever page/post you are viewing. Custom modes and be nested in grouped drop-downs.

I really like the Debug Bar plugin and I’ve created several extensions for my personal use. However, there are times when I want to see the raw data in a full-screen width. Once you click a Debug This mode, it takes you to an immersive full-width experience.

Finally, DT renders the page first before displaying the debug mode. Custom debug extensions can analyze the rendered page with the supplied buffer in their callback function. This allows for intricate debugging that no other plugin offers (that I know of).

Update: If Debug This doesn’t suit your needs, I came across another great debug plugin called Debug Objects.

Debug This

WordPress Plugin14KDownloadsDownload Now »