我假设您的意思是限制访问权限,以编辑管理界面中的侧栏,而不是删除它的主题。
如果不深入了解小部件/侧栏框架在幕后的工作方式,那么最好的选择就是$wp_registered_sidebars
全球的然而,关键是当时间太早和wp管理/小部件时。php模板将看到缺少的侧栏,并将其移到非活动侧栏“侧栏”。太晚了,而且,你没有效果。
add_action(\'widgets_admin_page\', \'sidebar_capabilities\');
/**
* Keep in mind that you can certainly create custom
* capabilities for your sidebars. You could create a loop
* that generates new capabilities for each sidebar and assigns them
* to admin. You could then manage those capabilities for other
* users with the Members plugin by Justin Tadlock
*/
function sidebar_capabilities(){
global $wp_registered_sidebars;
//Remove the comment lines to see the global variable structure.
//print_r($wp_registered_sidebars);
//Use whatever capabilities you want.
//To test as admin, just put junk text for the cap.
if(is_admin() && !current_user_can(\'edit_plugins\')){
//This sidebar name is from the twenty-ten theme.
unset($wp_registered_sidebars[\'primary-widget-area\']);
}
}