Unexpected Results When Adding Months To a Date

When adding or subtracting months to a date in PHP, you’ll get some uninuitive results in some cases. For example, strtotime( ‘+1 month’ ) will return the timestamp for July 1st when it’s executed on May 31st, instead of the expected June 30th. This is because a “month” is a fuzzy metric (i.e., some months […]

Continue reading...

Creating Admin Notices From a WordPress Plugin

I just threw a couple small PHP classes up on GitHub that I use in almost every WordPress plugin I write. The first is IDAdminNotices, which is a clean and easy way for plugins and themes to send messages/errors to the user within the Administration Panels. The second is IDDescribeVar, which will outputs the type, length and contents of […]

Continue reading...

FastCGI errors after PHP upgrade

I ran into a small problem upgrading PHP from 5.3.5 to 5.3.10 on a MediaTemple CentOS VPS today. The upgrade completed without any errors, but when I reloaded the site I got a “500 Internal Server Error” message. It was the stock installation, so I’m not sure which module it was using or what repository […]

Continue reading...

Unit Testing WordPress Plugins

Nikolay Bachiyski gave a good talk at this year’s WordCamp San Francisco about unit testing WordPress plugins. His method uses PHPUnit, which is an additional PEAR package you have to install on the server. You can then use MockPress to simulate WordPress in the tests. Another option is the SimpleTest for WordPress plugin, which uses SimpleTest […]

Continue reading...

Performance Improvements for Dedicated WordPress Servers

Mark Maunder benchmarked several performance tuning measures with a WordPress installation on a VPS server to show which are most effective. The biggest improvements were from installing PHP-APC, setting up Nginx to proxy concurrent connections for Apache, and using MySQL’s query cache.

Using Chained Properties Inside $wpdb->prepare()

If you’re using $wpdb->prepare() to query a custom table, you can’t pass the table name in as an argument because it will be single-quoted, which would be a MySQL syntax error. Instead, you need to insert the variable directly into the double-quoted query string and let PHP parse it out. That creates a new problem, […]

Continue reading...

PHP Error Logs with Virtuozzo

Virtuozzo sets domains up to have PHP’s display_errors flag turned off by default, so that you’ll only see a blank page when there are critical errors. This is a good thing in production environments because it avoids potential security issues, but it can also be annoying when you’re trying to debug something. Instead of displaying […]

Continue reading...

Home page posts missing when using Pretty Permalinks for WordPress on IIS

I’ve been working on a problem recently with the Pretty Permalinks solution for WordPress on IIS. I was migrating a working WordPress blog from one server to another and once it was on the new server the front page would come up w/ the theme, but instead of the default posts it would say “Sorry, […]

Continue reading...