Make WordPress Core

Changeset 53181


Ignore:
Timestamp:
04/14/2022 01:24:59 PM (2 years ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin.php

    r53104 r53181  
    156156        if ( $textdomain ) {
    157157            foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
    158                 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
    159                 $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
     158                if ( ! empty( $plugin_data[ $field ] ) ) {
     159                    // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
     160                    $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
     161                }
    160162            }
    161163        }
Note: See TracChangeset for help on using the changeset viewer.