WordPress Widgets and Google Adsense

I’ve upgraded my blog to use widgets and in the process upgraded a few other things to use widgets too.

I’m using Otto’s Google Adsense widget, it’s working very well.

Except, as you may recall reading here and here, there is an issue relating to the WordPress post preview and Google Adsense that could result in Google blocking your Adsense account.

I’ve not checked to see if the problem has “gone away”, but to be on the safe side, I’ve hacked Otto’s gadsense.php widget to prevent Google Adsense blocks from appearing in the preview. Here’s the code fragment that includes the hack, lines 10 and 12 are the ones to look out for:

[code lang=”php”]
function widget_adsense($args, $number = 1) {
$options = get_option(‘widget_adsense’);
$title = $options[$number][‘title’];
$text = $options[$number][‘text’];

is_preview): ?>

Technorati Tags: , , ,