New and improved method to remove / block DiggBar

ADVERTISEMENT

Last week, we shared JavaScript and PHP code snippets to block DiggBar. While they served the purpose fairly well, each had its own flaws.

Here is a new, improved method that puts two and two together – by combining the PHP and JavaScript code to get the best of both worlds. The PHP method provided would display a message and stop rendering the page, whereas the JavaScript code would remove all frames – including Google Images. This means that visitors who see the image from, say archive pages, would not have a link to click through to the actual page.

So, I combined the two so that the below code checks whether the visitor is viewing a Digg shortened URL (typical of DiggBar), and if so, serves some JavaScript to redirect the user to the original web page. This method can be used not just in WordPress, but in any CMS/app that supports PHP.

ADVERTISEMENT

<?php if (preg_match('#http://digg.com/\w{1,8}/?$#',
$_SERVER['HTTP_REFERER']) ) { ?>
<script language="JavaScript" type="text/javascript">
if (top.location != self.location) top.location.replace(self.location);
</script>
<?php
exit;
}
?>

And by the way, even Engadget, a gadget blog that hits Digg on a regular basis, has blocked Digg Bar. If a top publisher should block the DiggBar, I hope Digg realizes DiggBar’s problems and does some serious thinking over it.

To get our latest articles, click here to sign up for our free email newsletter or subscribe to RSS feed

§ Leave a Reply