-
-
Save tommcfarlin/b1eac5df600177b7beb423477ccceee6 to your computer and use it in GitHub Desktop.
[WordPress] Secure WordPress Form Submission: An Object-Oriented Approach
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
<?php | |
protected function verifyRequest($nonce, $action); |
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
<?php | |
protected function verifyRequest($nonce, $action) | |
{ | |
return isset($_GET[$nonce]) && | |
wp_verify_nonce(strip_tags(stripslashes($_GET[$nonce])), $action); | |
} |
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
<?php | |
protected function verifyRequest($nonce, $action) | |
{ | |
return | |
( | |
isset($_GET[$nonce]) && | |
wp_verify_nonce(strip_tags(stripslashes($_GET[$nonce])), $action) | |
) || | |
( | |
isset($_POST[$nonce]) && | |
wp_verify_nonce(strip_tags(stripslashes($_POST[$nonce])), $action) | |
); | |
} |
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
<?php | |
private function verifyPostRequest($nonce, $action) | |
{ | |
return | |
isset($_POST[$nonce]) && | |
wp_verify_nonce(strip_tags(stripslashes(filter_input(INPUT_POST, $nonce))), $action); | |
} |
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
<?php | |
private function verifyGetRequest($nonce, $action) | |
{ | |
return | |
isset($_GET[$nonce]) && | |
wp_verify_nonce(strip_tags(stripslashes(filter_input(INPUT_GET, $nonce))), $action); | |
} |
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
<?php | |
protected function verifyRequest($nonce, $action) | |
{ | |
switch (strtolower($_SERVER['REQUEST_METHOD'])) { | |
case 'post': | |
return $this->verifyPostRequest($nonce, $action); | |
break; | |
case 'get': | |
return $this->verifyGetRequest($nonce, $action); | |
break; | |
default: | |
return false; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment