Subscribe to RSS feed Prenumerera på RSS-flöde or eller follow me follow me on Twitter? på Twitter?
Last week, we shared JavaScript and PHP code snippets to Förra veckan delade vi JavaScript och PHP kodbitar till block DiggBar Block DiggBar . . While they served the purpose fairly well, each had its own flaws. Medan de syftade den ganska bra, hade varje egna brister.
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. Här är en ny, förbättrad metod som sätter ihop två och två - genom att kombinera PHP och JavaScript-kod för att få det bästa av två världar. The PHP method provided would display a message and stop rendering the page, whereas the JavaScript code would remove all frames – including Google Images. PHP metod som skulle visa ett meddelande och sluta göra sidan, medan den JavaScript-kod skulle ta bort alla bilder - inklusive 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. Detta innebär att besökare som ser bilden från, säger arkivsidor, inte skulle ha en länk att klicka sig vidare till själva sidan.
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. Så kombinerade jag de två så att den under koden kontrollerar om besökaren tittar på en Digg förkortad URL (typiskt DiggBar), och i så fall tjänar en del JavaScript att dirigera användaren till den ursprungliga webbsidan. This method can be used not just in WordPress, but in any CMS/app that supports PHP. Metoden kan användas inte bara i WordPress, men i alla CMS / app som stödjer PHP.
<?php if (preg_match('#http://digg.com/\w{1,8}/?$#', <? php if (preg_match ( '# http://digg.com/ \ w (1,8 }/?$#',
$_SERVER['HTTP_REFERER']) ) { ?> $ _SERVER [ 'HTTP_REFERER'])) (?>
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
if (top.location != self.location) top.location.replace(self.location); if (top.location! = self.location) top.location.replace (self.location);
</script> </ script>
<?php <? php
exit; exit;
} )
?> ?>
And by the way, even Engadget, a gadget blog that hits Digg on a regular basis, has Och förresten, även Engadget, en gadget blogg som träffar Digg regelbundet, har blocked Digg Bar blockerade Digg Bar . . If a top publisher should block the DiggBar, I hope Digg realizes DiggBar's problems and does some serious thinking over it. Om en topp utgivare bör blockera DiggBar, hoppas jag Digg inser DiggBar problem och gör något allvarligt tänka över det.
Related reading Relaterade läsning
- How to remove DiggBar (Greasemonkey script) Hur tar man bort DiggBar (Greasemonkey script)
- JavaScript and PHP codes to remove DiggBar JavaScript och PHP-koder för att ta bort DiggBar
- DiggBar Remover removes DiggBar the smart way DiggBar Remover bort DiggBar ett smart sätt
- How to block popups and ads in Google Chrome Hur man kan blockera popup-annonser i Google Chrome