How WordPress Scheduled Posts Work

There’s a bit of a misnomer in the WordPress community about scheduled posts that I hope to help clarify.

To start, let’s do a quick overview of the WordPress cron system. It’s a psuedo-cron, meaning that it doesn’t rely on a true linux crontab or the Windows version of scheduled task running. It depends on user activity on the site. If a user visits a page, it triggers a check of the scheduled tasks, and if it finds one that is in the past, it invokes the task callback. If WP_DISABLE_CRON is set to true, then the implicit behavior-based system is disabled and awaits for an explicit call to wp-cron.php. This is really the better option of the two as you can run a curl on the wp-cron.php URL from a true crontab and invoke the scheduler on a cyclical basis from the os task runner.
Continue…

WordPress Data Migration with MySQL

WP-CLI is a great tool for migrating data within WordPress from the command line, however it’s not always the appropriate or most efficient way to move data around. My rule of thumb is if I am working with unserialized data, I try to use MySQL queries first.

A simple migration script with WP-CLI could take up a lot of I/O and could take minutes or hours to complete depending on the data set. The same query in MySQL can take mere seconds. For example, if you wanted to take meta values from a specific post type, and move them to a new key, the WP-CLI script might look something like this:

Continue…

Installing WordPress and HHVM on Heroku For Beginners

For someone not familiar with Heroku, it can be a bit daunting to get WordPress and HHVM running on a Heroku web dyno after working on a traditional LAMP stack. That’s why I titled this for beginners because I are one and it took me a while to wrap my head around it. Let me also say that I am not a Heroku master and this tutorial most certainly will be agnostic of some of the more technical aspects of Heroku.

This tutorial is also just a means to get WordPress running on a single dyno (server) using the free tier and has not been tested on an enterprise installation. As a point-of-reference, though technically savvy, I do not use https://github.com/mchung/heroku-buildpack-wordpress because the template they use has actual distribution code committed to the repo which relies on a human to continually update. At this reading, some of the plugins are out-of-date, and I prefer to pull distributions from the source using Composer.

Continue…

Using HTTP Auth Basic in WordPress

I was posed with the question as to how to protect a BB forum with a general user/pass for students at a community college. Since the segment that needed securing was not a standard post, but a custom rewrite, there was no way to use the native post password feature. Using .htaccess was also out as that protects entire directories.

Fortunately, PHP allows you to implement auth headers to handle this. Let me first say that I understand that HTTP Auth Basic is not a secure authentication solution, but it is a privacy gate which is all that was requested to help reduce spam, malicious posts, etc.. With the proper hooks, I was able to target the specific URI segment and it worked like a charm.

Continue…

Create a WordPress admin user with MySQL

If you’ve ever been locked out of a WordPress installation, but have access to the database, here’s a nifty snippet to grant you administrator-level access. There are a couple of things you need to do before using this MySQL code. First, set the variables to your own information. Next, if your WordPress installation is based on a non-standard wp_ table prefix, you must find/replace ‘wp_’ with your current table prefix.
Continue…

Generate a custom _s (underscores) WordPress theme from command line

I’m building out a new theme for my blog using the _s theme. It’s an exercise in building out a responsive grid. _s is a great theme starter. Underscores.me has a nifty little tool to generate the starter theme with namespaced functions, title, description, etc… for the theme. I wanted to generate the theme directly from command line. Here’s what I used to generate the theme directory with one line (your pwd should be wp-content/themes/):

curl --data "underscoresme_generate=1&underscoresme_name=Coderrr&underscoresme_slug=coderrr&underscoresme_author=Brian+Fegter&underscoresme_author_uri=http%3A%2F%2Fcoderrr.com&underscoresme_description=A+custom+theme+for+coderrr.com." http://underscores.me >> coderrr.zip; unzip coderrr.zip; rm coderrr.zip;

There are four things that happen here:

  • Curl http://underscores.me and send post data
  • Tell Linux to place all returned data into a zip file
  • Unzip that file and create the theme directory
  • Remove the zip file

Continue…

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.

Continue…

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.
Continue…

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 Plugin141KDownloadsDownload Now »