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

WordPress Trac noreply at wordpress.org
Sun Aug 25 01:22:58 UTC 2019


#19898: Create a is_login() function similar to is_admin()
---------------------------------------+-----------------------
 Reporter:  dcowgill                   |       Owner:  (none)
     Type:  enhancement                |      Status:  reopened
 Priority:  normal                     |   Milestone:
Component:  Administration             |     Version:  3.3
 Severity:  normal                     |  Resolution:
 Keywords:  needs-refresh 2nd-opinion  |     Focuses:
---------------------------------------+-----------------------
Changes (by iandunn):

 * keywords:  needs-refresh => needs-refresh 2nd-opinion
 * status:  closed => reopened
 * resolution:  wontfix =>


Comment:

 I think this is worth reconsidering.


 > is_login() simply returns $GLOBALS['pagenow'] == 'wp-login.php, which is
 not really much of a shortcut

 > latest patch doesn't really save anyone who really wanted to use a
 function like this that much code

 It doesn't save a lot of lines of code, but what it does save is a lot of
 time spent investigating the most reliable way to solve this problem.

 As the various patches and
 [https://wordpress.stackexchange.com/q/12863/3898 WPSE answers]
 demonstrate, there are a handful of ways that devs have tried to solve
 this problem, and many of them are buggy. I personally just spent an hour
 of research and testing before settling on a solution I'm happy with, and
 it's still possible that I missed some edge cases.

 It'd save devs a lot of time and bugs if Core provided a reliable
 solution.

 > we can just use did_action( 'login_form_login' )

 I think the flaw with [attachment:"19898.5.diff"] is that
 `login_form_{$action}` executes ''after'' plugins have loaded, so it
 wouldn't solve the use case of a bootstraper that's trying to load code
 exclusively on the login screen.

 I would do this instead:

 {{{
 function is_login_screen() {
         return false !== stripos( wp_login_url(), $_SERVER['SCRIPT_NAME']
 );
 }
 }}}

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


More information about the wp-trac mailing list