کد PHP:
/* * Step A: Create an nonce for a link. * We pass it as a GET parameter. * The target page will perform some action based on the 'do_something' parameter. */$nonce = wp_create_nonce( 'my-nonce' );?><a href='myplugin.php?do_something=some_action&_wpnonce=<?php echo esc_attr( $nonce ); ?>'><?php esc_html_e( 'Do some action', 'textdomain' ); ?></a> /* * Step B: This code would go in the target page. * We need to verify the nonce. */$nonce = $_REQUEST['_wpnonce'];if ( ! wp_verify_nonce( $nonce, 'my-nonce' ) ) { // This nonce is not valid. die( __( 'Security check', 'textdomain' ) ); } else { // The nonce was valid. // Do stuff here.}
این مثال خود WP هست، یک توکن میسازه میزاره توی یک لینک، سپس در صفحه مورد نظر توکن را دریافت میکند و اعتبار سنجی میکند.