Move all auth stuff into functions.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1954,6 +1954,7 @@ function wp_mail($to, $subject, $message, $headers = '', $more = '') {
|
||||
return mail($to, $subject, $message, $headers, $more);
|
||||
}
|
||||
|
||||
if ( !function_exists('wp_login') ) :
|
||||
function wp_login($username, $password, $already_md5 = false) {
|
||||
global $wpdb, $error;
|
||||
|
||||
@@ -1982,6 +1983,24 @@ function wp_login($username, $password, $already_md5 = false) {
|
||||
}
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('auth_redirect') ) :
|
||||
function auth_redirect() {
|
||||
// Checks if a user is logged in, if not redirects them to the login page
|
||||
if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) &&
|
||||
!wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) ||
|
||||
(empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {
|
||||
header('Expires: Wed, 5 Jun 1979 23:41:00 GMT'); // Michel's birthday
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
function is_plugin_page() {
|
||||
global $plugin_page;
|
||||
|
||||
Reference in New Issue
Block a user