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.

Read More
Adding an ICS Event File to Google Calendar

If you register for webinars, conferences, meetings, etc. on a somewhat regular basis, you are probably familiar with ICS files. An ICS file is an iCalendar file; and can contain a single event or an entire calendar feed. Online registrations and event notices tend to make use of these files quite a bit, because they offer a one-click method for people to add the events to their calendars.

If you’re using Outlook, Thunderbird, iCal or just about any other desktop calendar program, you simply download the file, open it and save the event to your calendar.

However, if you’re using Google Calendar, things get a little bit trickier. There’s no simple way to open the file and have Google Calendar take over from there. Instead, you basically have to understand how Google Calendar expects ICS files to be used (why the system uses this logic is kind of beyond me; but that’s the way things are). Google Calendar, for some reason, does not seem to expect people to use ICS files to add individual events regularly. Instead, it uses the logic that an ICS file should include a calendar “feed”, similar to a website’s RSS feed, that would contain a complete list of events.

Read More
Gmail’s “Add to Calendar”

A while back, Google unveiled a new feature in Gmail that automatically scans the message currently being viewed, checks for a date and time in the message body, and, if found, adds a link allowing you to add the item directly to your Google Calendar (as shown in the image on the right). Lately, I’ve noticed that that algorithm has improved greatly. I used to see the “Add to calendar” feature only appear in very rare cases, but I am now seeing it almost every time I am viewing a message that I want to add to my calendar.

Read More
Firefox and HTML5

Earlier this evening, I was reminded of just how primitive the HTML5 support was in Firefox 3.5/3.6. While we have seen three major version releases since 3.5, it was actually still the latest version of Firefox less than 6 months ago (and was that way for almost 2 years). Therefore, Firefox 3.5.x still holds a decent amount of market share (probably as much as, if not more than IE6 did a year or two ago). Looking at a handful of websites for which I have analytics data, versions of Firefox prior to 4 still accounted for anywhere between 2% and 15% of the total visits to those sites last month.¬†With all of that information, it’s probably still important to make sure your sites work in versions of Firefox as far back as 3.5.

There are two somewhat major gotchas in the way Firefox 3.x handled HTML5. The first is easily fixed with a few lines of CSS. The second can only really be fixed if you rewrite some of your HTML.

Read More
WordPress: Adding “Get Shortlink” to Custom Post Types

For some reason, by default, WordPress only includes the “Get Shortlink” button when editing posts; not when editing any kind of custom post type or when editing pages. Honestly, I’m not sure why, since pages and custom post types all use the same basic short URL as standard posts (example.com/?p=[post_id]).

The solution is simple, though. You just need to hook into the get_shortlink filter. Following is a simple function that will help you add the button to all “publicly_queryable” post types in your theme.

Read More
WordPress: Adding “Page Links To” to Custom Post Types

If you use WordPress (especially as a content management system) and you haven’t heard of Mark Jaquith’s “Page Links To” plugin, you should definitely check it out. Basically, the plugin allows you to set up a WordPress page or post to redirect to a different URL. It can be very handy for setting up redirects, adding menu items for pages that wouldn’t normally appear in those menus, etc.

One issue with the plugin, however, is that it does not (as of version 2.4.1) support custom post types. It only supports WordPress posts and pages. If you want to set a custom post type to redirect to a URL other than its permalink, you can’t do so with this plugin.

However, there is a pretty simple way to add support for custom post types to this plugin; and the changes do not require you to edit the plugin itself. Instead, you can make all of the necessary changes in your theme’s functions.php file.

Read More
Image Manipulation Script Vulnerabilities

Yesterday, Mark Maunder published a blog post making people aware of a vulnerability in the popular PHP image manipulation script TimThumb. Anyone that uses TimThumb should definitely read that article to make sure that the vulnerability gets patched. Almost a year ago, though, I posted (and I was far from the first) about a vulnerability in another extremely popular PHP image manipulation script; phpThumb.

Read More
Some HTML5 “Features” You Might Not Expect

As we continue to transition whole-hog into HTML5 with new Web development, there are a few things you might need to know before deciding how to handle certain situations. I have discovered two somewhat major gotchas over the last few months that really made me reconsider my usage of the new technology.

While articles, asides, headers, footers, etc. are a fantastic way to introduce semantics into your page designs, there are a few elements and attributes that might not do quite what you’d expect.

Read More
What is Going on at Microsoft?

I am not really a fanboy of any company (other than Sega), but I do appreciate when a company does something well. For Microsoft, there have been a few bright spots over the last few years (even if they haven’t all been commercially profitable). Among those, I’d include the Zune as the best portable media player (note, I didn’t say “handheld entertainment device”, as the Zune and the ZuneHD were basically designed to do one thing, and do it extremely well); the Xbox 360 as quite possibly the best modern gaming console (though I do love my Wii, the Kinect kind of tipped the playing field slightly in Microsoft’s favor – or so I’ve been told; I don’t own a 360, yet); and Windows Phone 7 has, as much as Android and Apple fanboys would hate to admit, somewhat revolutionized the mobile touch interface.

Do I expect to see whole-hog clones of the WP7 Metro UI, the way we did with iOS? Absolutely not; but I do suspect that we’ll see subtle changes to touch interfaces over the next year or so as a result of the way the Windows Phone OS works.

All of that said, I can’t help but wonder what the Xbox team was thinking when it came up with the pricing structure for Microsoft Points or when they integrated Netflix into the Xbox ecosystem.

Read More
HTML Presentations with Opera

Because Opera is not an extremely popular browser, most developers probably aren’t aware of one of its greatest features: Opera Show mode. Opera Show mode is the official name of the full screen mode for Opera (technically, it’s only called Opera Show when a projection media style sheet – discussed below – is present); and it brings with it a great possibility.

More than two years ago, Opera added support for the projection media mode in CSS. Whenever the browser is expanded to full screen mode, it activates the projection media, allowing you to apply a completely different stylesheet to the full screen page than you have in other settings.

Read More