WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#21243 closed enhancement (fixed)

move password hint text to a function

Reported by: convissor Owned by: SergeyBiryukov
Milestone: 4.1 Priority: normal
Severity: normal Version:
Component: Users Keywords:
Focuses: docs Cc:
PR Number:

Description

The password hint text, noted below, is hard coded in four places:

wp-admin/install.php
wp-admin/user-edit.php
wp-admin/user-new.php
wp-login.php
Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).

This approach is prone to mistakes when changes are made. In addition, plugins that want to override the text need to use the resource intensive and clumsy gettext filter.

Per nacin and westi, the attached patch moves the text to a function (wp_password_hint()) in wp-includes/user.php and adds a filter (password_hint).

Attachments (7)

wp_password_hint.diff (3.8 KB) - added by convissor 7 years ago.
21243.2.diff (3.8 KB) - added by SergeyBiryukov 7 years ago.
21243.diff (3.4 KB) - added by voldemortensen 5 years ago.
21243.4.diff (3.6 KB) - added by convissor 5 years ago.
clean, patch updated to 4.1
21243.5.diff (3.8 KB) - added by convissor 5 years ago.
Add docblock for filter hook call. Fix @since on main function.
21243.patch (2.6 KB) - added by Ankit K Gupta 5 years ago.
patch file with updated function name
21243.8.patch (2.6 KB) - added by Ankit K Gupta 5 years ago.
Patch file with formatting

Download all attachments as: .zip

Change History (32)

#1 @SergeyBiryukov
7 years ago

  • Keywords has-patch added

It would probably make sense to mark the function as private (21243.2.diff), similarly to _wp_get_user_contactmethods().

#2 @ramiy
6 years ago

I like this.
Simple function and it has filterable text.

@voldemortensen
5 years ago

#3 @voldemortensen
5 years ago

+1 for this. Refreshed patch.

@convissor
5 years ago

clean, patch updated to 4.1

#4 @convissor
5 years ago

The minor grammar change in #26457 / r27246 "breaking" Login Security Solution reaffirms the need for this patch.

This ticket was mentioned in IRC in #wordpress-dev by DanielConvissor. View the logs.


5 years ago

#6 @SergeyBiryukov
5 years ago

  • Focuses docs added
  • Milestone changed from Awaiting Review to 4.1

The filter needs to be documented as per the documentation standards.

@convissor
5 years ago

Add docblock for filter hook call. Fix @since on main function.

#7 @SergeyBiryukov
5 years ago

  • Component changed from General to Users
  • Keywords commit added

#8 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 29962:

Move password hint text to a function. Add 'password_hint' filter.

props convissor.
fixes #21243.

#9 follow-up: @SergeyBiryukov
5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Let's rename the function to _wp_get_password_hint(), for consistency with other functions like _wp_get_user_contactmethods() or _get_additional_user_keys().

#10 @Ankit K Gupta
5 years ago

Updated the function name for make consistency with other functions.

@Ankit K Gupta
5 years ago

patch file with updated function name

@Ankit K Gupta
5 years ago

Patch file with formatting

#11 in reply to: ↑ 9 ; follow-up: @ramiy
5 years ago

Replying to SergeyBiryukov:

Let's rename the function to _wp_get_password_hint(), for consistency with other functions like _wp_get_user_contactmethods() or _get_additional_user_keys().

Sergey,

why not use a shorter name _get_password_hint() ?

#12 in reply to: ↑ 11 @Ankit K Gupta
5 years ago

Replying to ramiy:

Replying to SergeyBiryukov:

Let's rename the function to _wp_get_password_hint(), for consistency with other functions like _wp_get_user_contactmethods() or _get_additional_user_keys().

Sergey,

why not use a shorter name _get_password_hint() ?

We can use this. It is based on our choice. Let me know, what is the issue with longer name of the function ?

Last edited 5 years ago by Ankit K Gupta (previous) (diff)

#13 follow-up: @johnbillion
5 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 30033:

Rename _wp_password_hint() to _wp_get_password_hint() to bring it inline with core terminology. Fixes #21243.

#14 in reply to: ↑ 13 @Ankit K Gupta
5 years ago

Replying to johnbillion:

In 30033:

Rename _wp_password_hint() to _wp_get_password_hint() to bring it inline with core terminology. Fixes #21243.

Did you add my patch file ? As attached in comment 10 Or any issue in my patch file ?

Please confirm.
Thanks !

Last edited 5 years ago by Ankit K Gupta (previous) (diff)

#15 @Ankit K Gupta
5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#16 @johnbillion
5 years ago

  • Keywords close added; has-patch commit removed

I'm not sure what you're asking, Ankit. The change was applied in r30033 and will be available in WordPress 4.1.

#17 @johnbillion
5 years ago

  • Keywords close removed
  • Resolution set to fixed
  • Status changed from reopened to closed

Ah I see. The function was renamed _wp_get_password_hint() to bring it inline with other core function names.

#18 follow-up: @Ankit K Gupta
5 years ago

I guess, You forgot to mention the Props in this ticket after commit my patch.

#19 in reply to: ↑ 18 @helen
5 years ago

Replying to Ankit K Gupta:

I guess, You forgot to mention the Props in this ticket after commit my patch.

Just uploading a patch doesn't trigger any notifications - it is very likely johnbillion made the changes himself and committed them, as opposed to applying a patch that wasn't seen. In the future, please leave a comment about your patch, which also helps to explain what you're doing with it.

#20 follow-ups: @johnbillion
5 years ago

Nope I just missed the props. Sorry Ankit!

#21 in reply to: ↑ 20 @Ankit K Gupta
5 years ago

Replying to johnbillion:

Nope I just missed the props. Sorry Ankit!

Hey johnbillion. It's fine.
It would be great if you can add props now. Otherwise it's ok.

#22 in reply to: ↑ 20 @Ankit K Gupta
5 years ago

Replying to johnbillion:

Nope I just missed the props. Sorry Ankit!

It would be great if you can add props now.?

#23 follow-up: @SergeyBiryukov
5 years ago

Sorry, we can't change the commit message after the fact.

But you'll still make it to the Credits screen with [30027] and [30054].

#24 in reply to: ↑ 23 @Ankit K Gupta
5 years ago

Replying to SergeyBiryukov:

Sorry, we can't change the commit message after the fact.

But you'll still make it to the Credits screen with [30027] and [30054].

It's fine.
Thanks for the response.

#25 @SergeyBiryukov
5 years ago

In 30940:

No need for wp_get_password_hint() to be prefixed as if it is private.

Merges [30855] to the 4.1 branch.

props nacin.
see #21243.

Note: See TracTickets for help on using tickets.