Checking WordPress versions for plugin settings

Norcross Dec 7th, 2012WP Core

There’s been a lot of talk about the upcoming release of WordPress 3.5, in specific the new Media Manager. To say it’s sexy is an understatement. The core team (@Koop in particular) put a lot of work into it, and it shows.

One thing I noticed while beta testing my plugins was the new UI around the media buttons. One of my plugins, Schema Creator, uses a button in the same row to load the form. Well, the existing icon setup matched 3.4, but 3.5 released a new look along with text within the button container. So now mine looked woefully out of place.

And we can’t have that, can we? Here’s an example of the difference:

Schema Buttons

Now, the entire media loader is different. No more Thickbox at all. So there’s certainly a lot to be done. But for the launch, I wanted to make sure my UI was consistent. So while I wanted those who update to 3.5 to have a solid UI, I didn’t want to startle those who aren’t on 3.4. And I also wanted to update it before the release, since we’re all busy and I didn’t want to wait until after it went live.

So I wrote a small function to do a version check and load the button markup based on which version they had.

WP Core Version Check

You can do just about anything you’d like with that. All I did was change the button markup and add a span for an image. But you could do everything from load different JS files (which I plan on doing soon) or add / remove UI elements. The world, as they say, is your oyster.

7 Responses to “Checking WordPress versions for plugin settings”

  1. shayne

    Nice! Goes to show that tutorials don’t have to be a book – and what you’re doing with these shorter tutorials is great!

    My opinion – it’s better this way as it will give people just enough to go and do what they need and learn some in the process. What’s the fun in just copying/pasting someone else’s work?

    Good job buddy.

    • Norcross

      Thanks! I’m hoping that I can grab these small things as I’m doing my daily work and share them with others. Shorter is certainly something I have a better shot at accomplishing, that’s for sure.

    • Norcross

      no reason why not, both would work. and if I were doing numerous checks, then I’d probably add a function inside the class to do the check and call it when needed.

      but for this instance, I needed a quick compare.

      • Lee Willis

        I’d echo the previous comments about version_compare – it’s a lot more reliable – especially when people start using beta/svn releases.

  2. Scott Hack

    Quick question — Once you update this plugin again, will you leave this in place? Or just raise the required minimum for the plugin and only support 3.5+? I’m just wondering how long is appropriate to keep the band-aid on. It totally makes sense with 3.5 coming out and wanting to get your update done before hand, but how long afterwards should the plugin be backwards compatible?

    • Norcross

      since it’s a small UI change, there’s not a big rush to remove the old version. while I’d love it if everyone kept WP updated all the time, it’s probably not the case. If it were a larger switch, I may feel different.