Subscribe to RSS feed Підписатися на RSS-канал or або follow me Follow Me on Twitter? на Twitter?
Last week, we shared JavaScript and PHP code snippets to Минулого тижня ми поділилися JavaScript і PHP-коду фрагменти block DiggBar Блок 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. Ось новий, покращений метод, який ставить два і два разом - шляхом об'єднання PHP і JavaScript код, щоб отримати найкраще з обох світів. 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 що надається на дисплеї з'явиться повідомлення та припинити надання сторінки, у той час як код JavaScript буде видалити всі кадри - у тому числі 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. Отже, я об'єднав два так, що нижче коду перевіряє, чи є відвідувач Перегляд Digg скоротив URL (типові DiggBar), і якщо так, обслуговує близько JavaScript для перенаправлення користувачів на вихідну веб-сторінку. This method can be used not just in WordPress, but in any CMS/app that supports PHP. Цей метод може бути використаний не тільки в WordPress, але в будь-якому CMS / ок, що підтримує PHP.
<?php if (preg_match('#http://digg.com/\w{1,8}/?$#', <? PHP, якщо (preg_match ( '# http://digg.com/ \ W (1,8 }/?$#',
$_SERVER['HTTP_REFERER']) ) { ?> $ _SERVER [ 'HTTP_REFERER'])) (?>
<script language="JavaScript" type="text/javascript"> <script type="text/javascript"> language = "JavaScript"
if (top.location != self.location) top.location.replace(self.location); якщо (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 І, до речі, навіть Engadget, гаджет, який б'є блог Digg на регулярній основі, має blocked Digg Bar Digg заблокував Бар . . If a top publisher should block the DiggBar, I hope Digg realizes DiggBar's problems and does some serious thinking over it. Якщо верхня видавець повинен блокувати DiggBar, я сподіваюся, Digg розуміє проблеми DiggBar і робить деякі серйозно подумати над нею.
Related reading Схожі читанні
- How to remove DiggBar (Greasemonkey script) Як видалити DiggBar (Greasemonkey скрипт)
- JavaScript and PHP codes to remove DiggBar JavaScript і PHP кодів для видалення DiggBar
- DiggBar Remover removes DiggBar the smart way DiggBar Remover видаляє DiggBar Smart Way
- How to block popups and ads in Google Chrome Як заблокувати спливаючі вікна та оголошень в Google Chrome