auth_redirect

The timeline below displays how wordpress function auth_redirect has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * When this code is called from a page, it checks to see if the user viewing the page is logged in.
 * If the user is not logged in, they are redirected to the login page. The user is redirected
 * in such a way that, upon logging in, they will be sent directly to the page they were originally
 * trying to access.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filters whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect.
    if ($secure && !is_ssl() && str_contains($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (str_starts_with($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    $user_id = wp_validate_auth_cookie('', $scheme);
    if ($user_id) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && str_contains($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (str_starts_with($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good, so we're done.
    }
    // The cookie is no good, so force login.
    nocache_headers();
    if (str_contains($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) {
        $redirect = wp_get_referer();
    } else {
        $redirect = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    }
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 5.4

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * When this code is called from a page, it checks to see if the user viewing the page is logged in.
 * If the user is not logged in, they are redirected to the login page. The user is redirected
 * in such a way that, upon logging in, they will be sent directly to the page they were originally
 * trying to access.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filters whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect.
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    $user_id = wp_validate_auth_cookie('', $scheme);
    if ($user_id) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good, so we're done.
    }
    // The cookie is no good, so force login.
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 5.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * When this code is called from a page, it checks to see if the user viewing the page is logged in.
 * If the user is not logged in, they are redirected to the login page. The user is redirected
 * in such a way that, upon logging in, they will be sent directly to the page they were originally
 * trying to access.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filters whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    $user_id = wp_validate_auth_cookie('', $scheme);
    if ($user_id) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 4.6

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filters whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .20

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 5.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .10

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 4.5

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .30

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 4.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .20

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 4.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .10

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 4.4

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 3.5

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 3.4

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .30

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 3.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .20

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 3.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .10

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 4.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 2.9

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 2.4

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .30

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 2.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .20

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 2.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .10

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 1.5

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .40

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 1.4

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .30

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 1.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .20

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 1.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .12

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 0.4

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .30

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 0.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .20

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 0.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .12

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 9.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .13

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 3.9

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5.0
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    /**
     * Filter whether to use a secure authentication redirect.
     *
     * @since 3.1.0
     *
     * @param bool $secure Whether to use a secure authentication redirect. Default false.
     */
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        /**
         * Filter the authentication redirect scheme.
         *
         * @since 2.9.0
         *
         * @param string $scheme Authentication redirect scheme. Default empty.
         */
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        /**
         * Fires before the authentication redirect.
         *
         * @since 2.8.0
         *
         * @param int $user_id User ID.
         */
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 8.4

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .30

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 8.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .20

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 8.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .15

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 7.5

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .40

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 7.4

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .30

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 7.3

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .20

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 7.2

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: .15

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    /**
     * Filters the authentication redirect scheme.
     *
     * @since 2.9.0
     *
     * @param string $scheme Authentication redirect scheme. Default empty.
     */
    $scheme = apply_filters('auth_redirect_scheme', '');
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}

WordPress Version: 3.7

/**
 * Checks if a user is logged in, if not it redirects them to the login page.
 *
 * @since 1.5
 */
function auth_redirect()
{
    // Checks if a user is logged in, if not redirects them to the login page
    $secure = is_ssl() || force_ssl_admin();
    $secure = apply_filters('secure_auth_redirect', $secure);
    // If https is required and request is http, redirect
    if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
            wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
            exit;
        } else {
            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    if (is_user_admin()) {
        $scheme = 'logged_in';
    } else {
        $scheme = apply_filters('auth_redirect_scheme', '');
    }
    if ($user_id = wp_validate_auth_cookie('', $scheme)) {
        do_action('auth_redirect', $user_id);
        // If the user wants ssl but the session is not ssl, redirect.
        if (!$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
            if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
                wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
                exit;
            } else {
                wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return;
        // The cookie is good so we're done
    }
    // The cookie is no good so force login
    nocache_headers();
    $redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $login_url = wp_login_url($redirect, true);
    wp_redirect($login_url);
    exit;
}