声明非原创,在原创的基础上二开,找不到原帖了。
修复原版的接口失效,自建接口。
修复原版检测逻辑错误,原版是检测自己站点有没有对方的链接。
修复js报错问题。大大小小修复了原版的很多漏洞,具体可自行对比。
友链界面
演示地址可看:https://www.bfbke.com/link
路径:/wp-content/themes/zibll/pages/links.php
注意备份原文件,删除原代码将下方代码复制进去即可,自行修改图片地址
<?php
/**
* Template name: 子比美化版友情链接
* Description: sidebar page
*/
// 获取链接列表
function zib_page_links()
{
$type = 'card';
$post_ID = get_queried_object_id();
$args_orderby = get_post_meta($post_ID, 'page_links_orderby', true);
$args_order = get_post_meta($post_ID, 'page_links_order', true);
$args_limit = get_post_meta($post_ID, 'page_links_limit', true);
$args_category = get_post_meta($post_ID, 'page_links_category', true);
$args = array(
'orderby' => $args_orderby ? $args_orderby : 'name', //排序方式
'order' => $args_order ? $args_order : 'ASC', //升序还是降序
'limit' => $args_limit ? $args_limit : -1, //最多显示数量
'category' => $args_category, //以逗号分隔的类别ID列表
);
$links = get_bookmarks($args);
$html = '';
if ($links) {
$html .= zib_links_box($links, $type, false);
} elseif (is_super_admin()) {
$html = '<a class="author-minicard links-card radius8" href="' . admin_url('link-manager.php') . '" target="_blank">添加链接</a>';
} else {
$html = '<div class="author-minicard links-card radius8">暂无链接,请联系管理员添加</div>';
}
return $html;
}
get_header();
$post_id = get_queried_object_id();
$header_style = zib_get_page_header_style();
$page_links_content_s = get_post_meta($post_id, 'page_links_content_s', true);
$page_links_content_position = get_post_meta($post_id, 'page_links_content_position', true);
$page_links_submit_s = get_post_meta($post_id, 'page_links_submit_s', true);
?>
<style>
.admin-btn{background: #8486f8;padding: 2px 10px;color: #fff;border-radius: 4px;}
.admin-guanli{visibility:hidden;position: absolute;min-width: 80px;background-color: var(--main-bg-color);padding: 10px 5px;z-index: 99;border-radius: var(--main-radius);box-shadow: 0 0 10px rgba(0,0,0,.1);right: -40px;margin-top: -40px;}
.xy_hide:hover>.admin-guanli{visibility:unset;}
.xy_hide:hover>.admin-btn{color: #fff;background: #6d6fd8;}
.f12{font-size:12px;}
.xypro_describe {position: relative;border: 1px dashed #dcdfe6;line-height: 26px;}
.xypro_describe_title {position: absolute;top: 0;left: 8px;-webkit-transform: translateY(-50%);transform: translateY(-50%);background: #fff;padding: 0 5px;color: #303133;font-weight: 500;max-width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
.xypro_describe_content{color: #606266;padding: 18px 15px 30px;}
.yq{width: 100%;max-width: 100%;table-layout: fixed;color: #909399;margin-bottom: 18px;border-top: 1px solid #ebeef5;border-left: 1px solid #ebeef5;}
.yq thead th {font-weight: 500;background: #ebeef5;text-align: center;padding: 8px;border-bottom: 1px solid #ebeef5;border-right: 1px solid #ebeef5;}
.yq_link td {text-align: center;padding: 8px;border-bottom: 1px solid #ebeef5;border-right: 1px solid #ebeef5;text-overflow: ellipsis;
white-space: nowrap;overflow: hidden;}
.xy_li {text-align: center;font-size: 16px;line-height: 30px;}
.xy_li::marker {content: "#" counter(list-item) " ";color: var(--theme-color);}
.xy-mask {background-color: rgba(0,0,0,.5);}
.xy_height_hide{height: 300px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;}
.xy_height_hide_p{background: linear-gradient(180deg,hsla(0,0%,100%,0),#fff);width: 100%;z-index: 1;position: absolute;bottom: 0;margin: 0;height: 100px;}
.xy_height_hide_p2{text-align: center;bottom: 0;z-index: 2;position: absolute;left: 0;right: 0;cursor: pointer !important;}
.xy-more-btn{width: 20px;height: 20px;background-color: var(--main-bg-color);border: 1px solid rgb(237, 237, 237);border-radius: 50%;line-height: 18px;}
code{font-family: "lovely";}
.xy_callout ol li::marker {content: "#" counter(list-item) " ";color: var(--theme-color);}
.xy_callout {padding: 20px;border: 1px solid #e4e4e4;border-left-width: 5px;border-radius: 6px;line-height: 30px;font-weight: 600;border-left-color: var(--theme-color);}
.xy_content>h5{margin: 0;font-weight:600;font-size: 24px;line-height: 32px;padding:20px 0;text-align: center;}
.xy_checkbox:checked{background:var(--theme-color);-webkit-appearance: none;position: relative;border-radius: 2px;width: 15px;height: 15px;vertical-align: -2px;}
.xy_content h5:before {content: '「';color: var(--theme-color);font-weight: 600;margin-left: 5px;}
.xy_content h5:after {content: '」';color: var(--theme-color);font-weight: 600;margin-right: 5px;}
/**.xy_checkbox:checked:after {content:'';width: 6px;height: 10px;position: absolute;top: 1px;left: 5px;border: 2px solid #fff;border-top: 0;border-left: 0;-webkit-transform: rotate(45deg);transform: rotate(45deg);}**/
.wp-posts-content li{margin-bottom: 0;}
.xy-width{padding:0 30px 30px;}
.wp-posts-content ol>li>span{color: var(--theme-color);}
@media screen and (max-width:500px){.xy-width{padding:10px;}.wp-posts-content ol:not(.blocks-gallery-grid){margin:0;}.xy_hide{display:none;}.title-h-center{display:none;}.xy-mask {background-color: rgb(0 0 0 / 5%);}}
@media screen and (min-width:500px){.xy-width-190{width: 190px;}.xy-width-100{width: 100px;}}
</style>
<script>
//$.getJSON("https://api.qjqq.cn/api/Yi?c=f&encode=json",function(data){ $("#yulu").text(data.hitokoto);});$(function(){$("#yulu").click(function() {$(this).select();})})
</script>
<main class="container">
<div class="content-wrap">
<div class="content-layout">
<div class="page-cover theme-box radius8 main-shadow">
<img class="fit-cover no-scale lazyloaded" src="https://cos.vs98k.cn/uploads/2022/11/14/v2-4df3abc448cb4907a20ad8e35fd55f8e_r.jpg" data-src="https://cos.vs98k.cn/uploads/2022/11/14/v2-4df3abc448cb4907a20ad8e35fd55f8e_r.jpg">
<div class="absolute xy-mask"></div>
<div class="list-inline box-body abs-center text-center">
<div class="title-h-center">
<span class="xy_content"><h5><font size="6" color="red"> 注</font>意提醒 </h5>
<li class="xy_li">开启外链重定向会判定失败</li>
<li class="xy_li">网站打开时间过长会请求失败</li>
<li class="xy_li">首页未有本站链接会判定失败</li>
<li class="xy_li">如有疑问可找站长或进群</li>
</span>
</div>
</div>
</div>
<?php while (have_posts()) : the_post(); ?>
<?php echo zib_get_page_header(); ?>
<?php if ($page_links_content_position == 'top') {
echo '<div class="zib-widget">' . zib_page_links() . '</div>';
}?>
<?php echo Links(); ?>
<?php
if ($page_links_content_position != 'top') {
echo '<div class="zib-widget">' . zib_page_links() . '</div>';
}
echo'<div class="box-body notop">
<div class="title-theme">友链申请说明<small class="ml10">请注意查看</small></div>
</div>
<div class="zib-widget xy-width">
<span class="xy_content" style="display: block;">
<h5>申请前 <font size="6" color="red">必</font> 阅读</h5>
<section class="xy_callout wp-posts-content"
style="font-weight:400;padding:0 20px 10px;margin-bottom:15px;border-left-color: #1890ff;">
<h3>申请条件</h3>
<ol>
<li>先确认申请的博客内容符合以下类别,即使未列出的亦可继续申请。<br>
<i class="fa fa-check" aria-hidden="true"></i>
某领域技术性博客<br>
<i class="fa fa-check" aria-hidden="true"></i>
资源下载类博客<br>
<i class="fa fa-check" aria-hidden="true"></i>
论坛,社区或聚合媒体类网站<br>
<i class="fa fa-times" aria-hidden="true"></i>
纯视频站,纯图片站<br>
<i class="fa fa-times" aria-hidden="true"></i>
赌博、发卡、支付类网站<br>
<i class="fa fa-times" aria-hidden="true"></i>
原创少于1篇的博客<br>
<i class="fa fa-times" aria-hidden="true"></i>
没有独立博客服务器的博客(例如搭设在WordPress,blogger,typecho等)
</li>
<li>博客需每月至少有一篇更新博客,或者有经常更新的日常笔记,并且已存在至少<code>20篇</code>博文。</li>
<li>站点需要全站https,也不接受带ip或端口的链接,并且国内无墙。</li>
<li>在小站有效留言至少一条,至少我得熟悉你吧,这样才好申请友链。</li>
<li>博客有RSS2.0地址或atom地址(一般的博客程序都自带,请不要关闭,如果是自制程序没有可忽略)。</li>
<li style="color:red">权重大于3,以上条件皆可无视。</li>
</ol>
<h3>申请过程</h3>
<ol>
<li>申请前请先将本站友链加好。</li>
<li>申请信息真认真写好,请勿乱写。</li>
<li>申请时请写清<code>网站名称</code> <code>网站头像</code> <code>网站介绍</code> <code>网站链接</code></li>
</ol>
<h3>申请后续</h3>
<ol>
<li>如果不符合要求会无视掉申请,<font color="red">一天内都会通过。</font>
</li>
<li>网站修改友链信息请申请页面留言即可,无格式要求。</li>
<li>排名一般来说是有先后顺序的,但是还是要说,排名不分先后。</li>
<li>若发现站点无法访问,将会在一个月后删除。</li>
<li>网站正常访问但是无故下掉链接的,会拉入黑名单,不再接受友链申请。</li>
<li>本站使用
接口检测模式,
设有重定向、访问过慢的网站无法正常识别。</li>
</ol>
</section>
<div class="xy_callout"
<div style="">
<p><code>申请前请先将本站友链加好。</code></p>
<input type="checkbox" class="xy_checkbox" checked disabled>
名称:<span>毕方资源网</span><br> <input type="checkbox" class="xy_checkbox" checked disabled>
地址:<span>https://www.bfbke.com</span><br> <input type="checkbox" class="xy_checkbox" checked disabled>
介绍:<span>专注优质网络资源分享的技术博客</span><br> <input type="checkbox" class="xy_checkbox" checked disabled>
头像:<span>https://www.bfbke.com/favicon.ico</span>
</div>
</div>
</span>
</div>';
if ($page_links_content_s) {
echo '<div class="zib-widget"><article class="article wp-posts-content">';
the_content();
echo '</article>';
wp_link_pages(
array(
'before' => '<p class="text-center post-nav-links radius8 padding-6">',
'after' => '</p>',
)
);
echo '</div>';
}
if ($page_links_submit_s) {
$submit_args = array(
'title' => get_post_meta($post_id, 'page_links_submit_title', true),
'subtitle' => get_post_meta($post_id, 'page_links_submit_subtitle', true),
'dec' => get_post_meta($post_id, 'page_links_submit_dec', true)
);
echo zib_submit_links_card($submit_args);
}
?>
<?php ?>
<?php endwhile; ?>
<?php comments_template('/template/comments.php', true); ?>
</div>
</div>
<?php get_sidebar(); ?>
</main>
<?php
get_footer();?>
子比主题根目录
自行建立func.php
自己修改api地址:$url
api接口