wp_nonce_ays

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

Description

wp_nonce_ays( (string) $action ); 

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

Parameters (1)

0. $action (string)
The nonce action.

Usage

  1. if ( !function_exists( 'wp_nonce_ays' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // The nonce action. 
  5. $action = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_nonce_ays($action); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_nonce_ays( $action ) { 
  2. if ( 'log-out' == $action ) { 
  3. $html = sprintf( 
  4. /** translators: %s: site name */ 
  5. __( 'You are attempting to log out of %s' ),  
  6. get_bloginfo( 'name' ) 
  7. ); 
  8. $html .= '</p><p>'; 
  9. $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 
  10. $html .= sprintf( 
  11. /** translators: %s: logout URL */ 
  12. __( 'Do you really want to <a href="%s">log out</a>?' ),  
  13. wp_logout_url( $redirect_to ) 
  14. ); 
  15. } else { 
  16. $html = __( 'Are you sure you want to do this?' ); 
  17. if ( wp_get_referer() ) { 
  18. $html .= '</p><p>'; 
  19. $html .= sprintf( '<a href="%s">%s</a>',  
  20. esc_url( remove_query_arg( 'updated', wp_get_referer() ) ),  
  21. __( 'Please try again.' ) 
  22. ); 
  23.  
  24. wp_die( $html, __( 'WordPress Failure Notice' ), 403 );