[wp-trac] [WordPress Trac] #53729: $title never used, Replaced with text

WordPress Trac noreply at wordpress.org
Wed Jul 21 23:13:00 UTC 2021


#53729: $title never used, Replaced with text
-------------------------+-------------------------------
 Reporter:  ravipatel    |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Help/About   |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:  coding-standards
-------------------------+-------------------------------
Changes (by hellofromTonya):

 * keywords:  has-patch needs-refresh close 2nd-opinion => needs-patch


Comment:

 The `$title` variable is for populating the `<title>` tag and not for the
 panel's `<h1>`. The `<title>` is built in `wp-admin/admin-header.php`. Why
 is this variable in each panel's file and not assigned in the admin header
 file? For reusability. It allows each panel to assign its title for use in
 building the `<title>`.

 == Should this variable be used to also populate the `<h1>`?

 No, I don't think so. I agree with @SergeyBiryukov. Why?

 As Sergey notes, the `<h1>` is different than the `<title>` on many of the
 panels. Using it for dual purpose on some panels but not others will be
 confusing to contributors as it breaks the pattern.

 At the same time, I can also see confusion when reading it on the Privacy
 panel and it's the same. It looks like duplicate code. Right? I definitely
 get why this ticket was created.

 == What could we do to help with the readability and avoid this type of
 confusion?

 Add an inline comment as [comment:3 suggestions]:

 > To explain the variable in each of the three related files, perhaps we
 could add a regular comment as simple as:
 > {{{
 > // Used in HTML title tag.
 > $title = __( 'Privacy' );
 > }}}

 == Patch Notes

 Also note @ravipatel in [attachment:"53729.patch"], the title variable
 would need to be echoed. Thought I'd note that as a learning opportunity
 for anyone reading this ticket.

 == Next Steps

 Add comments above each `$title = ...` for readability. @ravipatel would
 you like to create the patch for this?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53729#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list