wp_refresh_post_nonces

函数
wp_refresh_post_nonces ( $response, $data, $screen_id )
参数
  • (array) $response The Heartbeat response.
    Required:
  • (array) $data The $_POST data sent.
    Required:
  • (string) $screen_id The screen ID.
    Required:
返回值
  • (array) The Heartbeat response.
定义位置
相关方法
wp_refresh_post_lockwp_refresh_heartbeat_nonceswp_refresh_metabox_loader_nonceswp_trash_post_commentswp_restore_post_revision
引入
3.6.0
弃用
-

wp_refresh_post_nonces: 这个函数用来刷新文章编辑器使用的nonces,以防止未经授权访问文章数据。

在新建/编辑文章界面检查nonce的过期情况,如果需要,可以刷新。

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;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2026-01-29 05:09:31

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: