本文是《免费(共164篇)》专题的第 162 篇。阅读本文前,您可以先阅读前面的一些文章:
美化图:
该美化有用到jquery请自行引入,如您已经引入过则可以忽视
第一步:
在合适的位置插入以下HTML代码
<div id="rizhuti_v2_module_dynamic-5" class="section rizhuti_v2-widget-dynamic">
<div class="wrapper">
<div class="module owl-dynamic alert-primary">
<span class="d-none d-lg-block float-left">
<span class="badge badge-danger mr-2">
<i class="b2font b2-notification-3-line"></i>网站动态
</span>
</span>
<div class="scroll-dynamic" id="scroll-dynamic">
<ul style="margin-top: 0px;">
<?php
$arr=B2Danmu_allinfo_data($data);
foreach($arr as $row){
foreach($row as $cell){
echo '<li>'.$cell.'</li>';
}
}
;
?>
</ul>
</div>
<span class="float-right d-none d-lg-block">
<small class="mr-2">用户
<span class="badge badge-primary-lighten ml-1"><?php $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users"); echo $users; ?></span></small>
<small class="mr-2">文章
<span class="badge badge-primary-lighten ml-1"><?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?></span></small>
<small class="mr-2">评论
<span class="badge badge-primary-lighten ml-1"><?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?></span></small>
<small class="mr-2">建站
<span class="badge badge-primary-lighten ml-1"><?php echo floor((time()-strtotime("2023-11-01"))/86400); ?>天</span></small>
</span>
</div>
</div>
</div>
<script>
function autoscroll(obj){
$(obj).find("ul:first").animate({marginTop:"-25px"},1000,function(){
$(this).css("marginTop","0px").find("li:first").appendTo(this)
})
}
$(document).ready(function(){
setInterval('autoscroll("#scroll-dynamic")',1500)
})
</script>
第二步:
在自定义css中添加以下CSS代码
/*网站动态开始*/@media screen and (max-width: 768px){
.owl-dynamic .scroll-dynamic ul li {
width: 280px!important; /* 设置容器宽度 */ overflow: hidden; /* 当内容超出容器宽度时进行隐藏 */ white-space: nowrap; /* 不换行 */
}
.float-left,.float-right{
display:none!important;
}
.owl-dynamic .scroll-dynamic{
max-width:unset!important;
}
}
.mr-2, .mx-2 {
margin-right: 0.5rem!important;
}
.badge-danger {
color: #f46;
background-color: rgba(255, 68, 102, 0.15);
}
.badge {
display: inline-block;
padding: 0.2em 0.6em;
font-size: 75%;
font-weight: 700;
line-height: 2;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.25rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.float-left {
float: left;
}
.d-lg-block {
display: block;
}
#rizhuti_v2_module_dynamic-5{
margin-bottom:20px;
}
#rizhuti_v2_module_dynamic-5 .owl-dynamic {
color: #000;
background: #fff;
}
#rizhuti_v2_module_dynamic-5 .owl-dynamic {
position: relative;
padding: 10px 15px;
border-radius: 0.5rem;
}
.ml-1, .mx-1 {
margin-left: 0.25rem!important;
}
.spinner-grow-sm {
width: 1rem;
height: 1rem;
}
.spinner-grow {
display: inline-block;
width: 2rem;
height: 2rem;
vertical-align: text-bottom;
background-color: currentColor;
border-radius: 50%;
opacity: 0;
-webkit-animation: .75s linear infinite spinner-grow;
animation: .75s linear infinite spinner-grow;
}
.small, small {
font-size: 96%;
font-weight: 400;
color: #000;
line-height: 2;
}
sup {
top: -0.5em;
}
sub, sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
.spinner-border,
.spinner-grow {
-webkit-animation-duration: 1.5s;
animation-duration: 1.5s;
}
.owl-dynamic .scroll-dynamic {
height: 25px;
line-height: 25px;
overflow: hidden;
display: inline-block;
max-width: 64%;
}
.owl-dynamic .scroll-dynamic ul {
list-style: none;
padding: 0;
margin: 0;
}
.owl-dynamic .scroll-dynamic ul li {
font-size:16px;
font-weight: 600;
height: 25px;
padding-left: 0;
line-height: 30px;
white-space: nowrap; /* 防止换行 */ overflow: hidden; /* 超过部分隐藏 */ width:500px;
}
.owl-dynamic .scroll-dynamic ul li a{
color:#f46;
text-decoration:underline;
}
.dark-open a {
color: #fff;
}
.float-right {
float: right;
}
.d-lg-block {
display: block;
}
.mr-2, .mx-2 {
margin-right: 0.5rem!important;
}
.small, small {
font-size: 16px;
font-weight: 400;
color: #000;
line-height: 2;
}
small {
font-size: 80% !important;
}
.badge-primary-lighten {
color: #f46;
background-color: rgba(255, 68, 102, 0.15);
margin-bottom: 10px;
}
.ml-1, .mx-1 {
margin-left: 0.25rem!important;
}
.badge {
display: inline-block;
padding: 0.2em 0.6em;
font-size: 14px;
font-weight: 700;
line-height: 24px;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.25rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
/*网站动态结束*/
第三步:
在主题functions.php中添加以下代码
function B2Danmu_allinfo_data($data){
global $wpdb;
$table_name = $wpdb->prefix . 'zrz_order';
$all_select = $wpdb->get_results( "SELECT * FROM $table_name WHERE order_state='q' AND order_type<>'mission' ORDER BY id DESC LIMIT 20",ARRAY_A);
$data = array();
foreach($all_select as $key=>$v) {
//获得user_id的名字
$user_id_name = get_userdata($all_select[$key]['user_id']);
$user_id_name_true = isset($user_id_name->display_name) ? esc_attr($user_id_name->display_name) : '';
$user_id_link=get_author_posts_url($all_select[$key]['user_id']);
//获得msg_users的名字
$msg_users_name = isset($all_select[$key]['msg_users']);
//$msg_users_name_tian= trim($msg_users_name,"[]");
$msg_users_name_jun=preg_replace( '/[\W]/', '', $msg_users_name);
$msg_users_name_ya = get_userdata($msg_users_name_jun);
//获取用户名
$msg_users_name_true = isset($msg_users_name_ya->display_name) ? esc_attr($msg_users_name_ya->display_name) : '';
$msg_users_link=get_author_posts_url($msg_users_name_jun);
if($all_select[$key]['order_type']=='vip') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="/vips" target="_blank" class="info_zianv2">VIP会员</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'元<i></i>购买<i></i>'.$answer_user_page;
}
elseif($all_select[$key]['order_type']=='cg') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$answer=$user_id_name_true.'花了'.$all_select[$key]['order_price'].'元<i></i>购买积分';
}
elseif($all_select[$key]['order_type']=='circle_join') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$answer=$user_id_name_true.'花了'.$all_select[$key]['order_price'].'元<i></i>加入付费圈子';
}
elseif($all_select[$key]['order_type']=='ds') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'打赏<i></i>'.$answer_user_page.'<i></i>的作者<i></i>'.$msg_credit.'元';
}elseif($all_select[$key]['order_type']=='infomation_sticky') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer=$user_id_name_true.'花了'.$msg_credit.'元<i></i>置顶一则供求信息';
}
elseif($all_select[$key]['order_type']=='x'&& $all_select[$key]['pay_type']=='credit' ) {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'积分<i></i>购买文章<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='x'&& $all_select[$key]['pay_type']<>'credit' ) {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'元<i></i>购买文章<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='circle_hidden_content_pay'&& $all_select[$key]['pay_type']=='credit' ) {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'积分<i></i>查看帖子<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='circle_hidden_content_pay'&& $all_select[$key]['pay_type']<>'credit' ) {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'元<i></i>查看帖子<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='w'&& $all_select[$key]['pay_type']=='credit' ) {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'积分<i></i>购买隐藏文章<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='w'&& $all_select[$key]['pay_type']<>'credit' ) {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'元<i></i>购买隐藏文章<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='v'&& $all_select[$key]['pay_type']=='credit' ) {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'积分<i></i>购买视频<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='v'&& $all_select[$key]['pay_type']<>'credit' ) {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'元<i></i>购买视频<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='gx') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'元<i></i>购买商品<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='coupon') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$answer=$user_id_name_true.'使用优惠券购买商品';
}
elseif($all_select[$key]['order_type']=='d') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'积分<i></i>兑换商品<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='c') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer_user_page='<a href="'.get_permalink($all_select[$key]['post_id']).'" target="_blank" class="info_zianv">'.get_post($all_select[$key]['post_id'])->post_title.'</a>';
$answer=$user_id_name_true.'花了'.$msg_credit.'积分<i></i>抽奖商品<i></i>'.$answer_user_page.'<i></i>';
}
elseif($all_select[$key]['order_type']=='cz') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$answer=$user_id_name_true.'充值<i></i>'.$all_select[$key]['order_price'].'元<i></i>';
}elseif($all_select[$key]['order_type']=='verify') {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$msg_credit=$all_select[$key]['order_price'];
$answer=$user_id_name_true.'花了'.$msg_credit.'元<i></i>进行<i></i><a href="/verify" target="_blank" class="info_zianv2">高级认证</a>';
} else {
$avatar = get_avatar_url($all_select[$key]['user_id'],array('size'=>160));
$infeo_link=$user_id_link;
$answer='欢迎访问本站';
}
$answer_list = array(
'answer'=>$answer,
);
$data[] = $answer_list;
}
return $data;
}
function goldwho_files() {
wp_enqueue_script('goldwho_jquery_js',get_theme_file_uri('/pic/jquery-3.7.1.min.js'),array(),'1.0');
}
add_action('wp_enqueue_scripts','goldwho_files');
您已阅读完《免费(共164篇)》专题的第 162 篇。您可以继续阅读该专题下面的其它文章: