wp_refresh_post_nonces

Check nonce expiration on the New/Edit Post screen and refresh if needed.

Description

(array) wp_refresh_post_nonces( (array) $response, (array) $data, (string) $screen_id ); 

Returns (array)

The Heartbeat response.

Parameters (3)

0. $response (array)
The Heartbeat response.
1. $data (array)
The $_POST data sent.
2. $screen_id (string)
The screen id.

Usage

  1. if ( !function_exists( 'wp_refresh_post_nonces' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/misc.php'; 
  3.  
  4. // The Heartbeat response. 
  5. $response = array(); 
  6.  
  7. // The $_POST data sent. 
  8. $data = array(); 
  9.  
  10. // The screen id. 
  11. $screen_id = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wp_refresh_post_nonces($response, $data, $screen_id); 
  15.  

Defined (1)

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

/wp-admin/includes/misc.php  
  1. function wp_refresh_post_nonces( $response, $data, $screen_id ) { 
  2. if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) { 
  3. $received = $data['wp-refresh-post-nonces']; 
  4. $response['wp-refresh-post-nonces'] = array( 'check' => 1 ); 
  5.  
  6. if ( ! $post_id = absint( $received['post_id'] ) ) { 
  7. return $response; 
  8.  
  9. if ( ! current_user_can( 'edit_post', $post_id ) ) { 
  10. return $response; 
  11.  
  12. $response['wp-refresh-post-nonces'] = array( 
  13. 'replace' => array( 
  14. 'getpermalinknonce' => wp_create_nonce('getpermalink'),  
  15. 'samplepermalinknonce' => wp_create_nonce('samplepermalink'),  
  16. 'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'),  
  17. '_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ),  
  18. '_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ),  
  19. ),  
  20. 'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ),  
  21. ); 
  22.  
  23. return $response;