首页 > 技术文章 > functions在后台移除“隐私”设置菜单

chengdex 2018-12-13 15:20 原文

在 WordPress 5.0 版本以后,如果未完整的配置隐私页面,设置菜单还会有特别明显的气泡“1”提示,如何隐藏掉。
//WordPress 彻底移除后台“隐私”设置功能
add_filter( 'map_meta_cap', 'ds_disable_core_privacy_tools', 10, 2 );
remove_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
remove_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' );
function ds_disable_core_privacy_tools( $caps, $cap ) {
    switch ( $cap ) {
        case 'export_others_personal_data':
        case 'erase_others_personal_data':
        case 'manage_privacy_options':
            $caps[] = 'do_not_allow';
            break;
    }
    return $caps;
}

 

推荐阅读