Language packs: Remove translations when deleting a theme or a plugin.

This is for translation files in WP_LANG_DIR which are installed through a language pack.
Change `wp_get_installed_translations()` to only return a translation if the .mo file also exists.

fixes #29860.
Built from https://develop.svn.wordpress.org/trunk@29856


git-svn-id: http://core.svn.wordpress.org/trunk@29619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling
2014-10-08 19:05:20 +00:00
parent 5f17e0952d
commit 57c41263d7
5 changed files with 134 additions and 45 deletions

View File

@@ -797,16 +797,23 @@ function wp_get_installed_translations( $type ) {
$language_data = array();
foreach ( $files as $file ) {
if ( '.' === $file[0] || is_dir( $file ) )
if ( '.' === $file[0] || is_dir( $file ) ) {
continue;
if ( substr( $file, -3 ) !== '.po' )
}
if ( substr( $file, -3 ) !== '.po' ) {
continue;
if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) )
}
if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) ) {
continue;
}
if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files ) ) {
continue;
}
list( , $textdomain, $language ) = $match;
if ( '' === $textdomain )
if ( '' === $textdomain ) {
$textdomain = 'default';
}
$language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" );
}
return $language_data;