1,常用主題函數
//移除后台默认小控件 add_action('wp_before_admin_bar_render', 'my_admin_bar_remove', 0); function my_admin_bar_remove() { global $wp_admin_bar; global $wp_meta_boxes; /* Remove their stuff */ $wp_admin_bar->remove_menu('wp-logo'); // 以下这一行代码将删除 "快速发布" 模块 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_plugins']); // 以下这一行代码将删除 "近期评论" 模块 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); // 以下这一行代码将删除 "近期草稿" 模块 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); // 以下这一行代码将删除 "WordPress 开发日志" 模块 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); // 以下这一行代码将删除 "其它 WordPress 新闻" 模块 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); // 以下这一行代码将删除 "概况" 模块 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); // 以下这一行代码将删除 "活动" 模块 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']); } // 添加后台小控件 add_action('wp_dashboard_setup', 'my_add_dashboard_widgets'); function my_add_dashboard_widgets() { wp_add_dashboard_widget('my_dashboard_widget', // Widget slug. 'welcome', // Title. 'dashboard_widget_function') // Display function. ; } //Create the function to output the contents of our Dashboard Widget. function dashboard_widget_function() { echo "欢迎!<br/>请点击左侧菜单进行相应操作。"; } // 去除后台标题中的“—— WordPress” add_filter('admin_title', 'wpdx_custom_admin_title', 10, 2); function wpdx_custom_admin_title($admin_title, $title) { return $title . ' ‹ ' . get_bloginfo('name'); } // 去除后台的谷歌自体 add_action('init', 'remove_open_sans_from_wp_core'); function remove_open_sans_from_wp_core() { wp_deregister_style('open-sans'); wp_register_style('open-sans', false); wp_enqueue_style('open-sans', ''); } // 自定义WordPress后台底部信息 add_filter('admin_footer_text', 'left_admin_footer_text'); function left_admin_footer_text($text) { // 修改左侧信息 $text = '感谢使用OKMILK销量查询系统'; return $text; } add_filter('update_footer', 'right_admin_footer_text', 11); function right_admin_footer_text($text) { // 修改右侧信息 $text = "4.6.1版本"; return $text; } // 去除右上角帮助 add_filter('contextual_help', 'wpse50723_remove_help', 999, 3); function wpse50723_remove_help($old_help, $screen_id, $screen) { $screen->remove_help_tabs(); return $old_help; } // 去除一般用户升级提醒 if (! current_user_can('manage_options')) { // Disable Theme Updates remove_action('load-update-core.php', 'wp_update_themes'); add_filter('pre_site_transient_update_themes', create_function('$a', "return null;")); wp_clear_scheduled_hook('wp_update_themes'); // Disable Plugin Updates remove_action('load-update-core.php', 'wp_update_plugins'); add_filter('pre_site_transient_update_plugins', create_function('$a', "return null;")); wp_clear_scheduled_hook('wp_update_plugins'); // Diasable Core Updates add_filter('pre_site_transient_update_core', create_function('$a', "return null;")); wp_clear_scheduled_hook('wp_version_check' ); }
2,插件
查看當前模板文件:安裝插件Show Current Template。
修改登陸頁logo:安裝插件Custom Login Logo。
去除wp頭部版本號:安裝插件Remove WP version and shortlink。
维护模式:安裝插件Maintenance Mode。