//获取下载按钮
function zibpay_get_post_down_buts($pay_mate, $paid_type = 'pay', $post_id = '')
{
if (empty($pay_mate['pay_download'])) {
return '<div class="muted-2-color text-center">暂无可下载资源</div>';
}
$down = zibpay_get_post_down_array($pay_mate);
$con = '';
$down_but = '';
if (!$post_id) {
global $post;
$post_id = $post->ID;
}
$down_url = zib_pay_get_download_url($post_id);
foreach ($down as $key => $down_v) {
$down_link = add_query_arg(array('down_id' => $key), $down_url);
$down_name = !empty($down_v['name']) ? $down_v['name'] : '本地下载';
$icon = '<i class="fa fa-download" aria-hidden="true"></i>';
$class = 'b-theme';
if (stripos($down_v['link'], 'weiyun') || stripos($down_v['link'], 'qq')) {
$class .= ' weiyun';
$down_name = $down_v['name'] ? $down_v['name'] : '腾讯微云';
$icon = zib_get_svg('weiyun', '0 0 1400 1024');
}
if (stripos($down_v['link'], 'baidu')) {
$class .= ' baidu';
$down_name = $down_v['name'] ? $down_v['name'] : '百度网盘';
$icon = zib_get_svg('pan_baidu');
}
if (stripos($down_v['link'], 'lanzou')) {
$down_name = $down_v['name'] ? $down_v['name'] : '蓝奏云';
$class .= ' lanzou';
$icon = zib_get_svg('lanzou');
}
if (stripos($down_v['link'], 'onedrive') || stripos($down_v['link'], 'sharepoint')) {
$down_name = $down_v['name'] ? $down_v['name'] : 'OneDrive';
$class .= ' onedrive';
$icon = zib_get_svg('onedrive');
}
if (stripos($down_v['link'], '.189.')) {
$down_name = $down_v['name'] ? $down_v['name'] : '天翼云';
$class .= ' tianyi';
$icon = zib_get_svg('tianyi');
}
if (stripos($down_v['link'], 'ctfile')) {
$down_name = $down_v['name'] ? $down_v['name'] : '城通网盘';
$class .= ' ctfile';
$icon = zib_get_svg('ctfile', '0 0 1260 1024');
}
$class = !empty($down_v['class']) ? $down_v['class'] : $class;
$icon = !empty($down_v['icon']) ? zib_get_cfs_icon($down_v['icon']) : $icon;
$copy_key = !empty($down_v['copy_key']) ? $down_v['copy_key'] : (!empty($down_v['copy_val']) ? '更多内容' : '');
$down_more = $down_v['more'] ? $down_v['more'] : $copy_key;
$down_more = $down_more ? '<span class="badg">' . $down_v['more'] . '</span>' : '';
if (!empty($down_v['copy_val'])) {
$down_more = '<a href="javascript:;" data-clipboard-tag="' . esc_attr($copy_key) . '" data-clipboard-text="' . esc_attr($down_v['copy_val']) . '" class="but">' . $down_v['more'] . '</a>';
}
$down_but .= '<div class="but-download flex ac"><a target="_blank" href="' . $down_link . '" class="mr10 but ' . $class . '">' . $icon . $down_name . '</a>' . $down_more . '</div>';
}
if (!$down_but) {
return '<div class="muted-2-color text-center">暂无可下载资源</div>';
}
$down_but = '<div class="flex ac hh">' . $down_but . '</div>';
//限制下载次数
$download_limit_html = '';
$user_id = get_current_user_id();
if ($user_id && stristr($paid_type, 'free')) {
//免费资源限制下载次数
$download_limit = 0;
$user_vip_level = zib_get_user_vip_level($user_id);
$user_down_number = zibpay_get_user_down_number($user_id);
if ($user_vip_level && _pz('pay_user_vip_' . $user_vip_level . '_s', true)) {
$download_limit = _pz('vip_benefit', 0, 'pay_download_limit_vip_' . $user_vip_level);
} else {
$download_limit = _pz('vip_benefit', 0, 'pay_download_limit');
}
if ($download_limit) {
$surplus = $download_limit - $user_down_number; //计算剩余下载次数
if ($surplus < 1) {
$down_but = '<div class=""><span class="badg c-red btn-block">您今日下载免费资源个数已超限,请明日再下载</span></div>';
} else {
$_text = $user_vip_level ? '您是尊贵的' . _pz('pay_user_vip_' . $user_vip_level . '_name') . ',' : '您';
$down_but = '<div class=""><span class="badg c-red btn-block">' . $_text . '今日还可下载' . $surplus . '个免费资源</span></div>' . $down_but;
}
}
$download_limit = _pz('vip_benefit', 0, 'pay_download_limit');
$download_limit_vip_1 = _pz('vip_benefit', 0, 'pay_download_limit_vip_1');
$download_limit_vip_2 = _pz('vip_benefit', 0, 'pay_download_limit_vip_2');
if ($download_limit || $download_limit_vip_1 || $download_limit_vip_2) {
$download_limit_html = '<div class="mb10" style=" padding: 10px 20px; background:var(--muted-border-color); border-radius: 4px; ">';
$download_limit_html .= '<div class="mb6">免费资源每日可下载:</div>';
$download_limit_html .= $download_limit ? '<div class="mb6">普通用户:' . ($download_limit ? $download_limit . '个' : '不限制') . '</div>' : '';
$download_limit_html .= $download_limit_vip_1 ? '<div class="mb6">' . _pz('pay_user_vip_1_name') . ':' . ($download_limit_vip_1 ? $download_limit_vip_1 . '个' : '不限制') . '</div>' : '';
$download_limit_html .= $download_limit_vip_2 ? '<div class="">' . _pz('pay_user_vip_2_name') . ':' . ($download_limit_vip_2 ? $download_limit_vip_2 . '个' : '不限制') . '</div>' : '';
$download_limit_html .= '</div>';
}
}
$con .= '<div>';
$con .= $download_limit_html;
$con .= $down_but;
$con .= '</div>';
return $con;
}
我想设置某个下载渠道只能是含一级以上的会员才能使用,代码怎么改,麻烦代码大佬们帮忙看下。