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

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

The is_login() 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 pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party.

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.

function add_text_to_login() {
    if ( is_login() ) {
        echo( "<h1>Welcome to the login screen!</h1>" );
    }
}
add_action( 'init', 'add_text_to_login' );

For more information See #19898.

Props to @antpb for reviewing this dev-note.

#6-1, #dev-notes, #dev-notes-6-1