文章目录
本文最后更新于 2022-10-14,已超过 365 天未更新,内容可能已失效。

直接上教程

第一步:

添加JS代码,新建一个js文件,在footer引入即可。或者直接把下面的代码添加到footer.PHP文件里,注意用<script></script>包裹下

[rihide]

jQuery(function (){
    var text;
            var now = (new Date()).getHours();
            if (now > 24 || now <= 5) {
                text = '温馨提示您 午夜骚年,快睡觉去,妹纸等你太久了会不耐烦的哦!';
            } else if (now > 5 && now <= 10) {
                text = '早上好~今天又是元气满满的一天哦!今天又更新了,<a href="/" style="color:#0099e5;" target="_blank">先去尝尝鲜</a>~';
            } else if (now > 10 && now <= 12) {
                text = '最难的任务适合在上午时段攻克哦,期待您的订单~';
            } else if (now > 12 && now <= 14) {
                text = '中午拿什么填补我空虚的胃和心灵?<br />停下手中的工作,快去吃饭吧,晚了就没的吃了';
            } else if (now > 14 && now <= 17) {
                text = '下午时段我们正在优化细节,力求做一个人见人爱的“细节控”哦~';
            } else if (now > 17 && now <= 19) {
                text = '快要下班了吧?休息会扒根烟喝杯茶~';
            } else if (now > 19 && now <= 21) {
                text = '晚安~音乐、运动、阅读,睡前时间放松一下,灵感也许会悄悄到来!';
            }else if (now > 21 && now <= 24) {
                text = '累了就早点休息~<br />晚间22:00-5:00是最佳睡眠时间哦';
            }
        showMessage(text, 12000);
})();


function showMessage(text, timeout){
    if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1];
    //console.log('showMessage', text);
    $('.message').stop();
    if(text != undefined){
        $('.message').html(text).fadeTo(200, 1);
    }
    if (timeout === null) timeout = 6000;
    hideMessage(timeout);
}
function hideMessage(timeout){
    $('.message').stop().css('opacity',1);
    if (timeout === null) timeout = 6000;
    $('.message').delay(timeout).fadeTo(200, 0);
}

[/rihide]

第二步:

添加CSS代码,ripro主题如diy.css或者后台顶部设置自定义CSS添加如下代码

/*****/
#landlord {
	user-select: none;
	position: fixed;
	left: 30px;
	bottom: 150px;
	z-index: 10000;
	font-size: 0;
	transition: all .3s ease-in-out
}

#landlord .landlord-close {
	opacity: 0;
	visibility: hidden;
	width: 20px;
	height: 20px;
	line-height: 20px;
	background: rgba(0,0,0,.2);
	text-align: center;
	color: #fff;
	position: absolute;
	top: 3px;
	right: 0;
	border-radius: 50%;
	font-size: 10px;
	cursor: pointer;
	z-index: 1;
	transition: .2s
}

#landlord .message {
	opacity: 0;
	width: 172px;
	height: auto;
	margin: auto;
	padding: 7px;
	top: -50px;
	left: -20px;
	text-align: center;
	color: #666;
	border-radius: 12px;
	background-color: #f5f5f5;
	box-shadow: 0 3px 15px 2px #eae6e6;
	font-size: 13px;
	font-weight: 400;
	text-overflow: ellipsis;
	text-transform: uppercase;
	overflow: hidden;
	position: absolute
}

 

第三步:

添加php代码,footer.php添加以下代码

[rihide]

<div id="landlord" style="display: block;">
    <span class="landlord-close iconfont icon-guanbi" onclick="$('#landlord').hide();$('#flost-landlord').show();"></span>
    <div class="message" style="opacity: 1;">喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡</div>
</div>

[/rihide]

最后可以添加一个手机端、首页判断

不在手机端显示

!wp_is_mobile()

 

只在首页显示

is_home()

 

CC 许可协议
署名-非商业性使用-相同方式共享 4.0 国际 了解协议
文章链接:https://zptheme.com/3370.html
本文作者:子佩·来源:子佩工作室

除非注明,子佩工作室 文章均为原创,转载请以链接形式标明本文地址。

相关推荐

登录后即可发表评论

社交账号登录

全部评论 (1)

  • 我们的梦想只能看着明天的太阳,路很长,我们只有望向远方。

    3 年前