Login and Registration: Improve messaging for invalid log-out nonces.

Clarify messaging of when `wp_nonce_ays('log-out')` is called due to an invalid log out nonce. The HTML title now describes the action being taken rather than using the generic text "something went wrong".

Props davidkryzaniak, hellofromTonya, peterwilsoncc.
Fixes #52600.



git-svn-id: https://develop.svn.wordpress.org/trunk@52088 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2021-11-09 23:05:32 +00:00
parent d4447c0d76
commit b2758c4494

View File

@ -3469,12 +3469,17 @@ function get_allowed_mime_types( $user = null ) {
* @param string $action The nonce action.
*/
function wp_nonce_ays( $action ) {
// Default title and response code.
$title = __( 'Something went wrong.' );
$response_code = 403;
if ( 'log-out' === $action ) {
$html = sprintf(
$title = sprintf(
/* translators: %s: Site title. */
__( 'You are attempting to log out of %s' ),
get_bloginfo( 'name' )
);
$html = $title;
$html .= '</p><p>';
$redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
$html .= sprintf(
@ -3494,7 +3499,7 @@ function wp_nonce_ays( $action ) {
}
}
wp_die( $html, __( 'Something went wrong.' ), 403 );
wp_die( $html, $title, $response_code );
}
/**