Please Stop Using cURL in WordPress Plugins

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.

Quick Tip: WordPress Visual Editor Button Icons

The process of adding a new button to the WordPress visual editor is fairly simple; as long as you understand how to develop a new TinyMCE plugin (which is a somewhat involved and laborious process that I will probably cover at another time).

One thing I discovered yesterday, though, is that one line of code makes the difference between the Visual Editor using a custom, static image as the button and the Visual Editor using a span that you can stylize with CSS (to fit better with the native Visual Editor appearance).

Using jQuery in your WordPress plugins

This evening on Twitter, @viper007Bond posted a quick tip about using jQuery in your WordPress plugins (also applicable to themes). His initial tweet was:

Using jQuery in your WordPress plugin? Make sure you’re using quotes in your selector strings! http://api.jquery.com/category/selectors/

Then, @dimensionmedia, @viper007Bond and I had the following brief conversation:

Twitoaster Has Been Unplugged

Last week on the official Twitoaster blog, it was announced that the service would be shutting down almost immediately (as of March 20). Sadly, I have used the Twitoaster plugin on multiple WordPress installations because of its ease of use. It was  great tool allowing WordPress posts to be pushed to Twitter automatically, and came with the added benefit of tracking when a blog post was tweeted (it even went as far as to allow you to automatically publish those tweets as comments on your posts).

My First Official WordPress Plugin

A few days ago, I was very happy to officially release a plugin for WordPress into the WP repository. The experience was an interesting one, but the documentation on the process was, for the most part, extremely helpful.

I began by registering my plugin with WordPress on Jan. 11, 2011. Almost a week later, I received approval to add my plugin to the repository. I then checked out the empty SVN repository using TortoiseSVN for Windows, created the appropriate subversion directories, added my previous versions to the “tags” directory and added my current version to the “trunk” directory. I validated my readme file through the WordPress plugin readme validator and then committed my changes to the repository.

Writing Dependent WordPress Plug-Ins

WordPress is a fantastic system in many ways, but one place that it’s really lacking is the ability to extend existing plug-ins. There is no built-in system of dependency when it comes to WordPress plug-ins, unfortunately.

Therefore, if you’re thinking of adding on to an existing WordPress plug-in, you basically have two options:

  1. You can modify the plug-in itself
    Using this method isn’t all that ideal, because any changes you make will obviously be overwritten whenever the plug-in is updated.
  2. You can write a plug-in that attempts to depend on the other plug-in
    With this method, if something changes in the other plug-in that causes your dependency check to fail, you could end up breaking the WordPress installation (which results in a blank white screen on most installations)

I would love to see WordPress implement some sort of dependency check or prioritizing method for plug-ins similar to the way they’ve implemented the method of using javascript and stylesheets. Sadly, though, there seems to be opposition from the development team because of too many unforeseen variables in the process.

Pages: