[wp-trac] [WordPress Trac] #19898: Create an is_login_screen() function similar to is_admin()

WordPress Trac noreply at wordpress.org
Mon Oct 10 17:58:16 UTC 2022


#19898: Create an is_login_screen() function similar to is_admin()
------------------------------------------------+--------------------------
 Reporter:  dcowgill                            |       Owner:
                                                |  SergeyBiryukov
     Type:  enhancement                         |      Status:  closed
 Priority:  normal                              |   Milestone:  6.1
Component:  Login and Registration              |     Version:  3.3
 Severity:  normal                              |  Resolution:  fixed
 Keywords:  has-patch 2nd-opinion has-dev-note  |     Focuses:
------------------------------------------------+--------------------------
Changes (by SergeyBiryukov):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"54447" 54447]:
 {{{
 #!CommitTicketReference repository="" revision="54447"
 Login and Registration: Rename `is_login_screen()` function to
 `is_login()`.

 As the function can be used in a variety of contexts, the `_screen` suffix
 may not always be appropriate.

 This commit aims to reduce confusion by renaming the newly added
 `is_login_screen()` function to `is_login()`, which better aligns with
 `is_admin()` and the related `is_*_admin()` function family.

 While it does not save a lot of lines of code, this function aims to save
 developers some time that would otherwise be spent investigating the most
 reliable way to determine whether the current request is for the login
 screen.

 Implementation details:
 * By checking `wp_login_url()`, the function accounts for custom login
 locations set via the `login_url` filter.
 * By checking `$_SERVER['SCRIPT_NAME']` directly, instead of `did_action(
 'login_form_login' )` or `$pagenow` global, the function can work as early
 as possible, for example in a must-use plugin.

 Follow-up to [53884].

 Props azaozz.
 Fixes #19898. See #56400.
 }}}

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


More information about the wp-trac mailing list