Best WordPress Hosting
 

New is_login_screen() function for determining if a page is the login screen

via make.wordpress.org => original post link

In #19898 the is_login_screen() function was introduced to allow for determining if a page is the login page.

The is_login_screen function determines if the current request is for the WordPress login screen returning true when the current screen matches and false for all other cases. This function will provide a quick and searchable way of checking if the login screen is being viewed. Custom login locations are also accounted for in this function. 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.

In the below example a check is happening on the init action to display a welcome message on the login page only. This check would account for pages that have custom login screens in non-standard locations.