A-A+

wordpress博客评论添加goto跳转的形式

2018年03月20日 PHP开源系统 评论 1 条 阅读 0 views 次

现在的博客cms基本上都是支持评论的,如果不能够支持评论功能,也就算不上是博客程序了,在博客之间互访时,博客主都会留下自己的网址,以便于能够获得相应的流量ip互访,而在默认的wordpress博客评论中,点击留言者的网址是直接跳转的,在这种情况下,如果留言越来越多的话,会严重影响自己站点的权重,所以国内的博客主题在评论的地方都是经过加工的。

看到不少的博客都是使用的goto跳转的形式来避免传递权重的,效果就类似于 http://www.xiariboke.net/goto.php?url=网站链接,这样的话,就相当于由外链转内链了,对于汇集自己站点的权重是很有好处的,实现这样的功能也是相当的简单,首先goto.php是一个真实的php文件所存在的,首先建立这个文件,代码如下:

  1. <!doctype html>   
  2. <html lang="en">   
  3. <head>   
  4. <meta charset="UTF-8">   
  5. <meta name="Author" content="">   
  6. <meta name="Keywords" content="">   
  7. <meta name="Description" content="">   
  8. <meta name="robots"content="noindex,nofollow">   
  9. <meta http-equiv="refresh"content="3;url=<?php $url=$_GET['url']; echo htmlspecialchars($url);?>">   
  10. <title>跳转页面</title>   
  11. <style>   
  12. .spinner {   
  13. margin: 100px auto 0;   
  14. width: 150px;   
  15. text-align: center;   
  16. }  
  17. .spinner > div {   
  18. width: 30px;   
  19. height: 30px;   
  20. border-radius: 100%;   
  21. display: inline-block;   
  22. -webkit-animation: bouncedelay 1.4s infinite ease-in-out;   
  23. animation: bouncedelay 1.4s infinite ease-in-out;   
  24. /* Prevent first frame from flickering when animation starts */   
  25. -webkit-animation-fill-mode: both;   
  26. animation-fill-mode: both;   
  27. }   
  28. .spinner .bounce1 {   
  29. -webkit-animation-delay: -0.32s;   
  30. animation-delay: -0.32s;   
  31. background-color: #428bca;   
  32. }   
  33. .spinner .bounce2 {   
  34. -webkit-animation-delay: -0.16s;   
  35. animation-delay: -0.16s;   
  36. background-color: #Dd534F;   
  37. }    
  38. .spinner .bounce3 {   
  39. -webkit-animation-delay: -0.01s;   
  40. animation-delay: -0.01s;   
  41. background-color: #67CF22;   
  42. } www.xiariboke.net  
  43. @-webkit-keyframes bouncedelay {   
  44. 0%, 80%, 100% { -webkit-transform: scale(0.0) }   
  45. % { -webkit-transform: scale(1.0) }   
  46. }   
  47. @keyframes bouncedelay {   
  48. 0%, 80%, 100% {   
  49. transform: scale(0.0);   
  50. -webkit-transform: scale(0.0);   
  51. } 40% {   
  52. transform: scale(1.0);   
  53. -webkit-transform: scale(1.0);   
  54. }   
  55. }   
  56. </style>   
  57. </head>   
  58. <body>   
  59. <div class="spinner">   
  60. <div class="bounce1"></div>   
  61. <div class="bounce2"></div>   
  62. <div class="bounce3"></div>   
  63. </div>   
  64. </body>   
  65. </html>   

说明一下,这个页面我们可以自己去diy一下,做成自己喜欢的样子,也可以加些js加载打开页面之类的效果,建好之后,命名为goto.php,放到根目录下,然后我们在万能的function里面加一个钩子就可以了,代码如下:

  1. /**博客的评论里的外链转内链**/   
  2. add_filter('get_comment_author_link','add_redirect_comment_link', 5);   
  3. add_filter('comment_text', 'add_redirect_comment_link', 99);   
  4. function add_redirect_comment_link($text''){   
  5.   $text=str_replace('href="','href="'.get_option('home').'/goto.php?url=', $text);   
  6.   $text=str_replace("href='","href='".get_option('home')."/goto.php?url="$text); //www.xiariboke.net   
  7.   return$text;   
  8. }  

好了,一个简单的wordpress博客评论外链变成跳转的方式了,其实,如果我们单纯的为了避免权重传递的话,常用的方法还有nofollow标签,只要给跳转的网址添加nofollow标签就可以避免权重了,哪种方法合适就看自己怎么使用了。

标签:

1 条留言  访客:1 条  博主:0 条

  1. 橙子VIP视频

    其实加上这个go跳转功能对站长有利,但是对于访客来说,也许会减少了互动性。nofollow标签就是个很好的选择

给我留言