Fixing Mistakes


A couple of months ago, I added some code to a plugin that I wrote to use wp_schedule_single_event() in order to schedule some background processes. These were to keep data up to date and to clear out expired data. I did some testing on a few sites and everything seemed to work great.

A couple of weeks later, I started to hear from customers that their sites were slow. My first reaction was to blame their host or the other plugins that they had installed. More and more customers were mentioning that the plugin seemed to make their site sluggish. The weirdest thing was that I wasn’t experiencing it on any of my sites…until a couple of days go. I was constantly receiving fatal errors that the memory had been exhausted. I inched the memory up further and further until it was over 400MB.

That’s when I discovered my problem. Almost all of those cron jobs that I had been scheduling were still in the system. They never completed. Not only did they never complete…they kept getting added. There were thousands of cron jobs attempting to run every time a page loaded. No wonder I was running out of memory!

That night I could not sleep. I sat up in bed for a couple of hours and after some research, came up with a way to clear out those cron jobs. I used _get_cron_array() to find and un-schedule the jobs I had created. Because the cron jobs were scheduled with arguments, I had to loop through each cron in that array to find the correct arguments to un-schedule them.

Immediately, my site was noticeably faster! Now I had to figure out why it was happening and how to prevent it. After a day of trial and error, I got to a point where everything was running smoothly. Cron jobs were running, then removing themselves from the schedule. Not only that, but my memory usage was staying really low. Yay!

Finally, I was able to release an update for my plugin with the fixes in place. I created a version upgrade routine that would run only once to clean up the mess. I even created a bug fix plugin that we made available for a couple of our customers who couldn’t even have our plugin active without it crashing their site. Run the bug fix plugin, then re-activate our plugin and install the update.

It was a big mess, but I feel a huge weight off my shoulders knowing that it’s been taken care of. Luckily, our customers have been very patient with us.

Transient Fallback Class for WordPress


I’ve been doing a lot of work with a 3rd party API over the past year. One of my frustrations has been how long it takes to request information from the API. Some of the requests could take up to 30+ seconds. The user visiting the site would have to wait during that time for the page to finish loading. I then started using Transients to cache the API calls for a specified period of time. This worked great until the transient expired and a visitor had to wait for the API to return the data again or if the site didn’t get much traffic and the transient expired before the next visitor got to benefit from it.

My first idea was to not return the API data on the page load, but instead request the data after the page had loaded via an AJAX call. At least the page would finish loading, then I could display a spinner or something to let the visitor know that content was still loading in that particular section of the page. Still not idea since the visitor would be required to wait for the data, just at a different stage of the page load.

Then, about a week ago when TechCrunch open sourced their WordPress Async Task Library, it got me thinking. I could do the same thing with my transients! I then did a search and found that Mark Jaquith had created something very similar. I refrained from looking at the source code for either of these projects because I wanted to figure it out on my own. I mean, how else am I going to learn unless I challenge myself, right? I know that my code can be improved, so I will take a look at their source code now that I’ve got mine working.

Here’s how my class works. It has its own version of set_transient() and get_transient(). The function to set the transient has the same options as the WordPress version, except that it sets two transients. The first one is set with the expiration that was passed to the function. The second (fallback) transient is set with the expiration that was specified when the class was constructed, which defaults to 1 week. When requesting the transient, there are a few extra parameters. Along with the name of the transient, ->get_transient() also requires a hook and the arguments to pass to that hook. The hook is a function that needs to be registered with add_action(). When a transient is requested, the main transient is checked for data. If that transient is valid, then the data is returned, but if it has expired, then the fallback transient is checked for data. If the fallback transient is valid, then the data is returned and the hook is scheduled to run using wp_schedule_single_event(). If the fallback transient has also expired, then the function returns false and you can act accordingly. When the scheduled event fires, make sure that it repopulates the transient using ->set_transient().

There is also a cleanup function that can be turned on when the class is constructed. This function will purge expired transients created by the class on a daily basis.

I’ve put the class up on GitHub if you’d like to take a look. Feel free to give me some feedback or use it in your own projects.

FireTree-Transient-Fallback class for WordPress

CCBPress for WordPress


I’m proud to announce that, as of yesterday, CCBPress is officially for sale!

I’ve been working on the project for well over a year. It hasn’t been a full-time project, but it’s certainly been keeping me busy.


“Introducing the easiest way to display information from Church Community Builder on your church WordPress site”

This plugin was created to fill a need that my church had, and we know that a lot of other churches have this same need. There’s no reason that you should have to keep information up-to-date in multiple locations. Once it’s set up, just enter your data in Church Community Builder and you’re done.

For Developers

Everything in CCBPress was designed to be easily modified to fit in with any theme. (Check out Discovery Church as an example.) Filters are used throughout to enable full control of what’s displayed. Feel free to take a look at our documentation.

The Future

We’re just getting started here. There are so many possibilities and we look forward to integrating more Church Community Builder services into WordPress.

Rewrite Rules


I’ve been reading up on Rewrite Rules for displaying non-WordPress content. For almost the past year, I have slowly been working on a plugin that connects to a third-party API to bring in content. (It’s been an on and off process…mostly off.) Until now, all of the content lived as widgets. Now that I’ve discovered rewrite rules, I can create permalinks that link to and display this content.

This was originally what I wanted to do, but had no idea how to accomplish it. Now that I’ve gotten this figured out, the usefulness of this plugin has exponentially increased. I need to make sure that I don’t get ahead of myself though. I have a lot of debugging to look forward to in order to make everything run smoothly.



Back in July, I wrote a post called Getting Started with iOS Development. At the time, I had an idea for an app or two and really wanted to create them. Then in August I wrote about Simplifying both tangible and intangible things. That simplification has now evolved into focusing. Focusing my talents and abilities on things that I’m already good at, but have certainly not mastered. I’ve decided that iOS development is not what I should be focusing on. I’m instead focusing on WordPress development.

I’ve been part of a two-man team doing WordPress theme and plugin development for about two years now as a side job. We haven’t really released anything publicly yet since the work we’ve done so far has been specific to the clients that we’ve been working with. I’d like that to change though. I have a premium plugin that I started working on nearly a year ago that I’d really like to finish. It’s a niche product, but currently has no competition in the WordPress space. I’m really excited about it and hope to be able to release more information about it by the end of the year.

Pressgram Layout WordPress Plugin


A few days ago, I threw out an idea on Twitter to create an add-on plugin to the official Pressgram WordPress plugin that would add some layout options.

I’ve never done anything like that with WordPress, so I wasn’t really sure what was possible. My original idea was to hijack the loop and rewrite it, but I couldn’t find anyplace that mentioned if that could even be done.

Continue Reading



Over the summer, my wife and I simplified. We sold about 75% of our possessions and moved our family to a smaller house. That’s the short version, but you get the idea.

I’m finding that the idea of simplifying can also be applied to what I do on the internet. Over the years, I’ve created a wish list website, a prayer journal website, as well as several blogs. All of which I haven’t really touched or maintained for quite a while. Even though I don’t currently work on them, they’re constantly in the back of my mind. Just keeping them on my plate causes me to think about them when I should be investing my time in the things that I care about. Obviously, I don’t care too much about these projects if I haven’t touched them in years.

Which is why I’ve begun cutting down on my online projects. I’m going to be closing down both the wish list and prayer journal websites, shutting down the stale blogs, and selling or let expire any unused domain names that I own. I’m simplifying my online self. I’m going to focus on the things that I’m passionate about and hopefully leave room for new passions to develop.

What are some ways that you can simplify your online self?

Getting Started with iOS Development


Several months ago, I decided that I wanted to get into iOS development. After reading dozens of blog posts and watching countless hours of video tutorials, I feel as though I’m no further than when I started. I think that I need to get into a routine of giving myself time to work on it every day. I’m not going to give up. There are two books that I’ve started reading, Beginning iOS Storyboarding: Using Xcode and iOS 6 Application Development for Dummies. I’m only at the very beginning of each book, but I like them both so far. I was under the impression that because I have a background in Microsoft Windows software development, it would make iOS development a little easier to pick up. Although, I’m finding that it’s actually making it harder because I’m making assumptions about how I think things should work. Having to manually connect interface elements to the code editor is one of those things. Hopefully it will all start making sense soon.