子主题开发之如何添加简单的美化功能[开发教程]


CSF::createSection( $prefix, array(
	'parent'      => 'custom',
	'title'       => '全局设置',
	'icon'        => 'fa fa-forumbee',
	'description' => '',
	'fields'      => array(
		array(
			'type'    => 'submessage',
			'style'   => 'warning',
			'content' => '<h3 style="color:#fd4c73;"><i class="fa fa-heart fa-fw"></i> 感谢您使用ZbApe子主题</h3>
                <p>ZbApe子主题是一款良心、厚道的好产品!创作不易,支持正版,从我做起!</p>
                <div style="margin:10px 14px;"><li>子主题官网:<a target="_bank" href="https://www.zbape.com/">https://zbape.com</a></li>
                <li>作者联系方式:<a target="_bank" href="http://wpa.qq.com/msgrd?v=3&uin=1660047787&site=qq&menu=yes">QQ 1660047787</a></li>
                </div>',
		),//第一个开关功能开始
		array(
			'title'   => '用户头像美化',
			'after'   => '头像彩色呼吸光环+悬停放大',
			'id'      => 'post',
			'default' => false,
			'type'    => 'switcher',
		),//第一个开关功能结束
	)
) );

以上代码就是一个单独的开关,大家写好开关之后就可以写相应的代码了

//css美化代码
function post(){ if (zbape_pz('post', false)) { ?>      
    <style>.posts-item{position: relative !important;}
        .new-icon{position: absolute;height: 35px;right: 0;top: 0;}
        .new-icon img{-webkit-user-drag: none;}</style>
<?php }}add_action('wp_footer', 'post');
//js美化代码
function comment_signin(){ if (zbape_pz('comment_signin', false)) { ?>
    <script>function a(a, b, c) {
            if (document.selection) a.focus(), sel = document.selection.createRange(), c ? sel.text = b + sel.text + c : sel.text = b, a.focus();
            else if (a.selectionStart || "0" == a.selectionStart) {
                var l = a.selectionStart,
                    m = a.selectionEnd,
                    n = m;
                c ? a.value = a.value.substring(0, l) + b + a.value.substring(l, m) + c + a.value.substring(m, a.value.length) : a.value = a.value.substring(0, l) + b + a.value.substring(m, a.value.length);
                c ? n += b.length + c.length : n += b.length - m + l;
                l == m && c && (n -= c.length);
                a.focus();
                a.selectionStart = n;
                a.selectionEnd = n
            } else a.value += b + c, a.focus()
        }
        var b = (new Date).toLocaleTimeString(),
            c = document.getElementById("comment") || 0;
        window.fancypig = {};
        window.fancypig.simple = {
            daka: function() {
                a(c, "滴!粉丝卡!打卡时间:" + b, ",请上车的乘客系好安全带~")
            },
            zan: function() {
                a(c, " 文章写得不错,给你点个赞,继续加油哈!")
            },
            cai: function() {
                a(c, "骚年,我怀疑你写了一篇假的文章!")
            }
        };</script>
<?php }}add_action('wp_footer', 'comment_signin');

大家按照以上代码更改即可,其中zbape_pz为子主题函数 后面的false为该id的默认值,add_action(‘wp_footer’, ‘post’)为将该函数即functions挂钩到wp底部(wp_footer为wp底部,wp_head为wp头部)一般的css或者js代码这样挂钩即可实现美化效果

© 版权声明
THE END
喜欢就支持一下吧
点赞10赞赏 分享
评论 共1条

请登录后发表评论

    请登录后查看评论内容