Make your WordPress plugin talk AJAX

This morning at BarCamp Cork I gave a short talk on how to add AJAX functionality to WordPress plugins.

Here are the example scripts I used during the talk. Rename the files to .php and install as you would normal WordPress plugins.

  1. helloworld1.txt – very simple and basic “Hello World” plugin.
  2. helloworld2.txt – script that will display the text “Hello World” using an AJAX request to get the text from the server.
  3. helloworld3.txt – script that displays “Hello World” text, and an “update” link that increments a counter via an AJAX http request.
  4. helloworld4.txt – script that displays a simple form. The form has one text box, a “Random” button and a “Save” button. Clicking the “Random” button makes a request to the server to get a random number. “Save” sends the number to the server.
  5. helloworld5.txt and rate.txt – “Rating” script to rate a post (Originally from here). Makes an AJAX request to the server with the rating. Server returns randomly generated stats on rating. Place rate.php in wp-content/

All scripts that operate in the Settings page in the Dashboard use a nonce for security and access admin-ajax.php when making AJAX requests. The wp_ajax_$POST[ ‘action’ ] hook is used to execute the actual code that does something useful.

The rating script uses wp_enqueue_script() to load the jQuery class.

If you’re an Irish O2 user, and use Twitter you might like to install the new Tweet Tweet WordPress plugin. Thanks to Enda who let me use his O2 account briefly, I created a plugin that sends Twitter sms notifications using the free O2.ie web texts. That means Meteor, Vodafone and O2 are now covered. Anyone want to contribute a plugin for 3?

PS. I was very proud that Automattic was able to sponsor BarCamp Cork, and hopefully most of the WordPress badges found good homes! Conor says 116 signed up for the event, with just over 100 showing up. That’s a great number to pull in for a Saturday tech event!

IMG_4625

IMG_4724

More photos can be found on pix.ie and flickr. Looks like Phil hasn’t uploaded any of his shots yet! Can’t wait to see what came of his afternoon photo session. I had to leave early and missed it unfortunately.
Discovered photos of my presentation. Yes, I used Vi (or Vim if you want to be pedantic) to give my talk!

Edge of Disgrace

You know there’s something special waiting for you when all around you people are clambering for the download link of Booze Design‘s new C64 demo, Edge of Disgrace.

The demo won first prize at X-2008 in the Netherlands last weekend. Most entries to the demo competition were uploaded quickly but Booze Design wanted to fix a few last minute bugs and caused no end of hype and hysteria. Just check out some of the comments:

Oxidy: I normally don’t comment on demos anymore, but I can’t help myself this time. Edge of Disgrace tops everything I’ve ever seen on the Commodore 64. It’s absolutely breathtaking and I wet myself numerous times during the bigscreen presentation. So much coder pron, so much fantastic graphics, so well polished. Fantastic work HCL/Dane/Jailbird! 10+

Medicus: All demos available for downloading except for the nr. 1? Is this a cruel joke? 🙁

Alias Medron: I would like to know how many people press F5 on this page every 10 seconds .. 🙂
cmooooonn!!!! upload that bloody D64!!!!!

Steppe: As Stainless Steel said, there was a clearly noticable dent in the space-time-continuum while this demo was playing. Caused nausea and wild screaming all over the place. Virtually every goddamn screen was accompanied by cheering and applauding of the crowd. Simply amazing having seen this on the big screen live at the party!

Stainless Steel: I felt a disturbance in the force when this was played at the compo.

A few days ago a teaser video was uploaded to Youtube but it doesn’t do the demo justice. It’s only 2 minutes of the 15 minute experience.

So, is it that good? Yes, it most certainly is. If you ever owned a C64, or any other 8 bit or 16 bit computer or console you should grab a C64 emulator, download Edge of Disgrace and be impressed. I’m amazed at what a 25 year old computer system can do, and even more impressed that the C64 demo scene is still alive and kicking in 2008!

Now to download Natural Wonders 2 and the other entries in the demo compo.

Socialist Party Budget Protest

The Socialist Party held a protest gathering against the recent tough budget. It took place in Emmett Place in Cork this afternoon. I took a few photos and this video. Our friend, Kathy Sinnott was in attendance but I didn’t hang around to listen for long. Must have a read of the leaflet I was handed. Maybe it has all the answers to a crumbling economy.

Gallery of images after the jump..
Continue reading “Socialist Party Budget Protest”

WordPress MU 2.6.3

WordPress MU, the multi blog version of WordPress that runs on WordPress.com has been updated.

Version 2.6.3 has just been released. This is a security release and a required update. More details about the vulnerability in the Snoopy library that WordPress uses can be found on the WordPress 2.6.3 announcement.

This release also includes a number of minor bug fixes but if you want to fix the Snoopy bug alone, it’s sufficient to update these files:

Those are not download links, click through and download the files using one of the links at the end of each page.

Otherwise, updating from 2.6.2 is as simple as overwriting your current install.

WP Super Cache 0.8.4, the garbage collector

WP Super Cache version 0.8.4 is now available. WP Super Cache is a page caching plugin for WordPress that will significantly speed up your website.

This is a minor release but was prompted by White Shadow. He released a plugin that cleans up expired cache files on a periodic basis instead of after X number of hits. Great minds think alike, (or fools seldom differ) because I had the same idea a few weeks ago and had the code running on this blog for that time without any problems.

WP Super Cache 0.8.4

The garbage collection system should have operated this way in the first place, but at least now it’s easier to configure.

Joe Six Pack

So, who is this “Joe Six Pack” that Sarah Palin keeps going on about? The Urban Dictionary says,

Average American moron, IQ 60, drinking beer, watching baseball and CNN, and believe everything his President says.

That isn’t the most flattering description of a demographic group. Who would willingly view themselves as a “Joe Six Pack” after reading that? Is there an Irish or British equivalent?

Anyway, I became curious after hearing another news report about American politics on Irish radio and found that Joe Six Pack really does exist! Joe dishes out the info on a range of topics and describes himself as, “America’s Most-Popular Divorced Dad”. Odd.

It turns out that Joe The Plumber exists too. They’re a plumbing company in Amarillo, Texas. I want one of their tshirts!

I’d love to see their stats. I wonder if the McCain/Palin campaign has sent much traffic to either site? Check out Palin as President for a humorous look at what Sarah Palin’s first day in the Oval Office might be like. Cracked me up.

So, who’s for a Brian Cowen tshirt? Or even an Enda Kenny tshirt? Can you imagine car bumper stickers with Cowen’s face? What would that do to the accident rate in the country?

PollDaddy join the Automattic Family

You’ve probably heard the news that Lenny and Eoin of PollDaddy have joined Automattic. PolDaddy has been acquired by Automattic, but on a personal level we’ve been joined by two great Irish guys from Sligo bringing the Irish contingent of Automattic up to three. Lenny did completely trash me at Wii Tennis but I won’t hold that against him!

We’ve even taken over a house here in Breckenridge, calling it the Irish House. The Irish Tricolour is flying outside an Irish pub downtown. They might lend it to us if we ask nicely ..
Raanan is staying there too so I guess we’ll make him an honourary Irishman for the week!

As well as the great PollDaddy news, expect a few more enhancements to WordPress.com soon, and if I have anything to do with it, a plugin or two that will make it into the WordPress MU community too!

Hold your breath

Life here in Colorado at 9,600ft is much the same as at sea level except for one major difference. The air is noticeably thinner at this altitude and takes some getting used to.

Thankfully we’re not here to train for the Olympics or do anything strenuous like that. Lying in bed is difficult enough! I tried reading last night and became breathless just because I was looking down at my book. Rolling on my side helped, but it’s scary when you can’t catch your breath. It feels like someone holding a bag over my head.

There’s an oxygen bar in a local town, and cans of oxygen can be purchased at the local store. Hopefully no more frights.

No previews of what we’re working on right now, but you’ll see the fruits of our labour soon enough!

IMG_3682

For photos see the Automattic Group on Flickr and/or my Colorado Set.

PS. Check out the WordPress MU plugin contest winners. Well done to everyone involved. 🙂