Role/Capability: Introduce capabilities dedicated to installing and updating language files.

The new meta capabilities are called `install_languages` and `update_languages`. Prior to this change, there were no proper capability checks applied. Instead only the filesystem and related constants were checked, and for actual permissions a rather vague fallback was used where a user needed to have at least one of the other updating capabilities. In addition to being generally more verbose, the new capabilities make it possible for example to allow a user to update languages, but nothing else. By default they fall back to the original way of how they were handled.

Props johnbillion, flixos90.
Fixes #39677.

Built from https://develop.svn.wordpress.org/trunk@41268


git-svn-id: http://core.svn.wordpress.org/trunk@41108 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz
2017-08-18 18:31:44 +00:00
parent c14e0a0527
commit f6ebc1a80c
9 changed files with 65 additions and 22 deletions

View File

@@ -177,14 +177,12 @@ if ( 'update' == $action ) {
}
// Handle translation install.
if ( ! empty( $_POST['WPLANG'] ) && ( ! is_multisite() || is_super_admin() ) ) { // @todo: Skip if already installed
if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) {
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
if ( wp_can_install_language_pack() ) {
$language = wp_download_language_pack( $_POST['WPLANG'] );
if ( $language ) {
$_POST['WPLANG'] = $language;
}
$language = wp_download_language_pack( $_POST['WPLANG'] );
if ( $language ) {
$_POST['WPLANG'] = $language;
}
}
}