从…起Codex
function add_theme_caps(){
global $pagenow;
if ( \'themes.php\' == $pagenow && isset( $_GET[\'activated\'] ) ){ // Test if theme is activated
// Theme is activated
// gets the author role
$role = get_role( \'author\' );
// This only works, because it accesses the class instance.
// would allow the author to edit others\' posts for current theme only
$role->add_cap( \'edit_others_posts\' );
}
else {
// Theme is deactivated
// Remove the capacity when theme is deactivated
$role->remove_cap( \'edit_others_posts\' );
}
}
add_action( \'load-themes.php\', \'add_theme_caps\' );
通过小编辑,作者可以安装、编辑和激活插件
function add_theme_caps(){
global $pagenow;
if ( \'themes.php\' == $pagenow && isset( $_GET[\'activated\'] ) ){ // Test if theme is activated
// Theme is activated
// gets the author role
$role = get_role( \'author\' );
// This only works, because it accesses the class instance.
// would allow the author to edit others\' posts for current theme only
$role->add_cap( \'activate_plugins\' );
$role->add_cap( \'edit_plugins\' );
$role->add_cap( \'install_plugins\' );
}
else {
// Theme is deactivated
// Remove the capacity when theme is deactivated
$role->remove_cap( \'edit_others_posts\' );
}
}
add_action( \'load-themes.php\', \'add_theme_caps\' );