wordpress备案选项
In my previous post we created a new WordPress plugin which simplified the administration panels for your clients. If you haven’t read it, please do so first. In this article, we’ll use the same plugin file for deeper configuration changes.
在我以前的文章中,我们创建了一个新的WordPress插件,该插件简化了您客户的管理面板 。 如果您还没有阅读过,请先阅读。 在本文中,我们将使用相同的插件文件进行更深入的配置更改。
删除WordPress更新通知 (Remove the WordPress Update Notification)
WordPress informs you when an update is available. Unfortunately, it tells everyone — including your clients. That could lead to unnecessary concern or tempt them call you every half an hour until it’s upgraded.
当有可用更新时,WordPress会通知您。 不幸的是,它告诉所有人-包括您的客户。 这可能导致不必要的担忧,或者诱使他们每半小时致电给您一次,直到升级为止。
Append the following code to easy-admin.php to remove the notification for everyone except for WordPress administrators:
将以下代码附加到easy-admin.php以删除除WordPress管理员以外的所有人的通知:
function no_update_notification() {
if (!current_user_can('activate_plugins')) remove_action('admin_notices', 'update_nag', 3);
}
add_action('admin_notices', 'no_update_notification', 1);
删除不必要的仪表板小部件 (Remove Unnecessary Dashboard Widgets)
You can remove dashboard widgets for a user by logging in as them and un-checking items in the “Screen Options” pull-down panel. However, that may not be practical and there’s nothing to prevent your client re-enabling them.
您可以通过以下方式删除用户的仪表板小部件,即以它们的身份登录并取消选中“屏幕选项”下拉面板中的项目。 但是,这可能不切实际,没有什么可以阻止您的客户重新启用它们的。
Append the following function to easy-admin.php to remove unnecessary dashboard widgets. You may need to add, remove or modify unset commands as required. For example, the first section (lines 5-7) removes “Right Now” for everyone but WordPress administrators. The second section (lines 9-13) removes widgets regardless of the user’s rights.
将以下功能添加到easy-admin.php,以删除不必要的仪表板小部件。 您可能需要根据需要添加,删除或修改未设置的命令。 例如,第一部分(第5-7行)为除WordPress管理员之外的所有用户删除了“立即使用”。 第二部分(第9-13行)删除小部件,而不考虑用户的权限。
The dashboard widget’s ID is assigned to its box div
element — use Firebug or inspect the source to find that value.
仪表板小部件的ID已分配给其box div
元素-使用Firebug或检查源以找到该值。
// remove unnecessary dashboard widgets
function remove_dashboard_widgets(){
global $wp_meta_boxes;
// do not remove "Right Now" for administrators
if (!current_user_can('activate_plugins')) {
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
}
// remove widgets for everyone
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
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']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
删除不必要的页面并发布元框 (Remove Unnecessary Page and Post Meta Boxes)
Few developers use all the features WordPress has to offer. For example, if all posts are assigned to a single default category, you don’t require the Categories box. Or perhaps you’re not permitting comments and can remove associated boxes.
很少有开发人员使用WordPress必须提供的所有功能。 例如,如果所有帖子都分配到一个默认类别,则不需要“类别”框。 或者,也许您不允许评论,并且可以删除关联的框。
Append the following function to easy-admin.php to remove unnecessary meta boxes from the posts and pages panels. You may have to add or remove remove_meta_box() calls in this function. The first argument is the ID assigned to the box’s div
element — again, this can be discovered in the source or with Firebug.
将以下功能附加到easy-admin.php,以从帖子和页面面板中删除不必要的元框。 您可能必须在此函数中添加或删除remove_meta_box()调用。 第一个参数是分配给该框的div
元素的ID,同样,可以在源代码中或使用Firebug来发现它。
// remove unnecessary page/post meta boxes
function remove_meta_boxes() {
// posts
remove_meta_box('postcustom','post','normal');
remove_meta_box('trackbacksdiv','post','normal');
remove_meta_box('commentstatusdiv','post','normal');
remove_meta_box('commentsdiv','post','normal');
remove_meta_box('categorydiv','post','normal');
remove_meta_box('tagsdiv-post_tag','post','normal');
remove_meta_box('slugdiv','post','normal');
remove_meta_box('authordiv','post','normal');
// pages
remove_meta_box('postcustom','page','normal');
remove_meta_box('commentstatusdiv','page','normal');
remove_meta_box('trackbacksdiv','page','normal');
remove_meta_box('commentsdiv','page','normal');
remove_meta_box('slugdiv','page','normal');
remove_meta_box('authordiv','page','normal');
}
add_action('admin_init','remove_meta_boxes');
删除收藏夹动作 (Remove Favorite Actions)
The favorite actions button resides in the WordPress header next to the “Howdy” message. It normally provides quick links to New Post, Drafts, New Page, Upload and perhaps a few plugin-specific options such as “Empty Cache”. Let’s remove the options we don’t require by appending the following code to easy-admin.php:
“收藏夹操作”按钮位于“ Howdy”消息旁边的WordPress标头中。 它通常提供指向“新帖子”,“草稿”,“新页面”,“上载”以及也许一些特定于插件的选项(例如“空缓存”)的快速链接。 通过将以下代码附加到easy-admin.php中,让我们删除不需要的选项:
// remove favorite actions
function remove_favorite_actions($actions) {
if (!current_user_can('activate_plugins')) {
unset($actions['edit-comments.php']);
}
return $actions;
}
add_filter('favorite_actions', 'remove_favorite_actions');
In this example, we’ve removed the Comments link for everyone except administrators. To remove other items, you need to find the action’s URL in the page source. Locate the element with the ID “favorite-actions” and, within that, an element with the ID “favorite-inside”. The child div
s contain links to URLs such as “media-new.php”. To remove that option, simply add unset($actions['media-new.php']);
to the function.
在此示例中,我们为管理员以外的所有用户删除了“评论”链接。 要删除其他项目,您需要在页面源中找到操作的URL。 找到ID为“ favorite-actions”的元素,并在其中找到ID为“ favorite-inside”的元素。 子div
包含指向URL的链接,例如“ media-new.php”。 要删除该选项,只需添加unset($actions['media-new.php']);
功能。
Phew. In my next WordPress post, we’ll address the WordPress menu and remove all the dangerous options you want to hide from clients.
ew 在我的下一篇WordPress帖子中,我们将介绍WordPress菜单并删除您要向客户端隐藏的所有危险选项。
翻译自: https://www.sitepoint.com/wordpress-easy-administration-plugin-2/
wordpress备案选项