WordPress MU 1.2.5

A new release of WordPress MU, the multi-user, multi-blog version of WordPress is now available.

This is a security release to address issues brought to our attention by Alexander Concha who I must thank for his unfailing patience while we sorted out this release.

Edit: this release is based on WordPress 2.2.3. Unfortunately a last minute bug crept in where post titles looked like post slugs when viewed on your blog. I quickly rolled together a new minor release, 1.2.5a which has an updated wpmu-functions.php. The download page has been updated too. If you have already updated your install, all you have to do is go to this page and download a new wpmu-functions.php and place it in your wp-includes directory. Apologies for the mix up!

Edit 2: I forgot to mention yesterday that a lot of the functions that were in the files in mu-plugins/ have been moved into wp-includes/wpmu-functions.php so move those files out of the way if you get errors about functions already existing. As stated previously on the forum, kses.php is synced with the one in WordPress which means class and id will be stripped from posts. If you’re happy for your users to use the class and id tag attributes then the following function will come in handy. Put it in mu-plugins/kses.php where it will be activated automatically.

function addabitofclass( $tags ) {
    global $allowedposttags;
    foreach( $allowedposttags as $tag => $attr ) {
        $attr[ 'class' ] = array();
        $attr[ 'id' ] = array();
        $allowedposttags[ $tag ] = $attr;
    }
    return $allowedposttags;
}
add_filter( 'edit_allowedposttags', 'addabitofclass' );

The observant among you will notice I forgot to assign the result of the filter in wp-includes/kses.php. This has since been fixed but it was too late for this release. Making it a global in the function above was a suitable work around.

Friends don't let friends see adverts

This post has been a long time in the writing. Ever since I started advertising on my blogs my strategies have been tweaked continuously so consider this post a snapshot description of what I’m doing with Adsense advertising now. This is a long post, but read through it. The plugin I use to do most of this stuff is linked near the end.

Last year at the IT@Cork Web 2.0 conference, Gavin mentioned that he earns enough off his blogs to pay for his hosting, and I thought to myself that it would be handy to have an extra bit of cash to do likewise. I didn’t do anything about it until July when I signed up for an Adsense account and put some ads on the site. Things were slow that month but they’ve steadily improved to the point that it’s a reasonable second income now.

At last year’s WordCamp in San Francisco, one of the talks was about monetizing your blog. It was a fascinating talk with a great discussion afterwards and I brought home some good ideas:

  • Don’t show adverts to your friends. They are the people who visit your blog and leave comments. They’re not going to click the ads anyway.
  • Position matters. Right underneath the post title and above the content is the best place on a blog to put an advert. (Thanks Matt!)
  • Go as wide as you can.
  • Experiment with ad colours, borders and sizes. Don’t accept the Google defaults. Blend your ads or make them stick out. It all depends on your blog.

Since then I’ve developed my ad serving strategies further:

  • I love when people comment, and I’m honoured when people subscribe to my blog. Therefore I won’t show my RSS or email readers adverts. If you like what I do enough to subscribe I won’t burden you with advertising. You’re my friend.
  • Don’t show adverts on the homepage.
  • Adsense Injection is great for putting adverts directly into posts.
  • Monetize your archive. Any post older than a month gets adverts.
  • Don’t show adverts to Digg, Delicious and Stumbleupon visitors.
  • Identify where most of your “just passing through” traffic is coming from and show them adverts, except for social bookmarking websites of course.
  • If my blog showed you adverts, I’ll tell you “Don’t like adverts? Leave a comment and they disappear.” below the comments form. At least one person has commented favourably about that.
  • Fill the competitive ad filter with low paying URLs. If you’re still showing ads from helium.com then you’re missing out. If your daily eCPM isn’t at least $5 you’re not making the most of your advertising. Subscribe to notspam.org to see which MFA and low paying sites go into my competitive ad filter. I’ll talk about the competitive ad filter in more detail in a future post.
  • Set an hour long cookie for users from search engines. Blogs have a notoriously low attention span for most visitors but if they click to the front page, show them a few more ads.
  • I use Kontera too but the returns from that have been very disappointing. One of my posts has an AuctionAds unit in it. You’ll see that no matter what because I’m testing it for a few weeks and the post in question is almost always only hit by visitors from Google.

I run advertising on my photoblog, In Photos dot org too but the rules there are a bit different:

  • Each post has a big image, pushing the text description below the fold. That’s not ideal for displaying adverts so I use the left sidebar to show a 600px high Adsense skyscraper unit.
  • Show the sidebar advert even on the homepage. It’s not an ideal location so better give it as much exposure as possible.
  • It’s difficult to attract visitors to a photoblog. I wrote 11 seo tips for your photoblog to outline some of the ways I draw traffic in. The biggest mistake is definitely not writing about your photography. If there is no text, how can the search engines figure out what your blog is about?

I’m not the only one only showing adverts to selective visitors. Recently Ben Gillbanks had a great post on increasing Adsense earnings that says some of the same things I summarised here.

I haven’t tried it yet, but the who sees ads plugin from Ozh does most of the same checks I do. That plugin won the WordPress plugin competition so congratulations to Ozh on winning!

The No Adverts for Friends plugin

Announcing my shiny new, rough as anything No Adverts for Friends plugin! This plugin adds new commands that you can use in your templates. Use them to surround your Google Adsense or other advertising code.

The No Adverts for Friends API:

  • is_regular_user() – returns true if the visitor has left a comment or is logged into your blog.
  • is_whitelisted_site( $url ) – returns true if $url is in a pre-defined list of friend sites like Digg, Delicious and StumbleUpon.
  • is_old_post() – returns true if the current post is over a month old.
  • is_searchengine_user() – if a user comes from one of the listed search engines or this is an old post return true.

Each of the API calls depends on the one before it returning a favourable value. For example, is_old_post() won’t return true if is_regular_user() returned true, no matter how old the post is.

Example usage:
<?php if( is_searchengine_user() == false ) { echo "Google adsense code goes here"; }?>
Edit single.php in your current theme and add that code somewhere within the loop. Now either visit an old page on your blog or use a Google search query to bring you to your blog. Hopefully you’ll see the text “Google adsense code goes here”. Replace this text with the Google Adsense Javascript.

Download

Install

  1. Rename both files to .php and place friendsadverts.php in your plugins folder. If you use WP-Cache copy wp-cache-phase1.php into plugins/wp-cache/ overwriting the file already there (make a backup first!)
  2. If you use WP-Cache copy the $nevershowads and $passingthrough arrays from friendsadverts.php into your wp-config.php. They’re needed by WP-Cache which kicks in well before plugins are loaded.
  3. Activate the “No Adverts for Friends” plugin from your plugins page and modify your templates using the new API.

Well, you’ve read this far. If some of the advice in this post helps you, if you like this plugin, if it improves the user experience of your regular visitors and maybe even increases your advertising revenue please consider uncommenting the add_action() command at the start of friendsadverts.php. The donnchas_happy_happy_notice() function prints a message in your blog’s footer saying you use this plugin and links back here.

Thanks John for bugging me to write this up. Hopefully I’ll see you at next year’s WordCamp!

Is your eAccelerator cache dir still there?

While looking through this WordPress performance post I realised that eAccelerator might not be running properly on this blog. For some time I’ve noticed this site hasn’t been as quick off the mark as it used to be. Dare I say it, but it was even a little sluggish!

If you’re not familiar with it, eAccelerator is a PHP accelerator. It caches PHP bytecode and performs optimizations to make your PHP site run a lot faster.

I verified that eAccelerator was loaded and then checked my php.ini configuration. Sure enough, the eaccelerator.cache_dir directive was set to “/tmp/eacc/” and that directory was deleted the last time my server rebooted.

A permanent fix is to change the location of the cache dir. Put it anywhere the webserver can read, but don’t put it in /tmp/.

While you’re looking at eAccelerator, upgrade to the latest version, especially if you’re running PHP5.

Idiot spammers

This comment was posted automatically using Blog Comment Poster. Check out its site to learn more and start building backlinks to your websites today.

This post was written manually using Donncha’s fingers. Check out the Akismet anti comment-spam plugin to stop the idiot spammer at 75.126.132.23 using “Blog Comment Poster”.

Comment Referrers 0.1

comment-referrers.png

Here’s a small plugin that does a small but useful task. It reports where the people who comment on your blog come from. It then adds a line to the end of your comment notification or moderation emails with that information.

Download: comment-referrers.txt

Install by renaming the file to .php and placing in your plugins folder and activating it on your WordPress plugins page.

Update! Here’s the plugin page for this plugin.

Notes when upgrading to PHP5

I upgraded one of my servers to PHP5 this morning. Two things to watch out for:

  • The location of your php.ini may have changed. It’s probably now in /etc/php5/apache2/. You need to copy over any changes from your old one.
  • Update your libraries too such as the mysql client and the gd library. Don’t forget you can delete the old ones. apt-get install php5-mysql php5-gd will do the job of installing, the old packages have a php4 prefix.
  • WP-Cache doesn’t like PHP5 much. If you see a blank page after upgrading to PHP5, then hit reload and it loads, then WP-Cache needs to be modified. Leroy has the fix, open wp-cache-phase2.php in your wp-cache folder and change ob_end_clean() to ob_end_flush(). SImple as that!

The reason for the upgrade? I wanted to install the gd extension, but after lots of fun upgrading everything my browser tried to download every page, complaining that it was a phtml file. I chose the upgrade to PHP5 to fix it!

And finally, the reason for gd, was to get the heatmap in this wordpress click tracking plugin working. It’s like Crazy Egg and it works well, but I couldn’t get it to display a heatmap for any page other than the front page. Some of the comments on Daily Blog Tips where I found it are hilarious. They completely miss the point of using a heatmap!

WordPress MU 1.2.4

The new WordPress MU 1.2.4 went live this afternoon and can now be downloaded. This is based on WordPress 2.2.2, a security release, so it’s important to update your WordPress MU install too. If you haven’t changed any files, all your need to do is copy over the new release and things should work fine.

  • Kses has been reverted so you can use class and id attributes in your HTML tags again. Conor is already happy because his microformats will work again!
  • The installer has been smartened up and is now friendlier and may catch a few more problems before they arise.
  • Lots and lots of bugs have been squashed. It’s been messy but they had to be exterminated.

If you’re comfortable with Subversion and merging file changes, then the list of changed files should come in useful. You can also download a diff file there if that suits. Check the forum announcement for feedback.

Dvorak vs Malik at WordCamp on video

John Pozadzides has released the first video from WordCamp and it’s sure to be one that will interest many. John C Dvorak debates with Om Malik on the subject of Blogging vs Journalism. It’s hosted on blip.tv and John has uploaded a high quality version there.

I won’t embed it here, go look at John’s post for the video! Thanks John for doing such a great job!

We spent a good portion of today at SFMOMA, where they have a really interesting photography exhibit, and some of the modern art on the first floor really caught my eye, especially the self portrait of Andy Warhol and the image containing the pencils across the room from it. Blew my mind they did.
Later we went for dinner but in between we relaxed in a local park. Here’s a photo Alex took of me and Matt. Alex has a neat little RF transmitter and receiver for his camera and flash. He lay the flash on the bench next to him while he shot this photo. Good fill flash and it’s not in-your-face like an onboard flash would be. I have to get my hands on an RF transmitter to go with my 580EX!

While on the subject, this is Automattic. There are quite a few of us now, and as you can see, we’re really getting into the formal “must wear a suit to work” dress code.

WP Tip: don't blog as Administrator

do not blog as administrator

The default user when you install WordPress is called “Administrator” and many people don’t change it which unfortunately leads to anonymous looking posts made by Administrator instead of by Matt, Mark, Lloyd, Joseph, Alex or your own name of course.

I would venture to say it’s a new user problem but I remember seeing Administrator posts by old hands at the blogging game so it might be worth double checking, just in case. Your template might not show Administrator, but your RSS feed isn’t as clever.

It’s simple to check and fix. Log in to your WordPress blog, go to Users, and then Your Profile. If you haven’t changed your first and last names, do it now. Click “Update Profile” and then change your “Display name” to a friendlier name.

One final tip, it’s probably much safer to blog as a non-admin user. If you’re logged in all the time, consider creating an editor or author user. If you leave your laptop unattended in a busy area for a moment it’s much less likely that someone will do real harm to your blog. (Presuming they don’t rob the laptop first!)

If you’re a WordPress.com user, then don’t worry about Administrator showing up on your blog posts, it won’t happen as your login name is your author name. Isn’t that nice?

Sunday Morning Wordcamping

IMG_2801.jpg

Barry spoke at length about High Performance WordPress this morning, and Matt came on stage to introduce and summarise the main features of the new Hyperdb. If you missed it you’re definitely going to want to watch the video when it comes out. I certainly wouldn’t have guessed that Barry was out last night telling me, “ah you’ll have one more before you go..” 🙂
Great talk guys!

Barry’s talk is already online. That was fast!

Rashmi Sinha, Iterative Design in Agile Environments

Rashmi Sinha’s talk on “Designing Massively Multiplayer Social Systems” is fascinating. I agree with her observation that the Internet really isn’t democratic. Whoever is popular will get ever more popular, in general. There are exceptions of course but the well established bloggers like Robert Scoble are hard to dislodge from their pedestals.

Dave Winer at Wordcamp

Dave Winer talking at Wordcamp.

John Pozadzides, Wordcamp Cameraman

John Pozadzides is the guy with the camera on the balcony at Wordcamp. He’s going to post videos of the event online and is looking for suggestions about where that should be. I’ll suggest blip.tv, as it’s served me well in the past!

Liz Danzico, Usability Analysis of WP

Liz presented research into the backend that will eventually make it into WordPress 2.4

Finally, Charles Stricklin has a great write up on the second day including the reminder that I sort-of promised to release that Paypal Instant Payment Notification code ..

There are literally hundreds of images from WordCamp on Flickr. Scott has posted a few too, and made them available under a CC license and here are a few photos taken by Alex who is just as mad about photography as I am!

ocao7-500.jpg

Really finally this time. I had my photo taken and then they made a cartoon out of it. Thanks! 🙂