Category Archives: Wordpress

WordPress 3.0 has been launched. And it’s late. And I’m busy all of tomorrow. And the weekend.

I’m not going to risk the install now – sods law says it will go hideously wrong.  I could try the install whilst I’m at work but their wireless network is so slow it’s nearly impossible to use.

Damn you WordPress (shakes fist at sky).

(More details tomorrow)

ClickHeat ScreenshotWanting to learn a bit more about the visitors to this site, I thought installing a heat map on the site would be a good start.

I initially used PicNet Mouse Eye Tracking – this is free, but an advert for the service appears at the foot of your site. However, I soon came across the OpenSource ClickHeat. You can use this on any kind of site and is a PHP-based installation.

After much gnashing of teeth, here’s how I got it installed…

  • Download the latest version of ClickHeat and unzip it
  • Install this into a folder on your server
  • Now, from the address bar of your browser, open up the folder. e.g. If you installed it to www.mysite.com/clickheat, you’d go to this directory in your address bar.
  • This will start the installer. I found errors straight away – make sure the config, log and cache folders are writeable.
  • Done. You simply need to add the code to start tracking – return to the ClickHeat folder to access your heat map and make settings changes.

To test it’s working, simply append ?debugclickheat to the end of any of your sites URLs.

For WordPress, there is a plugin available, but I couldn’t get this to work. Instead I added the JavaScript (which is generated from the ClickHeat admin screen) directly to my footer.php file in the theme folder, wrapping it in a check to ensure that an admin isn’t signed in (so it doesn’t track my clicking!).

One more problem I cam across – in the ClickHeat admin screens I kept getting the following error…

Warning: ob_start() [ref.outcontrol]: output handler 'ob_gzhandler' cannot be used twice in /xxx/clickheat/index.php  on line 51

Obviously, I’ve replaced the directory path with “xxx” for security reasons.

After some searching around, I decided the best solution was to make a modification to the ClickHeat code itself. Open up the index.php file within the ClickHeat folder and attempt to find the line that starts with the following…

if (@ini_get('zlib.output_compression')

Before this line, add the following…

ob_end_clean();

And that’s worked for me.

I’ll report back on how I get on with ClickHeat.

There are some excellent plugins available to allow you to make time sensitive posts and pages expire. However, these work for the entire post/page rather than just a section.

Here’s the simple solution – a shortcode that you wrap around some content and allows you to specify a date on which it should expiry and simply not display anymore.

Add the following code to your functions.php file in your theme folder…

add_shortcode('expire','expire_text');
function expire_text($paras="",$content="") {
   extract(shortcode_atts(array('date'=>''),$paras));
   if ( ($date!="")&&(date("Ymd")>$date) ) {$content="";}
   return $content;
}

(The above code has been simplified since the post was originally created)

Now, simply add [expire date="yyyymmdd"][/expire] around any text you wish to expire – change yyyymmdd to a date in that format.

For example…

[expire date="20101231"]It's 2010![/expire]

This will display the message “It’s 2010!” until after 31/12/2010.

This is the quick solution – a much fuller version, with expiry time as well as the ability to get content to appear on a specific date/time, will be released as a plugin soon.

I’ve never run a competition before and, thanks to Creative, my first opportunity has just concluded.

And what did I learn?

Well, a lot. First of all, the questions I should be asking the prize providers. Instead I kept badgering them as I kept asking some pretty basic questions…

  • When do you want the competition to start?
  • How long do you want the competition to run for
  • Are the prizes all for one person, all a “first” prize, or staged (first prize, second prize, etc)
  • How long until delivery
  • What will you provide if a product is no longer available?

Whilst running the competition I kept an eye on the entries to ensure that I wasn’t receiving multiple entries per person or household. And, after only 24 hours, I appeared to have found a problem – 3 people, each with an AOL email address, and the same IP address. Suspicious? It looked like it to me.

However, the fact that AOL is their ISP is the key here – they use a proxy-based system, meaning that many users may share the same IP address. Wikipedia has discussed such an issue before on their own site.

The database I created to hold winner details held a name, address, email, competition answer and IP address. Based on the AOL problems I now realise that I should also store a time stamp and user agent. I’ll be making these changes for next time.

I did a lot of work on the competition coding to ensure SQL injection problems. None-the-less I realised a few days ago that although the competition entry form disappears after the closing date, the code to submit the form details into the database still exists. This means that a third party script could inject entries (although not anything that would affect security) after this time. Again, this will now be fixed for future.

Lastly, I had so many entries that just trying to keep track of “rule breakers” became a lot, lot harder – more work on flagging such things at the point of competition entry will be useful, and I feel an automated email coming on!

Meanwhile, I have contacted the 3 winners and am just awaiting a confirmation of their postal addresses before details are announced.

Dashboard ScreenshotIf you wish to add a widget to your WordPress dashboard then that’s a different, and longer, discussion. Instead I’m going to show you how to add a simple message, of your choosing, to the “Right Now” box.

How could you use this? You could use a database lookup beforehand, for instance, to report on useful blog/theme information. I’m using it right now to report on how my competition is running – I’m performing a count on the table and reporting the output back (see image to the right).

First of all, you need to add an action for activity_box_end pointing to your new function. All of the code discussed here should be put in your theme’s functions.php file. In this example I’m pointing it to a function named show_admin_message

add_action('activity_box_end','show_admin_message');

Within your function you then simply need to output the HTML. Here’s a complete piece of code that you can use…

add_action('activity_box_end','show_admin_message');
function show_admin_message() {
   $output_text = "Put your output message here";
   echo '<div style="border: 1px solid #ffd700; margin: 10px 0 0; padding: 5px; background: #ffffba; color: #000;">'.= __($output_text).'</div>';
}

This will display the text “Put your output message here” in a yellow box, with a darker yellow border. The text will be in black.

Top
%d bloggers like this: