php WP Nonces.phtml

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WP Nonces.phtml相关的知识,希望对你有一定的参考价值。


<form method="post">
    <input type="hidden" id="wpf_nonce_field" name="wpf_nonce_field" value="1cfd4c0539" />
    <input type="hidden" name="_wp_http_referer" value="/wp-trunk/contact/" />
    Enter your name: <input type="text" name="text" /><br />
    <input type="submit" name="submit" value="Save Options" /> 
</form>

<?php

/*
After your form is posted, the fi rst thing you need to do is check your nonce secret key using the wp _ verify _ nonce() function like so:
*/

if ( isset( $_POST['submit'] ) ) {
    //check nonce for security
    wp_verify_nonce( 'wpf_settings_form_save', 'wpf_nonce_field' ); 
    //nonce passed, now do stuff
}


// Verifying that the nonce is valid is as simple as calling the wp _ verify _ nonce() function

/*
Nonces can also be used on links that perform actions. To create a URL nonce, you use the wp _ nonce _ url() function. This can be used in conjunction with multiple query strings in your URL like so:
*/

$link = 'my-url.php?action=delete&ID=15';
?>

<a href="<?php echo wp_nonce_url( $link, 'wpf_delete_action', 'wpf_nonce_url_check' ); ?>">Delete</a>

以上是关于php WP Nonces.phtml的主要内容,如果未能解决你的问题,请参考以下文章

php WP Config模板#php #wp #wordpress #config

php wp - 使用/wp-login.php更新站点

php 通过FTP #wp #php创建WP用户管理员

php wp-config.php文件中的WP Mail SES设置

php WP插入挂钩之前的WP

php wp主循环#wp