wordpress 后台添加菜单_WordPress教程

wordpress 后台添加菜单_WordPress教程

有时候我们给网站增加了一些功能,比如在线充值,那么需要在后台能看到用户的充值记录,所以需要添加一个后台菜单。 add_action('admin_menu', 'credit_logs_page'); function credit_logs_page() { add_menu_page('充值记录', '充值记录', 'm...

有时候我们给网站增加了一些功能,比如在线充值,那么需要在后台能看到用户的充值记录,所以需要添加一个后台菜单。

add_action('admin_menu', 'credit_logs_page');
 function credit_logs_page() {
 add_menu_page('充值记录', '充值记录', 'manage_options', 'CREDIT_LOGS', 'credit_logs');
 add_submenu_page( 'CREDIT_LOGS', '购买记录', '购买记录','manage_options', 'ORDER_LOGS', 'order_logs');
 add_submenu_page( 'CREDIT_LOGS', '后台充值', '后台充值','manage_options', 'CREDIT_ADD', 'credit_add');
 }

function credit_logs(){

global $wpdb; 
$total   = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->credits WHERE status=1"); 
$perpage = 20; 
$pages = ceil($total / $perpage); 
$page=isset($_GET['paged']) ?intval($_GET['paged']) :1; 
$offset = $perpage*($page-1); 
$orders=$wpdb->get_results("SELECT * FROM $wpdb->credits where status=1 order by create_date DESC limit $offset,$perpage");
?> 
<div class="wrap"> 
<h1 class="wp-heading-inline">充值记录</h1> 
<table class="wp-list-table widefat fixed posts">            
<thead>            
<tr>             
<th width="20%">用户ID</th>                
<th width="30%">充值金额</th>                
<th width="50%">充值时间</th>            
</tr>            
</thead>            
<tbody>            
<?php             
if($orders){            
foreach ($orders as $order) {            
echo "<tr>\n";                    
echo "<td>".get_user_by("id",$order->user_id)->user_login."</td>";                    
echo "<td>".$order->price." 元</td>";                    
echo "<td>".$order->create_date."</td>";            
}            
}            
?>            
</tbody> 
</table> 
<?php echo MBThemes_admin_pagenavi($total,$perpage);?> 
</div>

<?php}

原文链接:https://www.dqzy.cn/2025/05/06/523.html,转载请注明出处。 1、本站所有源码资源(包括源代码、软件、学习资料等)仅供研究学习以及参考等合法使用,请勿用于商业用途以及违法使用。如本站不慎侵犯您的版权请联系我们,我们将及时处理,并撤下相关内容! 2、访问本站的用户必须明白,本站对所提供下载的软件和程序代码不拥有任何权利,其版权归该软件和程序代码的合法拥有者所有,请用户在下载使用前必须详细阅读并遵守软件作者的“使用许可协议”,本站仅仅是一个学习交流的平台。 3、如下载的压缩包需要解压密码,若无特殊说明,那么文件的解压密码则为:www.dqzy.cn。 4、点启资源网是一个免费且专业分享网站源码、图片素材、特效代码、教程文章、站长工具的平台。我们努力给站长提供好的资源!
0

评论0

请先
显示验证码
没有账号?注册  忘记密码?