WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 3 days 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: has-patch commit
Focuses: docs Cc:

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 2 years ago.
21243.2.diff (3.8 KB) - added by SergeyBiryukov 2 years ago.
21243.diff (3.4 KB) - added by voldemortensen 3 weeks ago.
21243.4.diff (3.6 KB) - added by convissor 3 weeks ago.
clean, patch updated to 4.1
21243.5.diff (3.8 KB) - added by convissor 3 weeks ago.
Add docblock for filter hook call. Fix @since on main function.
21243.patch (2.6 KB) - added by Ankit K Gupta 10 days ago.
patch file with updated function name
21243.8.patch (2.6 KB) - added by Ankit K Gupta 10 days ago.
Patch file with formatting

Download all attachments as: .zip

Change History (20)

convissor2 years ago

SergeyBiryukov2 years ago

comment:1 SergeyBiryukov2 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().

comment:2 ramiy15 months ago

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

voldemortensen3 weeks ago

comment:3 voldemortensen3 weeks ago

+1 for this. Refreshed patch.

convissor3 weeks ago

clean, patch updated to 4.1

comment:4 convissor3 weeks ago

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

comment:5 ircbot3 weeks ago

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

comment:6 SergeyBiryukov3 weeks ago

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

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

convissor3 weeks ago

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

comment:7 SergeyBiryukov12 days ago

  • Component changed from General to Users
  • Keywords commit added

comment:8 SergeyBiryukov11 days 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.

comment:9 follow-up: SergeyBiryukov11 days 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().

comment:10 Ankit K Gupta10 days ago

Updated the function name for make consistency with other functions.

Ankit K Gupta10 days ago

patch file with updated function name

Ankit K Gupta10 days ago

Patch file with formatting

comment:11 in reply to: ↑ 9 ; follow-up: ramiy10 days 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() ?

comment:12 in reply to: ↑ 11 Ankit K Gupta4 days 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 4 days ago by Ankit K Gupta (previous) (diff)

comment:13 johnbillion3 days 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.

Note: See TracTickets for help on using tickets.