给WordPress网站添加外链go跳转效果

哎呀,不废话了,之前的文章因为网站数据丢失,找不回了,直接去服务器拿一个过来用着保存吧,目前自己用的,可以拿去玩玩。

给WordPress网站添加外链go跳转效果
给WordPress网站添加外链go跳转效果
<?php 
$t_url = preg_replace('/^url=(.*)$/i','$1',$_SERVER["QUERY_STRING"]); 
if(!empty($t_url)) {
    preg_match('/(http|https):\/\//',$t_url,$matches);
	if($matches){
	    $url=$t_url;
	    $title='页面正在安全跳转中,请稍候';
	} else {
	    preg_match('/\./i',$t_url,$matche);
	    if($matche){
	        $url='https://'.$t_url;
	        $title='页面正在安全跳转中,请稍候';
	    } else {
	        $url='https://www.jxip.net/';
	        $title='参数错误,正在返回首页';
	    }
	}
} else {
    $title='参数缺失,正在返回首页';
    $url='https://www.jxip.net/';
}
?>


<!--修改此文件需要 review-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta http-equiv="refresh" content="1.5;url='<?php echo $url;?>';">
<title><?php echo $title;?></title>
<style>
/* Main styles */
@import url(https://fonts.lug.ustc.edu.cn/css?family=Open+Sans:800);
.text {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-dasharray: 70 330;
  stroke-dashoffset: 0;
  -webkit-animation: stroke 6s infinite linear;
  animation: stroke 6s infinite linear;
}
.text:nth-child(5n + 1) {
  stroke: #F2385A;
  -webkit-animation-delay: -1.2s;
  animation-delay: -1.2s;
}
.text:nth-child(5n + 2) {
  stroke: #F5A503;
  -webkit-animation-delay: -2.4s;
  animation-delay: -2.4s;
}
.text:nth-child(5n + 3) {
  stroke: #E9F1DF;
  -webkit-animation-delay: -3.6s;
  animation-delay: -3.6s;
}
.text:nth-child(5n + 4) {
  stroke: #56D9CD;
  -webkit-animation-delay: -4.8s;
  animation-delay: -4.8s;
}
.text:nth-child(5n + 5) {
  stroke: #3AA1BF;
  -webkit-animation-delay: -6s;
  animation-delay: -6s;
}

@-webkit-keyframes stroke {
  100% {
    stroke-dashoffset: -400;
  }
}
@keyframes stroke {
  100% {
    stroke-dashoffset: -400;
  }
}
/* Other styles */
html, body {
  height: 100%;
}

body {
  background: #111;
  background-size: .2em 50%;
  font: 5em/1 Open Sans, Impact;
  text-transform: uppercase;
  margin: 0;
}

svg {
  position: absolute;
  width: 100%;
  height: 100%;
}
</style>
</head>
<body>

<svg viewBox="0 0 600 300">
  <!-- Symbol-->
  <symbol id="s-text">
    <text text-anchor="middle" x="50%" y="50%" dy=".35em">Loading</text>
  </symbol>
  <!-- Duplicate symbols-->
  <use class="text" xlink:href="#s-text"></use>
  <use class="text" xlink:href="#s-text"></use>
  <use class="text" xlink:href="#s-text"></use>
  <use class="text" xlink:href="#s-text"></use>
  <use class="text" xlink:href="#s-text"></use>
</svg>
</html>

然后去主题目录下的function目录最底下添加:

/**
* WordPress外链新窗口打开并使用php页面go跳转

*/
function the_content_nofollow($content){
preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/',$content,$matches);
if($matches){
foreach($matches[2] as $val){
if(strpos($val,'://')!==false && strpos($val,home_url())===false && !preg_match('/\.(jpg|jepg|png|ico|bmp|gif|tiff)/i',$val)){
$content=str_replace("href=\"$val\"", "href=\"".home_url()."/go/?url=$val\" ",$content);
}
}
}
return $content;
}
add_filter('the_content','the_content_nofollow',999);
@版权声明: 本站所有文章,如左上角无特殊说明,则归类于图图网原创,其它版权归原作者所有,如若本站内容侵犯了您的合法权益,可联系我们进行处理。

给TA支持
共{{data.count}}人
人已支持
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧