Last active
November 28, 2019 23:11
-
-
Save onliniak/99341adbf35ab3ac2a52f4f61e0caafd to your computer and use it in GitHub Desktop.
WordPress as UUID4 Validator
This file contains hidden or 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 | |
include_once $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php'; | |
$select = file_get_contents('php://input'); | |
if(empty($select)) { | |
echo wp_generate_uuid4(); | |
}else{ | |
wp_is_uuid( $select, 4 ); | |
echo 'UUID is correct'; | |
} |
This file contains hidden or 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
function GUID_get() { | |
fetch("guid.php") | |
.then((res) => { | |
return res.text(); | |
}) | |
.then((data) => { | |
sessionStorage.setItem("UUID", data); | |
console.log('UUID generated succesfull') | |
})}; | |
function GUID() { | |
fetch("guid.php", { | |
method: "POST", | |
body: sessionStorage.getItem('UUID') | |
}) | |
.then((res) => { | |
return res.text(); | |
}) | |
.then((data) => { | |
console.log(data) | |
})}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment