广告网站设计公司好吗,重庆在线app,自学考试 网页制作与网站建设06627,网站建设资讯站WordPress后台并非千篇一律#xff0c;你可以通过一些代码定制化一个你喜欢的后台#xff0c;本文所述代码都应写在主题的functions.PHP中。 移除后台某些菜单
如果你不想客户因为点了错误的菜单选项而删除付费主题#xff0c;或者搞乱后台的设置#xff0c;那么把你不希望…WordPress后台并非千篇一律你可以通过一些代码定制化一个你喜欢的后台本文所述代码都应写在主题的functions.PHP中。 移除后台某些菜单
如果你不想客户因为点了错误的菜单选项而删除付费主题或者搞乱后台的设置那么把你不希望他们看到的菜单隐藏吧。将你想移除的菜单天道$restricted数组中即可 1 2 3 4 5 6 7 8 9 10 function 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)]);} } } add_action(admin_menu, remove_menus);
更换登陆/注册页面的Logo 1 2 3 4 5 6 7 8 9 10 function my_custom_login_logo() { echo style typetext/css .login h1 a { background-image:url(.get_bloginfo(template_directory)./images/custom-login-logo.gif) !important; } /style ; } add_action(login_head, my_custom_login_logo);
更换Dashboard仪表盘的Logo 1 2 3 4 5 6 7 8 9 add_action(admin_head, my_custom_logo); function my_custom_logo() { echo style typetext/css #wp-admin-bar-wp-logo .ab-item .ab-icon { background-image: url(.get_bloginfo(template_directory)./images/custom-logo.gif) !important; } /style; }
删除“Please Upgrade Now”升级提示 1 2 3 4 5 6 7 8 9 10 11 # 2.3 to 2.7: add_action( init, create_function( $a, remove_action( init, wp_version_check ); ), 2 ); add_filter( pre_option_update_core, create_function( $a, return null; ) ); # 2.8 to 3.0: remove_action( wp_version_check, wp_version_check ); remove_action( admin_init, _maybe_update_core ); add_filter( pre_transient_update_core, create_function( $a, return null; ) ); # 3.0: add_filter( pre_site_transient_update_core, create_function( $a, return null; ) );
你也可以直接安装插件Disable WordPress Core Updates隐藏升级通知在某些时候很有用比如你要在低版本的wp上测试插件或者你不想让你的客户被升级通知困扰。
删除Dashboard的Widget
如果你不想整天读WordPress官方的新闻不想看见Dashboard到处是盒子用下面的代码移除。虽然WordPress的屏幕选项也能实现差不多的效果但从屏幕选项里去掉选择只不过是隐藏了这些widget东西都在只是你看不见罢了。用代码则可以禁止这些widget加载。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 function remove_dashboard_widgets() { global $wp_meta_boxes; unset($wp_meta_boxes[dashboard][side][core][dashboard_quick_press]); 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][normal][core][dashboard_plugins]); unset($wp_meta_boxes[dashboard][normal][core][dashboard_recent_drafts]); unset($wp_meta_boxes[dashboard][normal][core][dashboard_recent_comments]); unset($wp_meta_boxes[dashboard][side][core][dashboard_primary]); unset($wp_meta_boxes[dashboard][side][core][dashboard_secondary]); } add_action(wp_dashboard_setup, remove_dashboard_widgets );
创建自己的Dashboard Widget 1 2 3 4 5 6 7 8 9 10 11 function example_dashboard_widget_function() { // Display whatever it is you want to show echo Hello World, Im a great Dashboard Widget; } // Create the function use in the action hook function example_add_dashboard_widgets() { wp_add_dashboard_widget(example_dashboard_widget, Example Dashboard Widget, example_dashboard_widget_function); } // Hoook into the wp_dashboard_setup action to register our other functions add_action(wp_dashboard_setup, example_add_dashboard_widgets );
结束语
WordPress定制化很强你可以有一个琳琅满目的后台里面都是你需要和喜欢的东西也许你想要一个简单加载速度快的后台那么移除所有不需要的widget删除所有没用的插件、主题。自由度大不是累赘关键看如何使用。 https://blog.csdn.net/chaishen10000/article/details/71189303