子比主题美化持续更新篇

1. go跳转美化

替换wp-content/themes/zibll/go.php,注意做好备份

<?php
if (
    strlen($_SERVER['REQUEST_URI']) > 384 ||
    strpos($_SERVER['REQUEST_URI'], 'eval(') ||
    strpos($_SERVER['REQUEST_URI'], 'base64')
) {
    @header('HTTP/1.1 414 Request-URI Too Long');
    @header('Status: 414 Request-URI Too Long');
    @header('Connection: Close');
    @exit;
}
@session_start();
$t_url = !empty($_SESSION['GOLINK']) ? $_SESSION['GOLINK'] : preg_replace('/^url=(.*)$/i', '$1', $_SERVER['QUERY_STRING']);
// 数据处理
if (!empty($t_url)) {
    // 判断是否为base64加密
    if ($t_url == base64_encode(base64_decode($t_url))) {
        $t_url = base64_decode($t_url);
    }
    // 防止xss
    // $t_url = htmlspecialchars($t_url, ENT_QUOTES, 'UTF-8');
    // $t_url = str_replace(array("'", '"'), array(''', '"'), $t_url);
    // $t_url = str_replace(array("\r", "\n", "\t", "\x0B", "\x0C", "\x0D"), '', $t_url);

    //防止xss
$t_url = htmlspecialchars($t_url, ENT_QUOTES, 'UTF-8');
$t_url = str_replace(array("\r", "\n"), array("\n", "\n"), $t_url);
$t_url = str_replace(array("\r", "\n"), array('
', '
'), $t_url);
$t_url = str_replace(array("\t"), array('  '), $t_url);
$t_url = str_replace(array("\x0B"), array(''), $t_url);
$t_url = str_replace(array("\x0C"), array(''), $t_url);
$t_url = str_replace(array("\x0D"), array('
'), $t_url);
    // 校验协议
    preg_match('/^(http|https|thunder|qqdl|ed2k|Flashget|qbrowser):\/\//i', $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://' . $_SERVER['HTTP_HOST'];
            $title = '参数错误,正在返回首页...';
        }
    }
} else {
    $title = '参数缺失,正在返回首页...';
    $url   = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
}
// 防止外站盗链
if (function_exists('zib_get_url_top_host')) {
    $host    = zib_get_url_top_host($_SERVER['HTTP_HOST']);
    $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    if (!empty($referer) && !preg_match('/' . preg_quote($host, '/') . '/i', $referer)) {
        $url   = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
        $title = '非法请求,正在返回首页...';
    }
}
// 验证nonce(防伪造)
if (function_exists('_pz') && _pz('go_link_nonce_s')) {
    $nonce = isset($_GET['nonce']) ? $_GET['nonce'] : '';
    if (empty($nonce) || !wp_verify_nonce($nonce, 'go_link_nonce')) {
        $url   = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
        $title = '非法请求,正在返回首页...';
    }
}
$url = str_replace(['&', '&'], '&', $url);
?>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="robots" content="noindex, nofollow" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?php if (function_exists('zib_head_favicon')) zib_head_favicon(); ?>
    <noscript><meta http-equiv="refresh" content="1;url='<?php echo $url; ?>';"></noscript>
    <title><?php echo $title; ?></title>
    <link rel="stylesheet" href="//cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css">
    <style>
        body,html{padding:0;margin:0}
        body{background:#f5f6f7;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif}
        a{cursor:pointer;text-decoration:none;word-wrap:break-word;word-break:break-all}
        .wiiuii-go-main{display:flex;width:100%;height:100vh;justify-content:center;align-items:center}
        .wiiuii-go-container{position:relative;max-width:28em;background:#fff;margin:10px;padding:1.5em;border-radius:8px;box-shadow:0 0 20px rgba(0,0,0,.08)}
        .wiiuii-go-content a{color:#036af4}
        .wiiuii-go-content a:hover{color:#e91e63}
        .wiiuii-go-logo{text-align:center;width:auto;height:65px;margin-bottom:10px}
        .wiiuii-go-logo img{max-width:100%;height:100%}
        .wiiuii-go-msg{text-align:center;padding:10px 5px;font-weight:700;color:rgba(255,0,0,0.85);background:rgba(255,0,0,0.1);border-radius:5px;margin-bottom:10px}
        .wiiuii-go-button-item{text-align:right;margin-top:10px}
        .wiiuii-go-button{display:inline-block;border-radius:99px;padding:10px 15px;background:rgba(116,116,116,.1);transition:all .3s;margin-left:5px}
        .wiiuii-go-button a{font-weight:700;font-size:14px;color:#333}
        .wiiuii-go-button:hover{background:rgba(116,116,116,.2)}
        .wiiuii-goid-item{position:absolute;top:10px;left:10px;border-radius:4px;overflow:hidden;background:#ffd07c;font-size:13px}
        .wiiuii-goid-title{padding:0 4px;background:#ffa400;color:#fff}
        .wiiuii-goid-text{padding:0 5px;color:#333}
        hr{border:0;height:1px;background:#eee;margin:15px 0}
    </style>
</head>
<body>
    <div class="wiiuii-go-main">
        <div class="wiiuii-go-container">
            <div class="wiiuii-goid-item">
                <b class="wiiuii-goid-title">GID</b>
                <span class="wiiuii-goid-text"><?php echo substr(md5($url), 0, 8); ?></span>
            </div>
            <div class="wiiuii-go-logo">
                <?php if (function_exists('zib_get_adaptive_theme_img')) echo zib_get_adaptive_theme_img(_pz('logo_src'), _pz('logo_src_dark')); ?>
            </div>
            <div class="wiiuii-go-content">
                <div class="wiiuii-go-msg">
                    <i class="fa fa-exclamation-triangle"></i>
                    您即将离开本站,请注意您的账号和财产安全。
                </div>
                <p>访问链接:<a onclick="location.replace('<?php echo $url; ?>')" title="<?php echo $url; ?>"><?php echo $url; ?></a></p>
            </div>
            <hr>
            <div class="wiiuii-go-button-item">
                <div class="wiiuii-go-button">
                    <a onclick="location.replace('//<?php echo $_SERVER['HTTP_HOST']; ?>')">返回首页</a>
                </div>
                <div class="wiiuii-go-button">
                    <a onclick="location.replace('<?php echo $url; ?>')">继续访问 <span style="font-weight:bold;color:red;" id="countdown"></span> 秒</a>
                </div>
            </div>
        </div>
    </div>
    <script>
        function link_jump() {
            location.href = "<?php echo $url; ?>";
        }
        // 倒计时跳转
        function startCountdown(duration, display) {
            var timer = duration;
            var countdown = setInterval(function () {
                display.textContent = timer;
                if (--timer < 0) {
                    clearInterval(countdown);
                    link_jump();
                }
            }, 1000);
        }
        window.onload = function () {
            var timeLeft = 5;
            var countdownDisplay = document.getElementById('countdown');
            startCountdown(timeLeft, countdownDisplay);
        };
        //延时15S关闭跳转页面,用于文件下载后不会关闭跳转页的问题
        setTimeout(function() {
            window.opener = null;
            window.close();
        }, 15000);
    </script>
</body>
</html>

2. 鼠标指针美化

自定义CSS样式

/*鼠标指针样式*/ 
body{cursor:url(https://www.0cv.com/wp-content/uploads/2025/09/normal1.png), default;}
a:hover{cursor:url(https://www.0cv.com/wp-content/uploads/2025/09/link1.png), pointer;}
/*鼠标指针样式*/ 

3.通过QQ邮箱/QQ号获取用户头像

前往该文件路径/wp-content/themes/zibll/inc/functions/zib-theme.php文件

图片[1]-子比主题美化持续更新篇-灵码CV

打开需要编辑的文件,找到zib_get_avatar方法,大概在文件570行左右,将以下代码替换进去即可

function zib_get_avatar($avatar, $id_or_email, $args)
{
$user_id = zib_get_user_id($id_or_email);
$alt = $user_id ? get_the_author_meta('nickname', $user_id) . '的头像' . zib_get_delimiter_blog_name() : '头像';

// 获取用户邮箱
$email = '';
if (!empty(get_the_author_meta('email', $user_id))) {
    $email = trim(strtolower(get_the_author_meta('email', $user_id)));
}

$size = esc_attr($args['size'] ?: 100); // 默认尺寸100

// 尝试从QQ邮箱提取QQ号获取头像
$avatar = '';
if (!empty($email)) {
    // 检查是否为QQ邮箱并提取QQ号
    if (preg_match('/^(\d+)@qq\.com$/', $email, $matches)) {
        $qq = $matches[1];
        // 验证QQ号格式(5-13位数字)
        if (strlen($qq) >= 5 && strlen($qq) <= 13 && ctype_digit($qq)) {
            // 修正QQ头像接口:使用更稳定的headimg_dl接口
            $valid_sizes = [40, 100, 140, 200]; // 官方支持的常见尺寸
            $selected_size = in_array($size, $valid_sizes) ? $size : 100; // 确保尺寸合法
            $avatar = "//q2.qlogo.cn/headimg_dl?dst_uin={$qq}&spec={$selected_size}";
        }
    }
}

// 如果没有获取到QQ头像,则使用Cravatar头像
if (empty($avatar)) {
    $s = $size;
    $d = 'mm'; // 默认头像样式
    $r = 'g';  // 头像评级
    $avatar = 'https://cravatar.com/avatar/' . md5($email) . "?s={$s}&d={$d}&r={$r}";
}

// 优化头像地址
$avatar = str_replace('tb.himg.baidu.com', 'himg.bdimg.com', $avatar);
$avatar = preg_replace("/^(https:|http:)/", "", $avatar);

    // 生成img标签
    return '<img alt="' . esc_attr($alt) . '" src="' . esc_url($avatar) . '" class="avatar' . ($args['size'] ? ' avatar-' . $args['size'] : '') . ' avatar-id-' . $user_id . '"' . ($args['size'] ? ' height="' . $args['size'] . '" width="' . $args['size'] . '"' : '') . '>'; 
}

4. 文章/帖子去掉更新时间改为发布时间

修改主题源代码

访问至以下路径  网站根目录/wp-content/themes/zibll/inc/functions/在此目录中找到zib-single.php文件并打开,打开文件后下滑至大约213行位置,找到如图所示 文章时间,全选中 如图中红框所示function {     开头直至   }  结束所有代码,并将下方代码粘贴覆盖,并保存。

图片[2]-子比主题美化持续更新篇-灵码CV
function zib_get_post_time_tooltip($post = null) 
{
    if (!is_object($post)) {
        $post = get_post($post);
    }

    $time = get_the_time('Y-m-d H:i:s', $post);

    // 仅显示发布时间,不显示更新时间和相关提示
    return '<span data-toggle="tooltip" data-placement="bottom" title="' . date('Y年m月d日 H:i', strtotime($time)) . '发布">' . zib_get_time_ago($time) . '发布</span>';
}

5.首页文章列表悬停上浮开始

自定义 CSS 代码:

/*首页文章列表悬停上浮开始*/
@media screen and (min-width: 980px){.tab-content .posts-item:not(article){transition: all 0.3s;}.tab-content .posts-item:not(article):hover{transform: translateY(-10px); box-shadow: 0 8px 10px rgba(255, 112, 173, 0.35);}}
/*首页文章列表悬停上浮结束*/

6.网站动态标题

我们经常逛别人的网站,有些网站当我们离开该页面浏览其他页面的时候,我们在离开的页面上面会看到比如本站的“你别走吖 Σ(っ °Д °;)っ”这样的字样,当我们点回来的时候页面上面会看到“(/≧▽≦/)你又回来了!”的字样。那么我们如何实现呢?其实很简单,只需一句 javascript 语句即可实现。请看下面的教程。

后台主题设置—>自定义代码—>自定义 javascript 代码把下面的代码添加到里面即可实现。

//网站动态标题开始 
var OriginTitile = document.title,
titleTime;
document.addEventListener("visibilitychange",
function() {
    if (document.hidden) {
        document.title = "你别走吖 Σ(っ °Д °;)っ";
        clearTimeout(titleTime)
    } else {
        document.title = "(/≧▽≦/)你又回来啦! " ;
        titleTime = setTimeout(function() {
            document.title = OriginTitile
        },
        2000)
    }
});
//网站动态标题结束

7.修改主题字体(网站字体美化)

1.首先下载自己喜欢的字体包 在这里我给大家推荐一款免费的字体下载站

100 字体下载站

2.转换字体包格式
当我们下载字体之后会有一个压缩包 里面会有一个.ttf 的字体文件包
因为有些浏览器不支持这种字体的格式显示 所以我们需要对字体格式转换
如果不进行转换字体格式,有些浏览器会无法显示自己设置的喜欢的字体 如果你毫无技术不会转换字体格式不要怕,这里提供一个免费快捷的字体转换网站

字体格式在线转换网站

你只需要转换.ttf 文件为 eot,woff,woff2,svg,tff 以上格式随便一种

3.网站调用字体

把你转换好的 5 个字体文件放在自己网站随便那个文件夹内,只需要记住地址就行

我放在自己的根目录下的-案例:https://www.0cv.com/xx.ttf

如果是 WordPress 子比主题的话直接把下面的 css 代码放在自定义 css 样式中

/*全站字体美化开始*/
@font-face{
font-family: 'moe';
src:  url('域名/xx.ttf');
}
body{
font-family:'moe';
}
.enlighter-default .enlighter{max-height:400px;overflow-y:auto !important;}.lazyloading:not(.swiper-lazy-loaded){opacity: 0;}@media (max-width:640px) {
    .meta-right .meta-view{
      display: unset !important;
    }
  }
/*全站字体美化开始*/

8.文章分页按钮美化

网站管理后台-–》子比主题设置—》自定义代码—》自定义 CSS 样式,把下面的 css 代码复制粘贴到里面即可。

/*文章分页按钮美化*/
.post-page-numbers{padding: 4px 10px;text-align:center;display: inline; }.post-nav-links{background:0;margin-left: -50px;}

9.在评论输入框中加入【快来说点什么吧!】背景样式

/*评论背景图*/
textarea#comment {background-color:transparent;background:linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05)),url(https://www.0cv.com/wp-content/uploads/2025/10/d439b6003af33a871f7e3f0e9b5c10385343b597.png) right 10px bottom 10px no-repeat;-moz-transition:ease-in-out 0.45s;-webkit-transition:ease-in-out 0.45s;-o-transition:ease-in-out 0.45s;-ms-transition:ease-in-out 0.45s;transition:ease-in-out 0.45s;}
textarea#comment:focus {background-position-y:789px;-moz-transition:ease-in-out 0.45s;-webkit-transition:ease-in-out 0.45s;-o-transition:ease-in-out 0.45s;-ms-transition:ease-in-out 0.45s;transition:ease-in-out 0.45s;}
/*评论背景图*/

10.网站底部的按钮美化教程

教程分为两步,添加 css 样式和添加 HTML 代码即可如下

1.子比主题设置—>自定义代码—>自定义 CSS 样式:,添加以下 CSS 代码:

/*CSS 代码网站底部按钮美化*/
:root{--theme-color:#f04494;--focus-shadow-color:rgba(240,68,148,.4);--mian-max-width:1200px;}.github-badge {
    display: inline-block;
    border-radius: 4px;
    text-shadow: none;
    font-size: 12px;
    color: #fff;
    line-height: 15px;
    margin-bottom: 5px;
}
.badge-subject {
    display: inline-block;
    background-color: #4d4d4d;
    padding: 4px 4px 4px 6px;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}
.github-badge .bg-blue {
    background-color: #007ec6;
}
.github-badge .bg-brightgreen {
    background-color: #4dc820;
}
.github-badge .bg-blueviolet {
    background-color: #8833d7;
}
.github-badge .badge-value {
    display: inline-block;
    padding: 4px 6px 4px 4px;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}
.github-badge .bg-orange {
    background-color: orange;
}
/*CSS 代码网站底部按钮美化结束 */

2、子比主题设置—>页面&显示—>底部页脚—>板块二,添加以下 HTML 代码:

<div class="github-badge">

  <span class="badge-subject bg-blue">
     <a style="color:#fff" href="https://www.0cv.com/xlj" target="_blank">友链申请</a>
  </span>-
  <span class="badge-subject bg-brightgreen">
     <a style="color:#fff" href="https://www.0cv.com/sitemap.xml" target="_blank">网站地图</a>
  </span>-
  <span class="badge-subject bg-orange">
     <a style="color:#fff" href="http://wpa.qq.com/msgrd?v=3&uin=xxx&site=qq&menu=yes" target="_blank">广告合作</a>
  </span>-
  <span class="badge-subject bg-green">
     <a style="color:#fff" href="https://www.0cv.com/yszc" target="_blank">隐私政策</a>
  </span>-  
<span class="badge-value bg-blueviolet">
     <a style="color:#fff" href="https://www.0cv.com/yhxy" target="_blank">用户协议</a>
  </span>

</div>
© 版权声明
THE END
喜欢就支持一下吧
点赞8
评论 抢沙发

请登录后发表评论

    暂无评论内容