Lunacy Unleashed

Notes from the field in the War on Spam

2005 will be a bit longer this year

For the first time since 1998, the year will be about one second longer, as scientists agreed to add a leap second to the year.

Among other things, this means you start the 10-second countdown to midnight at 11:59:51 pm.

The once-common “leap second” is the first in seven years and reflects the unpredictable nature of the planet’s behavior.

The International Earth Rotation and Reference Systems Service in Paris keeps track of time by measuring the Earth’s rotation, which varies, and by an atomic clock, which is unwavering. When a difference in the two clocks shows up, the IERS adds or subtracts a second to the year.

For the first time since 1998, the IERS will sneak in an extra second this year to get time back in synch, officials said in a statement Monday.

On Dec. 31, the clock will read like this as it leads into Jan. 1, 2006:

23h 59m 59s … 23h 59m 60s … 00h 00m 00s. Normally, the seconds would roll from 59 directly to 00. — Live Science

Since 1972, when the technology had advanced sufficiently to keep accurate time, scientists have added 22 leap seconds. This weekend’s will be the 23rd.

December 27, 2005 Posted by | Uncategorized, WordPress.com | Comments Off

AdSense on WordPress 2.0

If you’re upgrading to WordPress 2.0 and use Google AdSense, there is something very important you need to know to ensure you continue to get well-targeted ads, and that Google doesn’t suspend your account for program violations.

One of the new features in WordPress 2.0 is a live post preview. If you scroll to the bottom of the page while editing a post, you’ll see a live preview of how your page will look once it’s published. This is a very nice addition to WordPress, but for AdSense publishers, and those using other context-targeted ad networks, it presents a serious problem.

When the post preview is rendered, it will try to fetch your Google ads!

And because the post hasn’t been published yet, when Google’s bot tries to crawl the page a few seconds later, it will receive a 404 error.

The best case scenario for this is that some of you (who don’t use permalinks) will receive very poorly targeted ads for up to two weeks after you publish your post.

And the worst case scenario, since Google prohibits displaying ads on 404 pages, is that you could get your account suspended.

WordPress 2.0 does provide a solution, though; it’s the new is_preview template tag. This new tag tells whether the post is being displayed in the post preview section while it’s being edited.

So all you need to do is to add in a check for this into your template code wherever you have placed AdSense, and the problem will be solved. Just add this code around your AdSense code:

<?php if (!is_preview()): ?>
// Paste your AdSense code here //
<?php endif; ?>

This way, the post preview will not try to show Google ads, and they will only be shown once your post is published. This will keep your AdSense account safe and your ads well-targeted.

Update: It’s come to my attention that is_preview() may be broken. If you find that’s the case, submit a bug report and post the ticket number in the comments below so we can track it.

Update: I’ve tested is_preview() and it seems to be working just fine. Like other template tags, it only works inside the loop, though.

Update: Since people frequently place ads outside the loop, there needs to be a way to test for this outside the loop. The following workaround worked for me:

<?php global $wp_query; if (!$wp_query->is_preview): ?>
// Paste your AdSense code here //
<?php endif; ?>

Update: Ticket 2188 is open for is_preview() acting strangely.

December 27, 2005 Posted by | AdSense, Advertising, Google, WordPress, WordPress 2.0 | 40 Comments

   

Follow

Get every new post delivered to your Inbox.