wp_refresh_post_nonces() WordPress Function

The wp_refresh_post_nonces() function is used to refresh the post nonces for the current user. This function is typically called after the user has completed an action that modifies the post, such as publishing a post or deleting a post.

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

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


Parameters

$response

(array)(Required)The Heartbeat response.

$data

(array)(Required)The $_POST data sent.

$screen_id

(string)(Required)The screen ID.


Top ↑

Return

(array) The Heartbeat response.


Top ↑

Source

File: wp-admin/includes/misc.php

function wp_refresh_post_nonces( $response, $data, $screen_id ) {
	if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
		$received = $data['wp-refresh-post-nonces'];

		$response['wp-refresh-post-nonces'] = array( 'check' => 1 );

		$post_id = absint( $received['post_id'] );

		if ( ! $post_id ) {
			return $response;
		}

		if ( ! current_user_can( 'edit_post', $post_id ) ) {
			return $response;
		}

		$response['wp-refresh-post-nonces'] = array(
			'replace' => array(
				'getpermalinknonce'    => wp_create_nonce( 'getpermalink' ),
				'samplepermalinknonce' => wp_create_nonce( 'samplepermalink' ),
				'closedpostboxesnonce' => wp_create_nonce( 'closedpostboxes' ),
				'_ajax_linking_nonce'  => wp_create_nonce( 'internal-linking' ),
				'_wpnonce'             => wp_create_nonce( 'update-post_' . $post_id ),
			),
		);
	}

	return $response;
}


Top ↑

Changelog

Changelog
VersionDescription
3.6.0Introduced.

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.