Click Counter Plugin For WordPress

Ooh, nice! A click counter for WordPress! It comes in two parts – a redirect script and a WordPress plugin. I wasn’t sure how well it’d work but it was simple to install – after modifying the sql to record and recognise each blog ID all I had to do was activate the plugin in the backend. If you want to activate it on your WPMU blog here just go into “Plugins” and click the “Activate” link! I’ll get the extra template tags into Smarty land in a minute and update this post shortly.
Here’s the extra template tags that come with this plugin:
wp_ozh_click_topclicks and wp_ozh_click_comment_author_link – there’s documentation on the plugin page above, but working with Smarty functions and parameter passing is quite easy if you’re used to HTML. Here’s what I did:

<br /><span>Most Popular Clicks</span><br /><ul>
{wp_ozh_click_topclicks limit=10}

<p><cite>{comment_type} {_e text="by"} {wp_ozh_click_comment_author_link} — {comment_date} @ <a href="#comment-{comment_ID}">{comment_time}</a></cite> {edit_comment_link link='Edit This' before=' |'}</p>


Custom Fields in WPMU

You can now use custom fields to execute functions in WPMU!
Currently there’s only one function, that’s “photoblog” but more will come.
When you’re writing a post, click the “advanced editing” button and scroll down. You’ll see text boxes where you can enter custom field keys and values. Now, edit your blog post.html in the template editor and add {custom_fields} where you’d like the output to appear.
For my last post I used “photoblog” as the key, and “20040922” as the value. The photo will appear tomorrow and I avoid all the nasty Javascript I had before!


Popular Posts Update

The popular posts plugin was broken, but it’s fixed now. Update your template so it looks like this if you want to use it:

{if $pposts != ''}
<br />Most Popular Posts<br /><br />
{foreach from=$pposts key=key item=details}
<nobr><a href="{$details.url}" title='{$details.title}'>{$details.title|truncate:30:"..."}</a>: {$key}</nobr><br />


Summary Feeds – why no links?

If you’ve wondered why your RSS feed here doesn’t have any feeds, that’s because WordPress by default displays only summaries.
To show the full text and mark-up of your posts, go into Options->Reading and click “full text” for the option, “For each article, show:”

God damn bookmarklet, kills my browser (Mozilla Firefox 1.0 preview) more often than not. *grrr*


Oh woh is me! Comment Spam Already!

It didn’t take long for the comment spammers to figure out we’re running WordPress here. I got a dozen requests to moderate comments this morning. Mark did too, but he had turned off the notification in WP so there may be a bug there somewhere. Expect test comments to appear and disappear on this post over the next hour or so!
Later… Fixed it. There’s no check for the “moderation_notify” flag . Here’s how to patch your own WordPress system:

Edit wp-includes/functions.php and add the following lines to the function wp_notify_moderator():

if( get_settings( "moderation_notify" ) == 0 )
    return true;


WordPress Tags – Use Them!

Someone on #wordpress asked how they could list the number of posts in every category. They were pointed at this page in the support forum. Even though we’re using Smarty as the templating system here, what’s stated there applies here! Add the following parameter to the call to {list_cats}:optioncount=1
ie. {list_cats optioncount=1 optional='0' all='All' sort_column='name'}
There’s a comprehensive list of WordPress Template Tags on the WP Wiki.
It should be the first port of call for anyone looking for help editing their template as the difference between Smarty syntax and PHP isn’t great and is easily learnt once you’ve digested what the template does.
And here are the docs on custom fields. It should be simple to add a Smarty function that’ll display my pic of the day again! (via the support forum)


WP Database Error – edit.php

Mark found a bug in the backend but it’s been discovered already and discussed. I applied my own fix below..

Warning: join(): Bad arguments. in …/wp-admin/edit.php on line 13


if( is_array( $editable ) == false )
  $editable = array( "1" );
$editable = join(',', $editable);

On another note, if you can’t post blog entries as anything other than “Draft” or “Private”, then go to Options->Writing and check “May publish articles” for “Newly registered members:”
Now, if only we could set publishing rights to a certain user level, then new users could publish if the admin set their level high enough.


Now Running WordPress

The site is now running on WordPress. I’m going to get some breakfast.
Much Later – Still problems with feeds. I’m updating tonight to the CVS snapshot of WordPress from this morning so breakages are likely, but hang on in there! We’re almost home!
Later Still – Merging of the CVS version of WordPress is complete. I’ll have to track this as time goes by but it looks to have solved the problems we had earlier! 🙂


PictPress – WordPress Gallery Plugin

Oooh, PictPress looks nice but I’ll have to put some restrictions on usage here as convert is such a dog on any system! Hmm, it’ll need some sort of upload facility in the backend too as it’s impossible to create directories in the images folder right now.

b2 WordPress

WordPress and Smarty

I was drafted in to help on WordPress a long time ago. Unfortunately I haven’t done much work on any OSS projects in a while and it was bothering me.
I did do some useful work though – I found out that the Smarty register_resource construct was buggy when using caching. That rules out using MySQL as a backend to hold templates. (I posted a mail to the Smarty list but nothing came of it. *shrug*)
Finally, after re-installing Linux on my new hard drive last weekend I Smartyised WP! Here’s a WIP snapshot.
What does it do? Well, I wrapped some of the Smarty template API (ie. bloginfo(), etc) in Smarty functions of the same names. I’ve only done enough to get the default template working, as it’s laborious work and I wanted to get something out quickly!
The template is split up into 3 parts: top.tpl, post.tpl and end.tpl. They live in users/main/templates/ and can be edited there with a text editor. The online editor from b2++ will make it’s way there eventually probably.

Before trying this, please be sure to backup your WP installation. The files in the tarball don’t conflict with the files in CVS but I can’t guarantee that this won’t delete all your WP install files if you’re not careful!

Download the WP – Smarty mod. (40Kb)