From 15f99a6338101ce0c432bce893f697fdc534f874 Mon Sep 17 00:00:00 2001
From: Peter Westwood
diff --git a/wp-content/themes/classic/comments.php b/wp-content/themes/classic/comments.php
index d1b6ef58c5..06b4ef70b7 100644
--- a/wp-content/themes/classic/comments.php
+++ b/wp-content/themes/classic/comments.php
@@ -49,7 +49,7 @@ if ( post_password_required() ) : ?>
-
" . __( 'Please try again.' ) . ""; + elseif ( 'log-out' == $action ) + $html .= "
" . sprintf( __( "Do you really want to log out?"), wp_nonce_url( site_url('wp-login.php?action=logout', 'login'), 'log-out' ) ); + wp_die( $html, $title); } diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index d8228f1ed4..426e958b6c 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -104,13 +104,48 @@ function get_sidebar( $name = null ) { */ function wp_loginout() { if ( ! is_user_logged_in() ) - $link = '' . __('Log in') . ''; + $link = '' . __('Log in') . ''; else - $link = '' . __('Log out') . ''; + $link = '' . __('Log out') . ''; echo apply_filters('loginout', $link); } +/** + * Returns the Log Out URL. + * + * Returns the URL that allows the user to log out of the site + * + * @since 2.7 + * @uses wp_nonce_url() To protect against CSRF + * @uses site_url() To generate the log in URL + * + * @param string $redirect Path to redirect to on logout. + */ +function wp_logout_url($redirect = '') { + if ( strlen($redirect) ) + $redirect = "&redirect_to=$redirect"; + + return wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' ); +} + +/** + * Returns the Log In URL. + * + * Returns the URL that allows the user to log in to the site + * + * @since 2.7 + * @uses site_url() To generate the log in URL + * + * @param string $redirect Path to redirect to on login. + */ +function wp_login_url($redirect = '') { + if ( strlen($redirect) ) + $redirect = "?redirect_to=$redirect"; + + return site_url("wp-login.php$redirect", 'login'); +} + /** * Display the Registration or Admin link. * diff --git a/wp-login.php b/wp-login.php index 30b3d1357e..6dc6d769f2 100644 --- a/wp-login.php +++ b/wp-login.php @@ -272,7 +272,7 @@ $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); switch ($action) { case 'logout' : - + check_admin_referer('log-out'); wp_logout(); $redirect_to = 'wp-login.php?loggedout=true';