wp_nonce_ays() WordPress Function

The wp_nonce_ays() function is used to create a security token that can be used to protect forms and links from being tampered with. This function is typically used when a form is submitted or a link is clicked. The security token is generated using a secret key that is known only to the WordPress site administrator.

wp_nonce_ays( string $action ) #

Display “Are You Sure” message to confirm the action being taken.


Description

If the action has the nonce explain message, then it will be displayed along with the "Are you sure?" message.


Top ↑

Parameters

$action

(string)(Required)The nonce action.


Top ↑

Source

File: wp-includes/functions.php

function wp_nonce_ays( $action ) {
	// Default title and response code.
	$title         = __( 'Something went wrong.' );
	$response_code = 403;

	if ( 'log-out' === $action ) {
		$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(
			/* translators: %s: Logout URL. */
			__( 'Do you really want to <a href="%s">log out</a>?' ),
			wp_logout_url( $redirect_to )
		);
	} else {
		$html = __( 'The link you followed has expired.' );
		if ( wp_get_referer() ) {
			$html .= '</p><p>';
			$html .= sprintf(
				'<a href="%s">%s</a>',
				esc_url( remove_query_arg( 'updated', wp_get_referer() ) ),
				__( 'Please try again.' )
			);
		}
	}

	wp_die( $html, $title, $response_code );
}


Top ↑

Changelog

Changelog
VersionDescription
2.0.4Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More