WordPress HTTP class usage

Unfortunately, I keep finding WordPress plugins that try to call cURL functions directly. Unfortunately, not only do these plugins fail to work if cURL isn’t installed, it throws a fatal PHP error in the process.

The problem with using cURL in WordPress plugins is that WordPress solved that problem more than 2 years ago by implementing the WP_Http class. WP_Http is a class included in the WordPress core that has multiple options. One of those options is cURL, but it gracefully reverts to other PHP functions if cURL isn’t available.

Basically, anything you can do with cURL can be done with the WP_Http class, and it will allow your plugin to be much more versatile and compatible with more server setups.

Unfortunately, though, it seems that a lot of plugin developers are completely unaware of the class. Each time I find a plugin that requires cURL (one of my servers does not have cURL compiled into PHP), I point them to a great article on the WP_Http class┬áthat Ozh wrote back in August 2009, and each one tells me they’ve never heard of WP_Http before.

So, if you are even tangentially connected to a WordPress plugin (or theme) developer, please help shout this from the rooftops. If you are performing any sort of file request in your plugin, please use WP_Http instead of relying entirely on cURL.