Last active
September 13, 2015 17:35
-
-
Save danielpataki/398b986210adb31c5d44 to your computer and use it in GitHub Desktop.
Nonces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$delete_link = wp_get_shortlink( get_the_ID() ) . '&delete=true'; | |
$nonced_link = wp_nonce_url( $delete_link, 'delete-post-' . get_the_ID(), '_mynonce' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="hidden" id="_wpnonce" name="_wpnonce" value="37b392c8a0" /> | |
<input type="hidden" name="_wp_http_referer" value="/2015/02/13/my-article/" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wp_nonce_field( 'delete-post-' . get_the_ID() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ! isset( $_GET['_mynonce'] ) || ! wp_verify_nonce( $_GET['_mynonce'], 'delete-post-' . $_GET['p'] ) | |
) { | |
// Do something if the nonce does not verify | |
exit(); | |
} | |
// Process your form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ! isset( $_POST['field_name'] ) || ! wp_verify_nonce( $_POST['field_name'], 'action_name' ) | |
) { | |
// Do something if the nonce does not verify | |
exit(); | |
} | |
// Process your form |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment