Puock – 适合我喜好的美化合集!

1,857次阅读
没有评论

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

Puock修改记录 – 适合我喜好的美化合集,不定期更新!


1、主题导航新标签打开

wordpress-theme-puock/inc/fun/core.php - 731行增加并修改。
        if($menu->target == "_blank"){
            $menu_blank = "target='_blank'";
        }else{
            $menu_blank = '';
        }
        if (!$mobile) {
            $out .= "<a class='ww' data-color='auto' {$target} href='{$menu->url}' $menu_blank>{$menu->title}";
        } else {
            $out .= '<span><a ' . $target . ' href="' . $menu->url . '" '.$menu_blank.'>' . $menu->title . '</a>';
        }

2、消息提示延长至4秒。

wordpress-theme-puock/assets/dist/js/puock.min.js - 第1161行
duration: 4000,

3、点赞成功、失败、重复等通知

wordpress-theme-puock/assets/dist/js/puock.min.js - 第959行。

建议整个替换

 {
        key: "eventSendPostLike",
        value: function() {
            var a = this;
            $(document).on("click", "#post-like", function(t) {
                var e = $(a.ct(t))
                  , t = e.attr("data-id");
                $.post("/wp-admin/admin-ajax.php", {
                    action: "puock_like",
                    um_id: t,
                    um_action: "like"
                }, function(res) {
                    if (res.e === 0) {
                        e.find("span").html(res.d);
                        e.addClass("bg-primary text-light");
                        a.toast("点赞成功");
                    } else {
                    a.toast(res.t, TYPE_DANGER);
                    }
                }, "json").fail(function() {
                    a.toast("点赞异常", TYPE_DANGER);
                })
            })
        }
    },

4、VIP权限可见

《WP主题增加其他权限可见功能的简单办法》


5、用户中心改头像

《WordPress用户中心修改用户头像简单教程!》


6、非插件相册

《WordPress不用插件如何展示图片,使用相册功能!》


7、主题字体

管理后台的“外观->自定义->额外css”中设置。

/* 设置网站字体 */
@font-face{
font-family:btfFont;
src: url(https://资源链接地址) format('woff2')
}
body{font-family:"btfFont" !important}

免费商用字体 点击下载免费字体 免费商用字体下载网站,再通过 CloudConvert 将字体资源转换成 woff2 格式,存放到网址任意位置即可,但要确保该文件能被正常访问。


8、随机图片功能

改功能需要使用子域名或其他域名,新建网址。

可以通过https://source.ailcc.com/?nighthttps://source.ailcc.com/?lighthttps://source.ailcc.com/来访问三个文件夹下面的图片。

<?php
// 图片文件夹路径
$imageFolder = 'img/';
// 获取查询参数
$category = isset($_GET['light']) ? 'light' : (isset($_GET['night']) ? 'night' : '');
// 根据查询参数选择图片文件夹
switch ($category) {
    case 'light':
        $imageFolder .= 'light/';
        break;
    case 'night':
        $imageFolder .= 'night/';
        break;
    default:
        $imageFolder .= 'default/';
}
// 扫描图片文件夹
$images = glob($imageFolder . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
if (empty($images)) {
    // 如果文件夹中没有图片,则返回 404 错误
    header("HTTP/1.0 404 Not Found");
    exit;
}
// 随机选择一张图片
$randomImage = $images[array_rand($images)];
// 将页面重定向到随机图片地址
header("Location: $randomImage");
exit;
?>

9、简单的评论拦截

《IP黑名单拦截评论插件!》


10、固定轮播图尺寸

新增css或者修改原有高度。

wordpress-theme-puock/assets/dist/style/style.min.css - 第1186行增加
.swiper img {
    height:350px !important;
}

11、发布文章时随机阅读和点赞

PS:Puock定制功能,其他主题也可能有点赞功能,所以记得更换自定义字段名称。

function add_custom_fields_on_publish($post_id, $post) {
    // 检查是否为发布文章的操作
    if (isset($_POST['original_publish']) && $_POST['original_publish'] == '发布') {
        // 检查是否已经存在字段值
        $views = get_post_meta($post_id, 'views', true);
        $puock_like = get_post_meta($post_id, 'puock_like', true);

        // 如果字段值不存在,则生成并保存
        if (empty($views)) {
            update_post_meta($post_id, 'views', mt_rand(395, 2000));
        }

        if (empty($puock_like)) {
            update_post_meta($post_id, 'puock_like', mt_rand(5, 20));
        }
    }
}
add_action('save_post', 'add_custom_fields_on_publish', 10, 2);
mp_wx_9dc2a13583

共计16人点赞,其中1人来自小程序

正文完
微信扫码打开小程序体验更多功能
post-qrcode
 16
沛霖主页
版权声明:本站原创文章,由 沛霖主页 2023-03-18发表,共计2942字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)