Make WordPress Core

Opened 7 weeks ago

Last modified 6 weeks ago

#60668 accepted enhancement

Missing translation in login_header() first parameter

Reported by: juliobox's profile juliobox Owned by: audrasjb's profile audrasjb
Milestone: 6.6 Priority: normal
Severity: minor Version: 2.1
Component: Login and Registration Keywords: good-first-bug has-patch
Focuses: Cc:

Description

Hey there

Actuel code from WP (wp-login.php):

<?php
function login_header( $title = 'Log In', $message = '', $wp_error = null ) {

The $title here will be print as is, in any language. WordPress uses it the right way by always passing a translatable string as first param, but since there is a default value, some plugins can use it without it (and they do it, i've check wpdirectory, more than 1M install, 7 plugins are doing it).

So we cannot remove the default value or we will break the world in half, we have to choose between this:

<?php
function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
    if ( 'Log In' === $title ) {
        $title = __( 'Log In' );
    }

or

<?php
function login_header( $title = null, $message = '', $wp_error = null ) {
    if ( is_null( $title ) ) {
        $title = __( 'Log In' );
    }

We can also use a ternary test to do it, as you want, the point is, what is the default value now?
In both cases and same as now you can still pass "" to print nothing and it's OK.
By using null as default and passing "Log In" as param you will print a non translated string "Log In" (in any language).
By using "Log In" as default and passing "Log In" as param you will print a correctly translated string "Se connecter" (here in french).

Thanks

Change History (3)

#1 @swissspidy
7 weeks ago

  • Component changed from I18N to Login and Registration
  • Keywords good-first-bug added
  • Milestone changed from Awaiting Review to Future Release
  • Version set to 2.1

A null check looks reasonable to me.

<?php
if ( null === $title ) {
        $title = __( 'Log In' );
}

This ticket was mentioned in PR #6209 on WordPress/wordpress-develop by @mainetenance.


7 weeks ago
#2

  • Keywords has-patch added; needs-patch removed

#3 @audrasjb
6 weeks ago

  • Milestone changed from Future Release to 6.6
  • Owner set to audrasjb
  • Status changed from new to accepted

The proposed PR looks good to me. Thank you @mainetenance and congrats for your first patch.

Moving to milestone 6.6.

Note: See TracTickets for help on using tickets.