文章源自狐狸影视城-https://fox-studio.net/29131.html
文章源自狐狸影视城-https://fox-studio.net/29131.html
历史介绍
知更鸟 Begin 付费主题 1.7.1 版本中加入了外链跳转的功能,提高访客的浏览体验。文章源自狐狸影视城-https://fox-studio.net/29131.html
外链加入有三个地方,从 Setting 文件中可以看到:文章源自狐狸影视城-https://fox-studio.net/29131.html
- 文章中外链跳转
- 评论者的外链跳转
- 下载按钮中的外链跳转
评论者的外链加入了下面的属性。搜索引擎不会用这个链接计算网站的 PR 值。文章源自狐狸影视城-https://fox-studio.net/29131.html
- rel='external nofollow'
当然你也可以适当考虑是否加入到其他两个地方。我建议还是默认的好。文章源自狐狸影视城-https://fox-studio.net/29131.html
文章源自狐狸影视城-https://fox-studio.net/29131.html
询问作者
最初时跳转不支持迅雷连接,点击后无法打开,这让我蛋疼许久。最新一版本的跳转却取消了对迅雷下载连接的支持,并且发现似乎 https 开头淘宝的超链接也没有了跳转。文章源自狐狸影视城-https://fox-studio.net/29131.html
询问过鸟哥后,得之代码来自张弋博客。遂留言于张弋博客,得到博主的完整源码。文章源自狐狸影视城-https://fox-studio.net/29131.html
具体过程不赘述,其代码原理我也不详,我不是做网站的,也请勿询问我相关专业问题。以下是源码和更改方法,适用于 Begin 1.7.1 版本文章源自狐狸影视城-https://fox-studio.net/29131.html
特别鸣谢:知更鸟;张弋文章源自狐狸影视城-https://fox-studio.net/29131.html
文章源自狐狸影视城-https://fox-studio.net/29131.html
修改方法
第一步,复制以下代码文章源自狐狸影视城-https://fox-studio.net/29131.html
- <?php
- $t_url = preg_replace('/^url=(.*)$/i','$1',$_SERVER["QUERY_STRING"]);
- if(!empty($t_url)) {
- preg_match('/(http|https|ftp|thunder):\/\//',$t_url,$matches);
- if($matches){
- $url=$t_url;
- $title='页面加载中, 请稍候...';
- } else {
- preg_match('/\./i',$t_url,$matche);
- if($matche){
- $url='http://'.$t_url;
- $title='页面加载中, 请稍候...';
- } else {
- $url='http://fox-studio.net/';
- $title='参数错误,正在返回首页...';
- }
- }
- } else {
- $title='参数缺失,正在返回首页...';
- $url='http://fox-studio.net/';
- }
- ?>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta http-equiv="refresh" content="1;url='<?php echo $url;?>';">
- <title><?php echo $title;?></title>
- <style>
- body{background:#000}.loading{-webkit-animation:fadein 2s;-moz-animation:fadein 2s;-o-animation:fadein 2s;animation:fadein 2s}@-moz-keyframes fadein{from{opacity:0}to{opacity:1}}@-webkit-keyframes fadein{from{opacity:0}to{opacity:1}}@-o-keyframes fadein{from{opacity:0}to{opacity:1}}@keyframes fadein{from{opacity:0}to{opacity:1}}.spinner-wrapper{position:absolute;top:0;left:0;z-index:300;height:100%;min-width:100%;min-height:100%;background:rgba(255,255,255,0.93)}.spinner-text{position:absolute;top:50%;left:50%;margin-left:-90px;margin-top: 2px;color:#BBB;letter-spacing:1px;font-weight:700;font-size:36px;font-family:Arial}.spinner{position:absolute;top:50%;left:50%;display:block;margin-left:-160px;width:1px;height:1px;border:25px solid rgba(100,100,100,0.2);-webkit-border-radius:50px;-moz-border-radius:50px;border-radius:50px;border-left-color:transparent;border-right-color:transparent;-webkit-animation:spin 1.5s infinite;-moz-animation:spin 1.5s infinite;animation:spin 1.5s infinite}@-webkit-keyframes spin{0%,100%{-webkit-transform:rotate(0deg) scale(1)}50%{-webkit-transform:rotate(720deg) scale(0.6)}}@-moz-keyframes spin{0%,100%{-moz-transform:rotate(0deg) scale(1)}50%{-moz-transform:rotate(720deg) scale(0.6)}}@-o-keyframes spin{0%,100%{-o-transform:rotate(0deg) scale(1)}50%{-o-transform:rotate(720deg) scale(0.6)}}@keyframes spin{0%,100%{transform:rotate(0deg) scale(1)}50%{transform:rotate(720deg) scale(0.6)}}
- </style>
- </head>
- <body>
- <div class="loading">
- <div class="spinner-wrapper">
- <span class="spinner-text"> 页面加载中, 请稍候...</span>
- <span class="spinner"></span>
- </div>
- </div>
- </body>
- </html>
替换其中 https://fox-studio.net/ 网址为你网站的地址。覆盖主题目录下的 begin/inc/go.html 文件。文章源自狐狸影视城-https://fox-studio.net/29131.html
文章源自狐狸影视城-https://fox-studio.net/29131.html
第二步,打开 begin/inc/core/setting.php 文件,查找以下内容 (在 //外链跳转 下) 约 959 行:文章源自狐狸影视城-https://fox-studio.net/29131.html
- function link_to_jump($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) && !preg_match('/(ed2k|thunder|Flashget|flashget|qqdl):\/\//i',$val)){
- $content=str_replace("href=\"$val\"", "href=\"".get_template_directory_uri()."/inc/go.php?url=$val\" ",$content);
- }
- }
- }
- return $content;
- }
替换为:文章源自狐狸影视城-https://fox-studio.net/29131.html
- function link_to_jump($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=\"".get_stylesheet_directory_uri()."/inc/go.php?url=$val\" ",$content);
- }
- }
- }
- return $content;
- }
只是删去了其中以下内容,我我也看不懂是啥意思。自己摸索的。文章源自狐狸影视城-https://fox-studio.net/29131.html
- && !preg_match('/(ed2k|thunder|Flashget|flashget|qqdl):\/\//i',$val)
我是在子主题中修改的这些文件。所以其中的文章源自狐狸影视城-https://fox-studio.net/29131.html
- get_template_directory_uri()
改成了文章源自狐狸影视城-https://fox-studio.net/29131.html
- get_stylesheet_directory_uri()
好了,现在去试试外链的跳转吧。效果如本站外链所示。文章源自狐狸影视城-https://fox-studio.net/29131.html
提供几个样例地址测试:文章源自狐狸影视城-https://fox-studio.net/29131.html
淘宝的 https 开头:https://item.taobao.com/item.htm?id=522217129671文章源自狐狸影视城-https://fox-studio.net/29131.html
迅雷 thunder 开头的:文章源自狐狸影视城-https://fox-studio.net/29131.html
thunder://QUFmdHA6Ly95Z2R5ODp5Z2R5OEB5MjAxLmR5Z29kLm9yZzo4MDM4L1vpmLPlhYnnlLXlvbF3d3cueWdkeTguY29tXS7nvo7lm73pmJ/plb8yLkJELjcyMHAu5Zu96Iux5Y+M6K+tLuS4reiLseWPjOWtl+W5lS5ta3ZaWg==文章源自狐狸影视城-https://fox-studio.net/29131.html
FTP 连接:ftp://ftp.pku.edu.cn/文章源自狐狸影视城-https://fox-studio.net/29131.html
百度网盘长链接:http://pan.baidu.com/share/link?shareid=3496202812&uk=2100613190文章源自狐狸影视城-https://fox-studio.net/29131.html
文章源自狐狸影视城-https://fox-studio.net/29131.html
关于子主题的创建请查阅:知更鸟 Begin 自定义子主题修正缩略图文章源自狐狸影视城-https://fox-studio.net/29131.html

2016 年 6 月 6 日 下午 5:19 2F
狐哥,其他的主题可以实现吗?我用的是鸟哥的 「响应式主题:Ality
2016 年 6 月 6 日 下午 5:45 B1
@ 司文雨轩 可以,如果你看的懂
2015 年 10 月 11 日 上午 10:52 1F
狐哥,第一段代码第三行错误了,有两个词重复了 【if(!emptyempty($t_url)) {】,我试了好几次终于解决了,谢谢啊
2015 年 10 月 13 日 上午 12:46 B1
@ 醉兔 感谢提醒,已修复。源代码都没有错误,可能是复制时候搞错了吧。
来自外部的引用: 1