VoucherPress: Version 1.0

I have to admin being a bit of a wimp when it comes to choosing version numbers for my WordPress plugins. Just like Google my work is constantly in a state of development, in flux. Although it isn’t, not really.

I don’t have anywhere near enough time to spend on open source software as I’d like (the bank manager wouldn’t be happy if I wanted to pay my mortgage in a new currency comprising of nice emails). So rather than commit and say “Yes! This is version 1.0, the definitive point in this plugins development!” I wimp out and start from 0.1 … moving to 0.2 when I add some features or fix a load of bugs.

However, one of my most popular plugins – and, incidentally, the one that I get by far the most amount of ‘thank you’ messages for – has just had it’s version 1.0 birthday.

VoucherPress allows you to create vouchers or coupons for download from your WordPress site. The list of features is now pretty extensive:

  • Large range of pre-built templates
  • The ability to add your own templates
  • Limit the number of vouchers available (e.g. only allow 1000 to be downloaded)
  • Set a date when a voucher will expire and not be available any more
  • Require visitors to provide their name and email address to download a voucher
  • Use shortcodes to provide a link to a voucher, a list of all your vouchers, or the registration form
  • Each voucher has a unique code in one of four formats:
    • A random code from 6-10 characters long
    • Sequential codes (1, 2, 3 etc) to which you can add your own prefix and suffix
    • Your own custom codes, one per voucher
    • A single code, the same for every download of a voucher
  • Simple statistics on the number of downloads of each voucher
  • A CSV export of all registered names and email addresses

As you can see, I’ve been a busy boy. Lots of people have asked for the custom codes thing, and a way to style the registration form easier, and both of those things are in this version.

So I think, quite rightly, this deserves to be the official Version 1.0 of the VoucherPress WordPress Plugin. Download it here (once the WordPress plugin administrators have checked all the t’s are dotted and i’s are crossed).

Testing VoucherPress

This is a test of my new plugin for WordPress. It’s called VoucherPress. Can you tell what it does yet?

Try this on for size: [voucher id=”1″]

With a description: [voucher id=”1″ description=”true”]

And this one should ask you for your email address: [voucher id=”2″]

And a test of a voucher link with a preview:

[voucher id=”1″ preview=”true”]

And a preview with a description:

[voucher id=”1″ preview=”true” description=”true”]

And one with a limited number of downloads:

[voucher id=”3″]

And one more:

[voucher id=”4″]

List of all vouchers:

[voucherlist]

And a list with descriptions:

[voucherlist description=”true”]

Technology and creativity

Confession time. When I was a child I was a big fan of Mary Norton’s Borrowers books. These little people were almost real to me, to the extent I would look for clues to their actual existence. I suppose I thought something that engrossed me so much must be based in reality. (By the way, forget the travesty of a film, the books are MUCH better.)

I had some Borrowers myself. They were Star Wars figurines, which were a little smaller than the real Borrowers, but suited my purposes well. Up to an embarrassingly mature age, probably 12 or 13, I would create worlds for my Borrowers out of shoe boxes, book covers, string and anything else I could find. I built houses and vehicles, systems for defence, drawbridges, pulleys and trapdoors. I stopped short of using dolls house furniture to furnish rooms (hey, I’m not *that* sad) but still, I remember spending far too much time playing with my Borrowers.

When I was a little older electronics took over. I would take apart old radios and try to put them back together. I always failed. In fact I never remember anything working better after I’d tinkered with it – in fact I never remember anything work at all after I’d tinkered with it. So I made pretend devices. I got into no small amount of trouble once when I built a fake bomb including a large lump of Blu-tack inside a box. I didn’t know there was an IRA bomb scare that day, and I certainly didn’t intend my device to be found. I grew up a little bit that day.

Looking back I see that – like everyone – I’m a product of my past. Those years spent building things out of bits I had lying around were teaching my brain to develop in two directions: technology and creativity. And tinkering with stuff to make something new is exactly what I continue to do today.

You see, the art of being a web developer is about the creative use of technology – taking bits we have lying around (HTML, PHP, JavaScript, SQL) and making something new. Both sides of the coin are as important as the other. You can start with the technology – the lines of code, bits and bytes – and apply some creativity to make them into something useful. Or you can start with creativity – an idea, a vision of a finished product – and then use the technology to make it happen. But you can’t have one without the other. they rely on each other.

A how developer makes thousands of tiny choices every day, from how to construct a block of code to what kind of button to use in a form. Sometimes lucky people may have UI designers to work with who make some of those decisions for them, but I would guess most web developers have to wear lots of hats at the same time. Database schema designer, UI designer, backend developer, front end developer, graphic designer, documentation writer and project manager are just the hats I’ve worn today.

Having both creativity and technology on your side helps you to wear all these hats, and stay sane. Creativity helps you make those small decisions that move a project in the right direction. Technology helps you put those decisions into action. Technology helps you know what options are available to you at every decision point. Creativity gives you the inkling you need to choose the right path.

It seems my brain, because I’m a product of my past, fits this technology/creativity mix quite well. For the same reason I love jazz music, as it is based on the two pillars of technology (chord structures and sequences, scales, arpeggi, melodies and more) and creativity. I’m sure there are many more things that have a similar mix of these two elements (architecture and cookery, for example).

As we start a new year I want to help develop my skills in these areas. I want to develop my technological skills by learning more about the technologies I use every day, and possibly some new technologies. And I want to develop my creative skills by looking closely at how other more advanced developers have used technology in creative ways. Hopefully by the end of 2010 I’ll be able to say I’ve moved forward.

Performer for WordPress

The worlds best CMS just got better, with the creation of a plugin for Performer. Unless you’ve been living under a rock you’ll have heard me waffle on about my JavaScript mini-library which allows you to use those cool effects that your favourite JavaScript library (such as jQuery, Prototype and MooTools) allows you to do. But without writing a single line of JavaScript. Yes, it’s true.

Here’s a simple example. Click here to be amazed.

If everything went to plan this text came pleasingly into view. You might think "Yeah, I’ve seen that JavaScript stuff before", but look at the code I wrote to make that work:

<a href="#" class="toggler targetEl-performerdemo1">Click here to be amazed</a>
<div id="performerdemo1" class="hider"> ... </div>

Yup, just CSS classes.

If you want more information please visit the main Performer website, or download the WordPress plugin here.

Internet Explorer bug with cloneNode()

I just spent the best part of an hour bashing my head against a keyboard because Internet Explorer wasn’t doing my JavaScript right, but Firefox and Chrome were. Turns out it was a simple solution. I had code like this:

element.innerHTML = element.innerHTML + '\n';
var clone = element.cloneNode(true);
targetElement.appendChild(clone);

But for some reason, despite the true parameter being passed to cloneNode() so it would clone children, no children would appear. Even stranger, this:

element.innerHTML = element.innerHTML + '\n';
alert(element.innerHTML);
var clone = element.cloneNode(true);
targetElement.appendChild(clone);

Alerted the element.innerHTML without its children. Turns out this line:

element.innerHTML = element.innerHTML + '\n';

Messes everything up, even in Internet Explorer 8. All I wanted to do was make the modified HTML source a little nicer, but it screwed up in the web developers nemesis.

Hopefully this helps someone else.