给子比用户主页/用户中心/评论区三个页面添加UID和靓号逻辑
单数字ID,AA~AAAAA ID、顺子ID增加靓号图标展示
原文链接:https://6ke.top/forum-post/788.html
演示
评论区
个人主页
用户中心
修改教程及代码
用户中心:/wp-content/themes/zibll/inc/functions/user/page.php
这段整个替换
function zib_user_page_header()
{
$user = wp_get_current_user();
$user_id = isset($user->ID) ? (int) $user->ID : 0;
$info_class = 'flex header-info relative hh';
$cover = get_user_cover_img($user_id);
$dropup_btn = '';
$avatar = zib_get_avatar_box($user_id, 'avatar-img', false, false);
$avatar = '<div class="hover-show relative">';
$avatar .= zib_get_avatar_box($user_id, 'avatar-img', false, false);
$avatar .= zib_get_user_avatar_set_link('absolute hover-show-con flex jc xx', '<i class="fa fa-camera mb6" aria-hidden="true"></i>修改头像') ?: ($user_id ? zib_get_user_home_link($user_id, 'absolute', '') : '');
$avatar .= '</div>';
$desc = '';
$btns = '';
if ($user_id) {
$dropup_btn = '<div class="abs-center right-bottom box-body cover-btns">' . zib_get_user_page_header_dropup_btn($user_id) . '</div>';
$name = '<span class="display-name">' . zibpay_get_vip_icon(zib_get_user_vip_level($user_id), 'mr3') . $user->display_name . zib_get_user_auth_badge($user_id, 'ml3') . zib_get_user_level_badge($user_id, 'ml3') . '</span>';
if (_pz('checkin_s')) {
$btns = zib_get_user_checkin_btn('but c-blue ml10 pw-1em radius', '<i class="fa fa-calendar-check-o"></i>签到', '<i class="fa fa-calendar-check-o"></i>已签到');
} else {
}
if (_pz('message_s')) {
$btns .= zibmsg_nav_radius_button($user_id, 'ml10');
}
$btns = '<div class="header-btns flex0 flex ac">' . $btns . '</div>';
// 判断用户 ID 是否为靓号
$is_lucky_id = false;
$numStr = strval($user_id);
//这里是判断靓号的正则表达式,如果没有覆盖你需要的规则靓号你可以自行添加规则
if (preg_match('/^([1-9])\1{0,}$|^([1-9]\d)\2{1,}$|^(?:123|234|345|456|567|678|789)\d{0,}$/', $numStr)) {
$is_lucky_id = true;
}
// 如果是靓号,则在 UID 前面添加一个 SVG 图标
if ($is_lucky_id) {
$desc = '<span class="but c-theme" data-toggle="tooltip" title="" data-clipboard-tag="UID" data-clipboard-text="' . $user_id . '" data-original-title="点击复制UID"><svg t="1724676985701" class="icon" viewBox="0 0 1109 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10521" style="width: 15px;height: 14px;"><path d="M42.666667 0m256 0l512 0q256 0 256 256l0 512q0 256-256 256l-512 0q-256 0-256-256l0-512q0-256 256-256Z" fill="#FF4200" p-id="10522"></path><path d="M219.050667 190.464h125.184v-51.456h69.888v51.456h119.04v59.136H414.122667v39.168h98.304v56.832H414.122667v39.936H546.986667v59.136H203.690667v-59.136h140.544V345.6H238.250667v-56.832h105.984v-39.168H219.050667v-59.136zM455.594667 844.8h-51.456l-17.664-64.512 48.384 3.84c9.216 0 14.592-7.68 14.592-23.04v-29.184H308.906667v114.432h-68.352V482.304h278.016v292.608c0 5.376-0.768 10.752-0.768 16.128 62.976-36.096 105.984-81.408 129.024-135.168 22.272-58.368 34.56-133.632 36.864-227.328V284.928h66.048v143.616c-1.536 62.976-7.68 118.272-16.896 166.656h48.384v151.296c0 16.896 5.376 25.344 16.128 25.344h27.648c6.912 0 12.15.2-10.752 11.52-26.88 17.664-48.384 17.664h-58.368c-41.472 0-61.44-24.576-61.44-73.728V657.408a507.733333 507.733333 0 0 1-17.664 45.312c-29.952 62.976-78.336 112.128-145.92 147.456l-36.096-56.832c-5.376 33.792-26.112 51.456-61.44 51.456zM308.906667 676.608h140.544v-40.704H308.906667v40.704z m0-96h140.544v-40.704H308.906667v40.704z m557.568-413.952v429.312h-69.12V232.704H636.842667v363.264h-67.584V166.656h297.216z" fill="#FFFFFF" p-id="10523"></path></svg>UID:' . $user_id . '</span>';
} else {
$desc = '<span class="but c-theme" data-toggle="tooltip" title="" data-clipboard-tag="UID" data-clipboard-text="' . $user_id . '" data-original-title="点击复制UID">UID:' . $user_id . '</span>';
}
$desc .= '<span class="but c-blue" data-toggle="tooltip" title="" data-clipboard-tag="用户名" data-clipboard-text="' . $user->user_login . '" data-original-title="点击复制用户名"><i class="fa fa-user-o"></i>' . $user->user_login . '</span>';
$desc .= $user->user_email ? '<span class="but c-yellow" data-toggle="tooltip" title="" data-clipboard-tag="邮箱" data-clipboard-text="' . $user->user_email . '" data-original-title="点击复制邮箱"><i class="fa fa-envelope-o"></i>' . $user->user_email . '</span>' : '';
$desc = apply_filters('user_page_header_desc', $desc, $user_id);
$info_html_flex1 = '<div class="flex1">';
$info_html_flex1 .= '<div class="em12 name">' . $name . '</div>';
$info_html_flex1 .= '<div class="desc user-identity flex ac hh">' . $desc . '</div>';
$info_html_flex1 .= '</div>';
} else {
$info_class .= ' signin-loader';
$info_html_flex1 = '<a href="javascript:;" class="display-name">Hi!请登录</a>';
}
$info_html = '<div class="' . $info_class . '">';
$info_html .= '<div class="flex0 header-avatar">';
$info_html .= $avatar;
$info_html .= '</div>';
$info_html .= $info_html_flex1;
$info_html .= $btns;
$info_html .= '</div>';
$html = '<div class="author-header mb20 radius8 main-shadow main-bg full-widget-sm">';
$html .= '<div class="page-cover">' . $cover . '<div class="absolute linear-mask"></div>' . $dropup_btn . '</div>';
$html .= '<div class="header-content">';
$html .= $info_html;
$html .= '</div>';
$html .= '</div>';
echo $html;
}
用户主页:/wp-content/themes/zibll/inc/functions/zib-author.php
这段整个替换
评论区:/wp-content/themes/zibll/inc/functions/zib-comments-list.php
这段整个替换
function zib_get_comments_user_name($comment)
{
if (!$comment) {
return;
}
$user_id = $comment->user_id;
$user_name = '';
if ($user_id) {
$user = get_userdata($user_id);
if (isset($user->display_name)) {
$display_name = $user->display_name;
$url = zib_get_user_home_url($user_id);
// 判断用户 ID 是否为靓号
$is_lucky_id = false;
$numStr = strval($user_id);
if (preg_match('/^([1-9])\1{0,}$|^([1-9]\d)\2{1,}$|^(?:123|234|345|456|567|678|789)\d{0,}$/', $numStr)) {
$is_lucky_id = true;
}
if ($is_lucky_id) {
// 如果是靓号,则在 UID 前面添加一个 SVG 图标
$user_name = '<a class="text-ellipsis font-bold" href="' . $url . '">' . $display_name .
'<span class="badg badg-sm c-blue moderator-bagd ml3 flex0"><svg t="1724676985701" class="icon" viewBox="0 0 1109 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10521" style="width: 15px;height: 14px;"><path d="M42.666667 0m256 0l512 0q256 0 256 256l0 512q0 256-256 256l-512 0q-256 0-256-256l0-512q0-256 256-256Z" fill="#FF4200" p-id="10522"></path><path d="M219.050667 190.464h125.184v-51.456h69.888v51.456h119.04v59.136H414.122667v39.168h98.304v56.832H414.122667v39.936H546.986667v59.136H203.690667v-59.136h140.544V345.6H238.250667v-56.832h105.984v-39.168H219.050667v-59.136zM455.594667 844.8h-51.456l-17.664-64.512 48.384 3.84c9.216 0 14.592-7.68 14.592-23.04v-29.184H308.906667v114.432h-68.352V482.304h278.h48.384v151.296c0 16.896 5.376 25.344 16.128 25.344h27.648c6.912 0 12.288-3.84 15.36-11.52 3.84-8.448 6.912-34.56 8.448-79.104l59.904 19.968c-4.608 64.512-13.056 102.912-23.808 115.2-10.752 11.52-26.88 17.664-48.384 17.664h-58.368c-41.472 0-61.44-24.576-61.44-73.728V657.408a507.733333 507.733333 0 0 1-17.664 45.312c-29.952 62.976-78.336 112.128-145.92 147.456l-36.096-56.832c-5.376 33.792-26.112 51.456-61.44 51.456zM308.906667 676.608h140.544v-40.704H308.906667v40.704z m0-96h140.544v-40.704H308.906667v40.704z m557.568-413.952v429.312h-69.12V232.704H636.842667v363.264h-67.584V166.656h297.216z" fill="#FFFFFF" p-id="10523"></path></svg> UID:' . $user_id . '</span></a>';
} else {
$user_name = '<a class="text-ellipsis font-bold" href="' . $url . '">' . $display_name .
'<span class="badg badg-sm c-blue moderator-bagd ml3 flex0"><i class="fa fa-id-card-o"></i> UID:' . $user_id . '</span></a>';
}
$user_name .= zib_get_user_auth_badge($user_id, 'ml3');
$user_name .= zib_get_medal_wear_icon($user_id, 'ml3');
$user_name .= zib_get_user_level_badge($user_id, 'ml3');
}
}
$user_name = $user_name ? $user_name : '<b class="mr6">' . $comment->comment_author . '</b>';
$badge = ''
if ($user_id && _pz('comment_author_tag', true)) {
$post = get_post($comment->comment_post_ID);
if ($user_id == $post->post_author) {
$badge .= '<span class="badg c-green badg-sm flex0 ml3">作者</span>';
}
}
$badge = apply_filters('comments_user_name_badge', $badge, $comment);
return '<name class="flex ac flex1">' . $topping_badge . $user_name . $badge . '</name>';
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
- 最新
- 最热
只看作者