仪表盘的显示如下,如何禁用其中的仪表盘呢?
1.找到php文件: /wp-admin/includes/dashboard.php
2.在文件最后添加以下代码:
// 创建一个动作钩子函数function meetrice_remove_dashboard_widgets() { global $wp_meta_boxes;// unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);// unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_duoshuo']);// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);} // 在 'wp_dashboard_setup'动作中注册这个钩子函数add_action('wp_dashboard_setup', 'meetrice_remove_dashboard_widgets' );
3.如何确定仪表盘的名称及类型
$wp_meta_boxes['dashboard']['仪表盘类型']['core']['仪表盘名称']
使用开发者工具查看diy的ID,就是仪表盘的名称;
而它的容器div的ID为 xxx-sortables,其中xxx即它的类型
另外一种 移除仪表盘的方法:
修改用户的主题中的functions.php文件,在其中加入以下代码:
也可以根据用户的权限来称除
function user_role_dashboard(){ global $wp_meta_boxes, $current_user; // remove incoming links info for authors or editors if(in_array('author', $current_user->roles) || in_array('editor',$current_user->roles)) { unset($wp_meta_boxes['dashboard']['normal ']['core']['dashboard_incoming_links']); } // remove the plugins info and news feeds for everyone unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); }//add our function to the dashboard setup hookadd_action('wp_dashboard_setup', 'user_role_dashboard');