自定义wordpress仪表盘
来源:互联网 发布:大数据架构师指南 pdf 编辑:程序博客网 时间:2024/06/05 23:46
原网址:http://www.cnblogs.com/huangcong/p/3546636.html
WordPress作为一博客管理系统,相对来说已经相当简洁了,对用户也十分友好,新手也极易上手。
仪表盘是我们登陆WordPress后看到的后台界面,映入眼帘的是各种各样的信息,如WordPress China博客消息,及其他关于WordPress的RSS信息,这些无用的东西空空的耗费着我们内存。通过定制WordPress的管理后台,我们可以让WordPress更加简单实用,易于管理。简化后台界面,去除冗余信息和代码。
WordPress内置的hooks(包括filter和action)为我们定制WordPress后台提供了完美的解决方案。通过“勾入”而非修改WordPress的核心程序,可以在不影响安装文件完整性的情况下安全地作改动。
下面介绍的代码将全部在主题模板函数functions.php文件里修改。
去除控制台Widgets
//Remove dashboard widgetsfunction remove_dashboard_widgets(){ global $wp_meta_boxes; unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); }add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
增加控制台Widget
//Add dashboard widgetsif ( ! function_exists( 'add_dashboard_widgets' ) ) :function welcome_dashboard_widget_function() {echo "<ul><li><a href='post-new.php'>发布内容</a></li><li><a href='edit.php'>修改内容</a></li></ul>";}function add_dashboard_widgets() {wp_add_dashboard_widget('welcome_dashboard_widget', '常规任务', 'welcome_dashboard_widget_function');}add_action('wp_dashboard_setup', 'add_dashboard_widgets' );endif;
去除小工具Widgets
//Disable Standard Widgetsfunction remove_some_wp_widgets(){ unregister_widget('WP_Widget_Pages'); unregister_widget('WP_Widget_Calendar'); unregister_widget('WP_Widget_Archives'); unregister_widget('WP_Widget_Links'); unregister_widget('WP_Widget_Meta'); unregister_widget('WP_Widget_Search'); unregister_widget('WP_Widget_Text'); unregister_widget('WP_Widget_Categories'); unregister_widget('WP_Widget_Recent_Posts'); unregister_widget('WP_Widget_Recent_Comments'); unregister_widget('WP_Widget_RSS'); unregister_widget('WP_Widget_Tag_Cloud');}add_action('widgets_init',remove_some_wp_widgets', 1);
删除顶级菜单
//remove menusfunction remove_menus() { global $menu; $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins')); end ($menu); while (prev($menu)){ $value = explode(' ',$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);} }}if ( is_admin() ) { add_action('admin_menu', 'remove_menus');}
删除子菜单
//remove submenusfunction remove_submenus() { global $submenu; unset($submenu['index.php'][10]); // Removes 'Updates'. unset($submenu['themes.php'][5]); // Removes 'Themes'. unset($submenu['options-general.php'][15]); // Removes 'Writing'. unset($submenu['options-general.php'][25]); // Removes 'Discussion'. unset($submenu['edit.php'][16]); // Removes 'Tags'. }add_action('admin_menu', 'remove_submenus');
根据角色设定菜单可见性
//remove role menusfunction remove_menus() { global $menu; // 这里$restricted设置了评论和工具菜单 $restricted = array(__('Comments'), __('Tools')); end ($menu); while (prev($menu)){ $value = explode(' ',$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);} }}function remove_submenu() { remove_submenu_page( 'options-general.php', 'options-privacy.php' );}global $current_user;get_currentuserinfo();//如果当前用户的等级小于3,那么就删除对应的菜单if ($current_user->user_level < 3 && is_admin()) { add_action('admin_menu', 'remove_menus'); add_action('admin_init','remove_submenu');}
0 级对应 订阅者 1 级对应 投稿者 2 – 4 级对应 作者 5 – 7 级对应 编辑 8 – 10 级对应 管理员
修改后台LOGO图标
//custom admin logofunction custom_logo() { echo '<style type="text/css"> #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/admin_logo.png) !important; } </style>';}add_action('admin_head', 'custom_logo');
修改登录页面LOGO
//custom login logofunction custom_login_logo() { echo '<style type="text/css"> h1 a { background-image:url('.get_bloginfo('template_directory').'/images/login_logo.png) !important; } </style>';}add_action('login_head', 'custom_login_logo');
隐藏版本更新
//Hide the Upgrade Notice to Recent Versionsadd_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
修改页脚信息
//Customize the Footerfunction modify_footer_admin () { echo 'Created by <a href="http://wiinder.com">wiinder</a>.'; echo 'Powered by<a href="http://WordPress.org">WordPress</a>.';}add_filter('admin_footer_text', 'modify_footer_admin');
去除编辑页面媒体上传按钮
//remove all media buttonsadd_action('admin_init', 'remove_all_media_buttons');function remove_all_media_buttons(){ remove_all_actions('media_buttons');}
完整删除WP版本号
//完整的删除WordPress的版本号function wpbeginner_remove_version() {return '';}add_filter('the_generator', 'wpbeginner_remove_version');
隐藏帮助按钮和版本更新
//隐藏管理后台帮助按钮和版本更新提示function hide_help() {echo'<style type="text/css">#contextual-help-link-wrap { display: none !important; } .update-nag{ display: none !important; } #footer-left, #footer-upgrade{ display: none !important; }#wp-admin-bar-wp-logo{display: none !important;}.default-header img{width:400px;}</style>';}add_action('admin_head', 'hide_help');
去除header冗余代码
//去除header冗余代码remove_action('wp_head', 'feed_links_extra', 3);remove_action('wp_head', 'rsd_link');remove_action('wp_head', 'wlwmanifest_link');remove_action('wp_head', 'index_rel_link');remove_action('wp_head', 'start_post_rel_link', 10, 0);remove_action('wp_head', 'wp_generator');
0 0
- 自定义Wordpress的仪表盘
- 自定义wordpress仪表盘
- WordPress自定义仪表盘
- 定制化WordPress后台自定义仪表盘
- 自定义仪表盘
- 自定义仪表盘DashBoard - -kankanstyle
- 自定义之仪表盘
- 自定义仪表盘PaneView
- 自定义仪表盘控件
- Android自定义仪表盘视图
- Android自定义仪表盘
- Android自定义仪表盘
- 自定义仪表盘笔记
- 自定义汽车仪表盘
- Android 自定义仪表盘
- 时尚仪表盘 Android 自定义View
- Android自定义View之仪表盘
- 自定义View 汽车速度仪表盘
- js 手机端触发事事件、…
- Android Async异步操作实例---加载网络图片(慕课网笔记)
- Android 制作.9图
- R语言学习笔记4:股票杂谈
- 查找兄弟单词
- 自定义wordpress仪表盘
- 透明状态栏或沉浸式状态在MIUI系统下,更改系统状态栏字体颜色的方法
- 用单片机IO口直接驱动段式LCD的方法 用IO口驱动段式LED(数码管)的方法相信大家比较清楚,但用IO口直接驱动段式LCD的方法相对复杂一些。在网上搜了一下单片机IO口驱动段式LCD的方法,大
- eclipse中设置自动补全功能
- 撤销ViewPager-Fragments左右滑动页面功能
- ubuntu 15.10 nginx rtmp 搭建
- String.Format用法
- 【转载】毕业后的五年拉开大家差距的原因
- Ftp download