返回列表 发布新帖
查看: 3|回复: 0

[代码技巧] 子比主题 – 用户中心增加我的投诉页面(三款)

[复制链接]
SunJu_FaceMall
社区贡献

226

主题

186

回帖

1万

积分

等级头衔
Icon组别 : 管理员
Icon等级 :

积分成就
   钻石 : 524 颗
   贡献 : 1030 点
   金币 : 5 枚
Icon在线时间 : 1280 小时
Icon注册时间 : 2024-11-22
Icon最后登录 : 2025-10-9

荣誉勋章

连签LV.1会员LV.1会员LV.2会员LV.3会员LV.4会员LV.5会员LV.6会员LV.7会员LV.8会员LV.9会员LV.10

风云·优秀版主

飞流名人堂成员

1

实名认证 手机认证 vip vip-year FLLTCN发表于 昨天 22:55 | 查看全部 |阅读模式 浙江金华

资源无需等待,交易就趁现在,全面资源整合网络大咖云集,让你轻松玩转互联网!

您需要 登录 才可以下载或查看,没有账号?立即注册

×
给子比用户中心加一个投诉的页面,这样就可以让很多用户可以看到自己投诉的用户什么时候能否处理好,之前就是在子比后台显示,那么让他前台也显示了一下,更美观,一共三款样式,话不多说直接开始!

第一款



tengfei_down (55).webp

第二款


tengfei_down (56).webp

第三款


tengfei_down (57).webp

代码部署



定位:/wp-content/themes/zibll/inc/functions/user/page.php文件,我们搜下面的函数
  1. function zib_user_ctnter_main_tabs_array_filter_main($tabs_array)
复制代码
然后在官方认证下面添加下面的代码!
  1.     $tabs_array['complaint'] = array(
  2.         'title'         => '我的投诉',
  3.         'nav_attr'      => 'drawer-title="我的投诉"',
  4.         'content_class' => 'complaint-settings',
  5.         'loader'        => '<div class="zib-widget">
  6.                                 <div class="placeholder k1 mb10"></div>
  7.                                 <div class="placeholder k1 mb10"></div>
  8.                                 <div class="placeholder s1"></div>
  9.                                 <div class="placeholder t1 mt20"></div>
  10.                                 <div class="placeholder s2"></div>
  11.                                 <div class="placeholder k1 mb10"></div>
  12.                                 <div class="placeholder k1 mb10"></div>
  13.                                 <div class="placeholder s1"></div>
  14.                                 <div class="placeholder t1 mt20"></div>
  15.                                 <div class="placeholder s2"></div>
  16.                             </div>',
  17.         'content_func'  => 'zib_main_user_tab_content_complaint', // 添加此行
  18.     );
复制代码
然后我们搜下面的函数
  1. function zib_user_center_page_sidebar_button_1($con)
复制代码
在官方认证下面添加下面的代码
  1.       $buttons[] = array(
  2.             'html' => '',
  3.             'icon' => '<svg t="1688968573785" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5245" width="200" height="200"><path d="M232.727273 117.410909m93.090909 0l372.363636 0q93.090909 0 93.090909 93.090909l0 512q0 93.090909-93.090909 93.090909l-372.363636 0q-93.090909 0-93.090909-93.090909l0-512q0-93.090909 93.090909-93.090909Z" fill="#B177ED" opacity=".8" p-id="5246"></path><path d="M337.454545 233.774545m23.272728 0l302.545454 0q23.272727 0 23.272728 23.272728l0 0q0 23.272727-23.272728 23.272727l-302.545454 0q-23.272727 0-23.272728-23.272727l0 0q0-23.272727 23.272728-23.272728Z" fill="#FFFFFF" p-id="5247"></path><path d="M337.454545 373.387636m23.272728 0l186.181818 0q23.272727 0 23.272727 23.272728l0 0q0 23.272727-23.272727 23.272727l-186.181818 0q-23.272727 0-23.272728-23.272727l0 0q0-23.272727 23.272728-23.272728Z" fill="#FFFFFF" p-id="5248"></path><path d="M814.568727 907.636364h-605.090909a93.090909 93.090909 0 0 1-93.090909-93.090909v-334.289455a93.090909 93.090909 0 0 1 130.653091-85.154909l227.397818 100.305454a93.090909 93.090909 0 0 0 75.147637 0l227.397818-100.305454a93.090909 93.090909 0 0 1 130.676363 85.154909v334.289455a93.090909 93.090909 0 0 1-93.090909 93.090909z" fill="#8D1DEF" opacity=".8" p-id="5249"></path></svg>',
  4.             'name' => '我的投诉',
  5.             'tab'  => 'complaint',
  6.         );
复制代码
接下来就是我们的页面样式了,如一开始的图片,选择你喜欢的样式,下面任意位置添加,我的投诉选项卡页面的代码,我这边是加到了如下图的地方,记住还是这个文件,别乱去其他文件
tengfei_down (58).webp
第一款代码
  1. // 我的投诉页面
  2. function zib_main_user_tab_content_complaint()
  3. {
  4.     $current_user_id = get_current_user_id();
  5.     $my_complaint_style = '<div style="margin-bottom: 10px;padding: 15px;color: #0986f5;background: #337ab71c;">加入网络监督员维护社区网络环境,举报不良信息,共建和谐绿色社区</div>';
  6.     $my_complaint_div ='style="background: #eeeeee57;padding: 15px;"';
  7.     global $wpdb;
  8.     $table_name = $wpdb->prefix . 'zib_message';
  9.     $query = $wpdb->prepare(
  10.         "SELECT * FROM $table_name WHERE send_user = %d AND type = %s",
  11.         $current_user_id,
  12.         'user_report'
  13.     );
  14.     $results = $wpdb->get_results($query);
  15.   
  16.   //如果查询记录为空则显示
  17.   if (empty($results)) {
  18.     $html = '<form class="zib-widget">' . $my_complaint_style . '<div ' . $my_complaint_div . '>您当前没有举报记录</div></form>';
  19.   } else {
  20.     $html = '<div>';
  21.     foreach ($results as $result) {
  22.       // 提取被举报用户到提交时间之间的文本
  23.       $start_pos = strpos($result->content, '被举报用户:');
  24.       $end_pos = strpos($result->content, '提交时间:');
  25.       $filtered_content = substr($result->content, $start_pos, $end_pos - $start_pos);
  26.       $html .= "<p $my_complaint_div>" . $filtered_content;
  27.       
  28.       // 提取提交时间中的数字部分
  29.       preg_match('/提交时间:(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/', $result->content, $matches);
  30.       if (isset($matches[1])) {
  31.         $submission_time = $matches[1];
  32.         $html .= '提交时间:' . $submission_time;
  33.       }
  34.       
  35.       $html .= '</p>';
  36.     }
  37.     $html .= '</div>';
  38.     $html = '<form class="zib-widget">' . $my_complaint_style . $html . '</form>';
  39.   }
  40.   return zib_get_ajax_ajaxpager_one_centent($html);
  41. }
  42. add_filter('main_user_tab_content_complaint', 'zib_main_user_tab_content_complaint');
复制代码

第二款代码
  1. // 我的投诉页面
  2. function zib_main_user_tab_content_complaint()
  3. {
  4.     $current_user_id = get_current_user_id();
  5.     $my_complaint_style = '<div style="margin-bottom: 10px;padding: 15px;color: #0986f5;background: #337ab71c;">加入网络监督员维护社区网络环境,举报不良信息,共建和谐绿色社区</div>';
  6.     $my_complaint_div ='style="background: #eeeeee57;padding: 15px;margin-bottom: 15px;"';
  7.     $my_complaint_time ='style="background: rgb(239, 243, 245);padding: 10px;color: #55798a;margin-bottom: auto;"';
  8.     global $wpdb;
  9.     $table_name = $wpdb->prefix . 'zib_message';
  10.     $query = $wpdb->prepare(
  11.         "SELECT * FROM $table_name WHERE send_user = %d AND type = %s ORDER BY status ASC, content ASC",
  12.         $current_user_id,
  13.         'user_report'
  14.     );
  15.     $results = $wpdb->get_results($query);
  16.     //如果查询记录为空则显示
  17.     if (empty($results)) {
  18.         $html = '<form class="zib-widget">' . $my_complaint_style . '<div ' . $my_complaint_div . '>您当前没有举报记录</div></form>';
  19.     } else {
  20.         $html = '<form class="zib-widget">' . $my_complaint_style;
  21.         foreach ($results as $result) {
  22.             // 提取提交举报的时间
  23.             preg_match('/提交时间:(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/', $result->content, $matches);
  24.             if (isset($matches[1])) {
  25.                 $submission_time = $matches[1];
  26.                 $html .= "<p $my_complaint_time>提交时间:$submission_time</p>";
  27.             }
  28.             // 提取被举报用户到提交时间之间举报信息
  29.             $start_pos = strpos($result->content, '被举报用户:');
  30.             $end_pos = strpos($result->content, '提交时间:');
  31.             $filtered_content = substr($result->content, $start_pos, $end_pos - $start_pos);
  32.             $filtered_content = str_replace('<br>', '<br class="complaint-br">', $filtered_content);
  33.             $html .= "<div $my_complaint_div>" . $filtered_content;
  34.             // 判断处理进度并添加相应的样式和文字
  35.             if ($result->status == 1) {
  36.                 // 处理完成
  37.                 $html .= '<div class="progress-bar">';
  38.                 $html .= '<div class="progress-bg progress-completed"></div>';
  39.                 $html .= '</div>';
  40.                 $html .= '<p style="margin-bottom: 5px;">投诉已经处理</p>';
  41.             } else {
  42.                 // 正在处理
  43.                 $html .= '<div class="progress-bar">';
  44.                 $html .= '<div class="progress-bg progress-processing"></div>';
  45.                 $html .= '</div>';
  46.                 $html .= '<p style="margin-bottom: 5px;">正在处理中...</p>';
  47.             }
  48.             $html .= '</div>';
  49.         }
  50.         $html .= '</form>';
  51.     }
  52.     return zib_get_ajax_ajaxpager_one_centent($html);
  53. }
  54. add_filter('main_user_tab_content_complaint', 'zib_main_user_tab_content_complaint');
  55. // 添加CSS样式
  56. function add_custom_styles() {
  57.     echo '
  58.     <style>
  59.     .progress-bar{
  60.       width: 100%;
  61.       height: 10px;
  62.       overflow: hidden;
  63.       box-sizing: border-box;
  64.       border-radius: 24px;
  65.       background-color: rgba(180, 160, 120, .2);
  66.       position: relative;
  67.     box-shadow: unset;
  68.     margin-bottom: 5px;
  69.     }
  70.     .progress-bg{
  71.       width: 10%;
  72.       height: 100%;
  73.       overflow: hidden;
  74.       box-sizing: border-box;
  75.       background-image: linear-gradient(135deg, #00BFFF 25%,#FA8072 0,#FA8072 50%,#00BFFF 0,#00BFFF 75%, #FA8072 0);
  76.       border-radius: 24px;
  77.       animation: panoramic 20s linear infinite;
  78.       background-size: 32px 100%;
  79.     }
  80.     @keyframes panoramic{
  81.       to {
  82.         background-position: 200% 0;
  83.       }
  84.     }
  85.     .progress-completed {
  86.       width: 100%;
  87.       background-image: linear-gradient(135deg, #4abd15bd 25%,#4abd15bd 0,#4abd15bd 50%,#4abd15bd 0,#4abd15bd 75%, #4abd15bd 0);
  88.       animation: none;
  89.     }
  90.     .progress-processing {
  91.       width: 50%;
  92.       background-image: linear-gradient(135deg, #ffe8a4 25%,#ffd353 0,#ffd353 50%,#ffe8a4 0,#ffe8a4 75%, #ffd353 0);
  93.       animation: none;
  94.     }
  95.    
  96.     .complaint-br {
  97.         display: block;
  98.         margin-bottom: 5px;
  99.     }
  100.     </style>
  101.     ';
  102. }
  103. add_action('wp_head', 'add_custom_styles');
复制代码

第三款代码
  1. // 我的投诉页面
  2. function zib_main_user_tab_content_complaint()
  3. {
  4.     $current_user_id = get_current_user_id();
  5.     $my_complaint_style = '<div style="margin-bottom: 10px;padding: 15px;color: #0986f5;background: #337ab71c;">加入网络监督员维护社区网络环境,举报不良信息,共建和谐绿色社区</div>';
  6.     $my_complaint_div ='style="background: #eeeeee57;padding: 15px;"';
  7.     $my_complaint_time ='style="background: rgba(255, 111, 6, 0.1);padding: 5px;color: #ff6c00;"';
  8.     global $wpdb;
  9.     $table_name = $wpdb->prefix . 'zib_message';
  10.     $query = $wpdb->prepare(
  11.         "SELECT * FROM $table_name WHERE send_user = %d AND type = %s ORDER BY status ASC, content ASC",
  12.         $current_user_id,
  13.         'user_report'
  14.     );
  15.     $results = $wpdb->get_results($query);
  16.     //如果查询记录为空则显示
  17.     if (empty($results)) {
  18.         $html = '<form class="zib-widget">' . $my_complaint_style . '<div ' . $my_complaint_div . '>您当前没有举报记录</div></form>';
  19.     } else {
  20.         $page = isset($_GET['page']) ? absint($_GET['page']) : 1; // 获取当前页数,默认为第一页
  21.         $per_page = 3; // 每页显示的举报信息数量
  22.         $total_items = count($results); // 总的举报信息数量
  23.         $total_pages = ceil($total_items / $per_page); // 计算总页数
  24.         // 确保当前页数不超过总页数
  25.         if ($page > $total_pages) {
  26.             $page = $total_pages;
  27.         }
  28.         // 计算起始索引和结束索引
  29.         $start_index = ($page - 1) * $per_page;
  30.         $end_index = min($start_index + $per_page, $total_items);
  31.         $html = '<div>';
  32.         for ($i = $start_index; $i < $end_index; $i++) {
  33.             $result = $results[$i];
  34.             // 提取提交举报的时间
  35.             preg_match('/提交时间:(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/', $result->content, $matches);
  36.             if (isset($matches[1])) {
  37.                 $submission_time = $matches[1];
  38.                 $html .= "<p $my_complaint_time>提交时间:$submission_time</p>";
  39.             }
  40.             // 提取被举报用户到提交时间之间举报信息
  41.             $start_pos = strpos($result->content, '被举报用户:');
  42.             $end_pos = strpos($result->content, '提交时间:');
  43.             $filtered_content = substr($result->content, $start_pos, $end_pos - $start_pos);
  44.             $html .= "<p $my_complaint_div>" . $filtered_content;
  45.             // 判断处理进度并添加相应的样式和文字
  46.             if ($result->status == 1) {
  47.                 // 处理完成
  48.                 $html .= '<span style="display: inline-block; width: 100%; height: 2px; background-color: #4abd15bd;"></span>';
  49.                 $html .= '<span style="color: #4abd15bd;">处理完成</span>';
  50.             } else {
  51.                 // 正在处理
  52.                 $html .= '<span style="display: inline-block; width: 50%; height: 2px; background-color: #ffe8a4;"></span>';
  53.                 $html .= '<span style="color: #ffd353;">正在处理</span>';
  54.             }
  55.             $html .= '</p>';
  56.         }
  57.         $html .= '</div>';
  58.         // 分页按钮
  59.         if ($total_pages > 1) {
  60.             $pagination_html = '<div style="margin-top: 10px;">';
  61.             $pagination_html .= '<span style="padding: 5px;">共 ' . $total_items . ' 条举报信息</span>';
  62.             if ($page > 1) {
  63.                 $prev_page = $page - 1;
  64.                 $pagination_html .= '<a href="?page=' . $prev_page . '" style="padding: 5px;margin-right: 5px;">上一页</a>';
  65.             }
  66.             if ($page < $total_pages) {
  67.                 $next_page = $page + 1;
  68.                 $pagination_html .= '<a href="?page=' . $next_page . '" style="padding: 5px;margin-right: 5px;">下一页</a>';
  69.             }
  70.             $pagination_html .= '</div>';
  71.             $html .= $pagination_html;
  72.         }
  73.         $html = '<form class="zib-widget">' . $my_complaint_style . $html . '</form>';
  74.     }
  75.     return zib_get_ajax_ajaxpager_one_centent($html);
  76. }
  77. add_filter('main_user_tab_content_complaint', 'zib_main_user_tab_content_complaint');
复制代码

路虽远,行则将至;事虽难,做则必成。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

飞流广播+ 发布

系统消息:柒沐已经连续答对10道难题,逆天学霸谁与争锋?!#每日答题#
10-09 09:07
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
09-24 09:00
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
09-11 11:40
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
09-02 09:17
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
08-27 08:56
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
08-20 15:12
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
08-03 10:22
系统消息:柒沐已经连续答对10道难题,逆天学霸谁与争锋?!#每日答题#
06-30 08:57
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
06-18 09:14
系统消息:清风网络已经连续答对10道难题,逆天学霸谁与争锋?!#每日答题#
04-11 09:40
系统消息:清风网络已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
04-10 09:31
系统消息:IXM77777已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
04-09 13:44
系统消息:清风网络已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
04-09 09:22
系统消息:柒沐已经连续答对10道难题,逆天学霸谁与争锋?!#每日答题#
04-09 08:52
系统消息:清风网络已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
04-08 09:24
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
04-07 09:02
系统消息:柒沐已经连续答对10道难题,逆天学霸谁与争锋?!#每日答题#
02-27 09:35
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
02-26 09:06
系统消息:柒沐已经连续答对3道难题,逆天学霸谁与争锋?!#每日答题#
02-25 08:49
系统消息:飞流安卓客户端APP已上线,请在QQ群(123129)群文件内获取下载。
02-21 02:22
站内通告

提供资源交易、信息共享、靓号交流、技术变现、学习问答、兴趣娱乐等全面服务。

1.丰富功能系统,扩展社区特色玩法,打造最好的互联网聚集圈子。

2.准确信息真实交易,安全快捷又方便,让虚拟交易面对面。

3. 天上不会掉馅饼,话术骗术迷人心,切勿脱离平台线下交易,被骗与平台无关!

4. 欺诈骗钱,违规违法将视情受到警告&禁言&封号甚至检举至👮🏻‍♀️处理!

官方Q群:123129钉推群:BAYR2383 站长QQ:3220000000

投诉/建议/商务合作联系

fl@fllt.cn

严禁私下交易,被骗与本站无关。
违反交易细则,取证立查严惩。
  • 钉钉新帖推送群
  • 官方交流QQ群
  • 站长唯一微信号

👮曝光Ta|🧿小黑屋|📴手机页|飞流网 ( 渝ICP备2025054677号-1|电信增值许可 渝B2-20250789 )|网站地图

GMT+8, 2025-10-9 13:41 , Processed in 0.090383 second(s), 59 queries, MemCached On , Gzip On.

Based on XJ-TX X3.5 Licensed

飞流论坛 HanAnalytics icp Astro vhAstro-Theme

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表