wp_nonce_url()获取在查询中添加了随机数的URL

目录

描述

译文

检索在查询中添加了随机数的URL。

原文

Retrieve URL with nonce added to URL query.

The returned result is escaped for display.

wp_nonce_url() 描述

用法

<?php wp_nonce_url$actionurl$action$name ); ?>

wp_nonce_url() 用法

参数

$actionurl

(string) (必填) URL to add nonce action

默认值: None

$action

(string) (可选) nonce action name

默认值: -1

$name

(string) (可选) nonce name

默认值: _wpnonce

wp_nonce_url() 参数

返回值

(string) 

URL with nonce action added.

wp_nonce_url() 返回值

示例

Plugin authors can safely add links that perform tasks using a combination of wp_nonce_url() and admin_url().

For instance, start by creating the link users can click to do something interesting:

Then, to detect when the user clicks the link, check the nonce validity using wp_verify_nonce() in the function you defined when you called add_menu_page() or one of its Administration Menus wrappers. If the nonce isn't valid, the link wasn't clicked, so display the link. Otherwise, do "something interesting."

Note that the recommended "context" parameter of the nonce is used to disambiguate which button was pressed. If you make more than one button users can press, make sure each button has a different nonce name and/or context.

wp_nonce_url() 示例

历史

添加于 版本: 2.0.4

wp_nonce_url() 历史

源文件

wp_nonce_url() 函数的代码位于 wp-includes/functions.php.

wp_nonce_url() 源文件

相关