Subscribe to RSS feed Subscribe to RSS feed or vai follow me sekojiet man on Twitter? on Twitter?
Last week, we shared JavaScript and PHP code snippets to Pagājušajā nedēļā mēs dalītu JavaScript un PHP koda daļas, lai block DiggBar bloķēt DiggBar . . While they served the purpose fairly well, each had its own flaws. Kamēr tie kalpoja, lai diezgan labi, katram bija savi trūkumi.
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. Šeit ir jauna, uzlabota metode, kas izvirza divus, un divi kopīgi - apvienojot PHP un JavaScript kodu, lai iegūtu labāko no abām pasaulēm. 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 metode, kas displeja paziņojumu un apstāšanās padarīt lappuses, turpretim JavaScript kods nojauks - visi rāmji skaitā 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. Tas nozīmē, ka apmeklētāji, kas redz attēlu no, teiksim arhīva lappusēs, nebūtu saiti noklikšķina uz Faktiskā lappuse.
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. Tātad, es kopā divus tā, lai zem kodu pārbauda, vai apmeklētājs ir apskates Digg saīsināts URL (tipisks DiggBar), un ja tā ir, kalpo daži JavaScript novirzīt lietotāja sākotnējo tīmekļa lapu. This method can be used not just in WordPress, but in any CMS/app that supports PHP. Šo metodi var izmantot ne tikai WordPress, bet jebkurā CMS / app, kas atbalsta 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 Un tā, pat Engadget, sīkrīku blogu, kas hits Digg uz regulāri, ir blocked Digg Bar bloķēts Digg Bar . . If a top publisher should block the DiggBar, I hope Digg realizes DiggBar's problems and does some serious thinking over it. Ja top izdevējs vajadzētu bloķēt DiggBar, es ceru Digg realizē DiggBar problēmas, un tā vairākas nopietnas domas pār to.
Related reading Related lasījums
- How to remove DiggBar (Greasemonkey script) Kā noņemt DiggBar (Greasemonkey script)
- JavaScript and PHP codes to remove DiggBar JavaScript un PHP kodu noņemt DiggBar
- DiggBar Remover removes DiggBar the smart way DiggBar Remover noņem DiggBar Gudrs veids
- How to block popups and ads in Google Chrome Kā bloķēt izlecošos logus un reklāmas Google Chrome