Wordpress - how detect if current page is the login page

后端 未结 4 1522
生来不讨喜
生来不讨喜 2021-02-05 06:39

There is a better way than using global variable $pagenow to detect current page if is login page, like a is_admin() ?

if ($pagenow !=          


        
4条回答
  •  [愿得一人]
    2021-02-05 06:56

    Incase you want to be as non WP independant as possible; for instance in a plugin keeping future changes out of scope. You can use something like this:

    function is_login_page() {
        return !strncmp($_SERVER['REQUEST_URI'], '/wp-login.php', strlen('/wp-login.php'));
    }
    

提交回复
热议问题