wp_nonce_url

Retrieve URL with nonce added to URL query.

Description

(string) wp_nonce_url( (string) $actionurl, (int) $action = -1, (string) $name = '_wpnonce' ); 

Returns (string)

Escaped URL with nonce action added.

Parameters (3)

0. $actionurl (string)
URL to add nonce action.
1. $action — Optional. (int) => -1
Nonce action name. Default -1.
2. $name — Optional. (string) => '_wpnonce'
Nonce name. Default _wpnonce..

Usage

  1. if ( !function_exists( 'wp_nonce_url' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // URL to add nonce action. 
  5. $actionurl = ''; 
  6.  
  7. // Optional. Nonce action name. Default -1. 
  8. $action = -1; 
  9.  
  10. // Optional. Nonce name. Default '_wpnonce'. 
  11. $name = '_wpnonce'; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wp_nonce_url($actionurl, $action, $name); 
  15.  

Defined (1)

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

/wp-includes/functions.php  
  1. function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) { 
  2. $actionurl = str_replace( '&', '&', $actionurl ); 
  3. return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) );