欢迎您光临92源码网,秉承服务宗旨,履行"站长"责任,销售只是起点,服务永无止境!

Rizhiti-V2主题美化网站动态条(移植Ripro-v2)

作者 : 92源码网 本文共7565个字,预计阅读时间需要19分钟 发布时间: 2021-12-9 共714人阅读
注:未经许可的【搬运】和【账号共享】可能会被取消VIP【每个都会记录ip,多ip封禁账号】
本站所有资源来源于网络,分享目的仅供大家学习和交流!不得使用于非法商业用途,不得违反国家法律。否则后果自负! 本站提供的资源,都不包含技术服务请大家谅解!如有链接无法下载、失效或广告,请联系站长处理!

先看看效果图:

Rizhiti-V2主题美化教程:

1.打开“rizhuti-v2\inc\options\widget-options.php ”第三行(顶部)添加以下代码

抱歉,隐藏内容须成功后刷新可见!

2.打开“rizhuti-v2\inc\template-tags.php ” 第七行(顶部)添加以下函数代码

/**
	 * rizhuti-v2添加网站动态
	 * */
function rizhuti_v2_get_today_posts_count(){
	$today       = getdate();
	$query       = new WP_Query('year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"]);
	$postsNumber = $query->found_posts;
	return $postsNumber;
}

function rizhuti_v2_get_week_post_count(){
	$date_query = array(
		array(
			'after' => '1 week ago',
		),
	);
	$args = array(
		'post_type'        => 'post',
		'post_status'      => 'publish',
		'date_query'       => $date_query,
		'no_found_rows'    => true,
		'suppress_filters' => true,
		'fields'           => 'ids',
		'posts_per_page'   => -1,
	);
	$query = new WP_Query($args);
	return $query->post_count;
}


3.打开”rizhuti-v2\inc\goto.php”  第72行(或搜索 添加下载记录)添加以下代码

/*
	 * rizhuti-v2添加网站动态
	 * Author: MySQL研究院
	 * */
	if (!$is_today_down) {
		//发送消息到网站动态
		RiDynamic::add(array(
			'info' => sprintf( __('下载了%s', 'rizhuti-v2'),get_the_title( $down_post_id ) ),
			'uid' => $down_user_id,
			'href' => get_the_permalink( $down_post_id ),
			'time' => time(),
		));
	}


4.打开“rizhuti-v2\inc\template-filter.php”大约第636行,或搜索

update_user_meta($user->ID, ‘last_login_ip’,get_client_ip()) )

添加以下代码

/*
	 * rizhuti-v2添加网站动态
	 * */
	RiDynamic::add(array(
		'info' => sprintf(__('成功登录了本站%s', 'rizhuti-v2'),''),
		'uid' => $user->ID,
		'href' => '#',
		'time' => time(),
	));


5.打开“rizhuti-v2\inc\template-filter.php” 文件末尾添加以下代码

function dynamic_message_comment($comment_id, $comment_approved){

	if( 1 === $comment_approved ){
		$comment = get_comment($comment_id);
		//发送消息到网站动态
		RiDynamic::add(array(
			'info' => sprintf( __('评论了%s', 'rizhuti-v2'),get_the_title($comment->comment_post_ID) ),
			'uid' => $comment->user_id,
			'href' => get_the_permalink($comment->comment_post_ID),
			'time' => time(),
		));
	}

}

add_action( 'comment_post', 'dynamic_message_comment', 10, 2 );


6.打开“rizhuti-v2\inc\template-shop.php ” 文件末尾添加以下代码

/*
	 * rizhuti-v2添加网站动态
	 * */
class RiDynamic {

	public static $max_num       = 10; //最大缓存动态数量
	public static $expire_time   = 43200; //缓存时间秒 十二小时
	public static $transient_key = 'ripri_site_dynamic'; //data keyex

	public static function get($key = null) {

		$data = get_transient(self::$transient_key);

		$arr = maybe_unserialize($data); //解密数据

		if ($arr === false || empty($arr) || !is_array($arr)) {
			return array();
		} else {
			// rsort($arr); //序列数组 sort
			return $arr;
		}

	}

	public static function add($data = array()) {

		$arr = self::get();

		array_push($arr, $data);

		array_multisort(array_column($arr, 'time'), SORT_DESC, $arr);

		if (count($arr) > self::$max_num) {
			array_pop($arr);
		}

		$data_arr = maybe_serialize($arr); //格式化数据

		return set_transient(self::$transient_key, $data_arr, self::$expire_time);
	}

	public static function delete() {
		return delete_transient(self::$transient_key);
	}

}


7.打开“rizhuti-v2\inc\template-shop.php”大约第967,或搜索

$amount = sprintf(‘%0.2f’, $author_aff_info[‘author_aff_ratio’] * $order->order_price) )

添加以下代码

/*
	 * rizhuti-v2添加网站动态
	 * */
	    RiDynamic::add(array(
		    'info' => sprintf(__('通过推广链接获得佣金奖励:¥%s', 'rizhuti-v2'),$amount),
		    'uid' => $author_aff_info['aff_uid'],
		    'href' => get_user_page_url('aff'),
		    'time' => time(),
	    ));


8.打开“rizhuti-v2\inc\template-shop.php”  第958行(或者在 site_shop_pay_succ_callback 方法中)添加以下代码

/*
	 * rizhuti-v2添加网站动态
	 * */
    $order_info = maybe_unserialize($order->order_info);
    if (!empty($order_info['vip_day']) && $order_info['vip_day'] > 0) {
		//发送消息到网站动态
		RiDynamic::add(array(
			'info' => sprintf( __('使用%s成功开通了本站VIP会员', 'rizhuti-v2'),get_order_pay_type_text($order->pay_type) ),
			'uid' => $order->user_id,
			'href' => get_user_page_url('vip'),
			'time' => time(),
		));
	} else {
		RiDynamic::add(array(
			'info' => sprintf( __('成功购买了%s', 'rizhuti-v2'),get_the_title( $order->post_id ) ),
			'uid' => $order->user_id,
			'href' => get_the_permalink( $order->post_id ),
			'time' => time(),
		));
	}

注意:此处代码是将订单信息发送到网站动态,暂时只有开通会员以及资源购买

9.打开“rizhuti-v2\inc\admin\shop_index.php “大约第163行,或搜索

<div class=”layui-row layui-col-space15″>

在搜索到的第二个标签下,添加以下代码

<!-- rizhuti-v2添加网站动态  -->
                <div class="layui-col-md3">
                    <div class="layui-card">
                        <div class="layui-card-header">网站动态(十条)</div>
                        <div class="layui-card-body">
                            <dl class="layuiadmin-card-status">
				<?php
				    $result = RiDynamic::get();
				    foreach ($result as $key => $value) {
				        echo '<dd>';
					echo '<div class="layui-status-img"><a href="javascript:;"><img src="'.get_avatar_url($value['uid']).'"></a></div>';
					echo '<div>';
					if ($author_obj = get_user_by('ID', $value['uid'])) {
					    $u_name =$author_obj->user_login;
					}else{
					    $u_name = '游客';
					}
					echo '<p><strong>'.$u_name.'</strong> | <small>'.date('Y-m-d H:i:s',$value['time']).'</small></p>';
					echo '<span><a href="'.$value['href'].'">'.$value['info'].'</a></span>';
					echo '</div>';
					echo '</dd>';
				}?>
                            </dl>
                        </div>
                    </div>
                </div>


10.打开“rizhuti-v2\assets\css\app.css” 中添加以下代码

.rizhuti_v2-widget-dynamic .owl-dynamic {
    position: relative;
    padding: 10px 15px;
    border-radius: .5rem;
    padding-bottom: 5px;
}

.owl-dynamic .scroll-dynamic {
    height: 25px;
    line-height: 25px;
    overflow: hidden;
    display: inline-block;
    max-width: 70%;
}

.owl-dynamic .scroll-dynamic ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.owl-dynamic .scroll-dynamic ul li {
    height: 25px;
    padding-left: 0;
    line-height: 25px;
}


11.打开“rizhuti-v2\assets\js\app.js” 末尾添加以下代码

function AutoScroll(t) {
    $(t).find("ul:first").animate({
        marginTop: "-25px"
    }, 500, function () {
        $(this).css({
            marginTop: "0px"
        }).find("li:first").appendTo(this)
    })
}


12.执行完以上操作就可以在后台,外观小工具中看到网站动态条小工具啦,启用后需要刷新缓存,等一会就可以显示了!

本站声明:
1. 本站所有资源来源于网络,分享目的仅供大家学习和交流! 2. 不得使用于非法商业用途,不得违反国家法律。否则后果自负! 3. 本站提供的资源,都不包含技术服务请大家谅解! 4. 如有链接无法下载、失效或广告,请联系站长处理!

再次声明:如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


92源码网 » Rizhiti-V2主题美化网站动态条(移植Ripro-v2)

常见问题FAQ

本站下载资源解压密码是什么?
本站所有资源解压密码均为www.92luntan.com或者92luntan.com
免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
Copyright © 2018-2022 92源码资源网 - All rights reserved 浙ICP备14006446号-2
开通VIP 享更多特权,建议使用QQ登录