:root{--puock-block-not-tran:100%}

替换git主题自带的go跳转

438次阅读
没有评论

共计 941 个字符,预计需要花费 3 分钟才能阅读完成。

今天来说说,本站使用的 git 主题,自带的 go 跳转 (go.html?url=),跳转过程中,不显示跳转的页面,而是直接跳转到目标页 (省去了中途的过程)。下面就来说说解决方法。
首先要关闭 git 主题自带的 go 跳转功能,在主题目录“functions.php”下添加下面这段代码 (如果你没有能力修改,请不要修改下面代码内的任何东西,以免造成不能使用的情况发生):

// 给外部链接加上跳转 by:www.qicaiyun.top
add_filter('the_content','the_content_nofollow',999);
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.php?url=$val\" ",$content);
            }
        }
    }
    return $content;
}

替换 git 主题自带的 go 跳转
文章下方有 go 跳转模板的下载地址,当然你也可以使用你自己的或者网上搜索其他的模板。上传到你网站的根目录,同样不要更改文件名,以免造成不能使用的情况发生。替换到这里就结束了,在去你带有外链的文章查看一下链接,如变成“http:// 你的域名 /go.php?url= 目标域名”则代表改造成功。反之失败,请确定你没有修改任何代码,
[fanctdl filename=’go.zip’ filesize=’4kb’ href=’https://www.qicaiyun.top/wp-content/uploads/2019/05/2019051910564294.zip’ filedown=’ 七彩云博客下载 ’][/fanctdl]

正文完
 0
评论(没有评论)