PHP 如何以编程方式删除WordPress仪表板小部件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 如何以编程方式删除WordPress仪表板小部件相关的知识,希望对你有一定的参考价值。

Simply paste the following into your functions.php file. The code will remove all dashboard widgets, so you should comment lines related to wigets you'd like to keep.

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']);

}

if (!current_user_can('manage_options')) {
	add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
}

以上是关于PHP 如何以编程方式删除WordPress仪表板小部件的主要内容,如果未能解决你的问题,请参考以下文章

WordPress:以编程方式从 Post Window 隐藏小部件

删除 Wordpress 导航标签?

php 从Wordpress仪表板中删除小部件

php WP-从Wordpress仪表板中删除Aditional CSS

php 在管理仪表板页面上删除不必要的WordPress小部件

从WordPress管理面板/仪表板删除菜单项