Plugins: Avoid translating empty plugin headers.

This change aims to avoid unnecessarily translating empty strings from plugin headers, by removing empty fields from translation process in `_get_plugin_data_markup_translate()`.

Props Chouby, johnbillion, audrasjb.
Fixes #54586.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52770 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2022-04-14 13:26:12 +00:00
parent 44e4439d68
commit 80aea1734c
2 changed files with 5 additions and 3 deletions

View File

@ -155,8 +155,10 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
}
if ( $textdomain ) {
foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
if ( ! empty( $plugin_data[ $field ] ) ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
}
}
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-beta1-53180';
$wp_version = '6.0-beta1-53181';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.